diff --git a/.github/workflows/maven_build.yml b/.github/workflows/maven_build.yml index 1a43998..943d2ab 100644 --- a/.github/workflows/maven_build.yml +++ b/.github/workflows/maven_build.yml @@ -1,4 +1,4 @@ -name: '[ BUILD ] Build Project (Java/Maven)' +name: '[ Start ] Build Project (Java/Maven)' on: workflow_dispatch: @@ -40,6 +40,8 @@ env: jobs: Build: runs-on: ubuntu-latest + outputs: + build_artifacts_id: ${{ steps.BuildArtifactUpload.outputs.artifact-id }} steps: - name: Checkout code uses: actions/checkout@v4 @@ -63,26 +65,36 @@ jobs: id: Build run: ./mvnw -T1C --batch-mode clean install + - name: Evaluate branch name where the scan results are added to in Sonarcloud + if: ${{inputs.actor != 'dependabot[bot]' }} + id: branch_to_scan + shell: bash + run: | + echo github.head_ref - pull request: ${{ github.head_ref }} + echo github.ref_name - push: ${{ github.ref_name }} + echo event: ${{ github.event_name }} + echo branch name to scan: ${{ github.head_ref || github.ref_name }} + echo name=${{ github.head_ref || github.ref_name }} >> $GITHUB_OUTPUT + - name: Javadoc and sign artifacts if: ${{ inputs.release_build }} - run: ./mvnw -T1C --batch-mode package javadoc:jar gpg:sign -Dgpg.signer=bc + run: ./mvnw -T1C --batch-mode package gpg:sign -Dgpg.signer=bc env: MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }} MAVEN_GPG_KEY: ${{ secrets.GPG_SIGNING_KEY }} GITHUB_DEPENDENCY_GRAPH_ENABLED: false + - name: (Info) Display structure of files + run: tree + - name: Upload build artifacts + id: BuildArtifactUpload uses: actions/upload-artifact@v4 with: - name: build-artifacts + name: build-artifacts-${{ inputs.build_version }} path: | - ./**/target/*${{inputs.build_version}}*.jar - ./**/target/*${{inputs.build_version}}*.jar.asc + ./**/target/*${{ inputs.build_version }}*.jar + ./**/target/*${{ inputs.build_version }}*.zip + ./**/target/*${{ inputs.build_version }}*.asc ./**/target/reports/ retention-days: 10 - - - name: Publish to GitHub Packages - if: ${{ inputs.release_build }} - run: mvn deploy - env: - GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/maven_publish.yml b/.github/workflows/maven_publish.yml index 4cfc623..2376360 100644 --- a/.github/workflows/maven_publish.yml +++ b/.github/workflows/maven_publish.yml @@ -1,4 +1,4 @@ -name: '[ PUBLISH ] Release build with maven' +name: '[ Step ] Publish artifacts with maven' on: workflow_call: @@ -7,36 +7,86 @@ on: description: 'The version to be published' type: string required: true - Publish: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Setup JDK - uses: actions/setup-java@v4 - with: - distribution: temurin - java-version: 17 - cache: 'maven' - cache-dependency-path: '**/pom.xml' - server-id: 'central' - server-username: ${{ secrets.SONATYPE_CENTRAL_USERNAME }} - server-password: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }} - - - name: Download build artifacts - uses: actions/download-artifact@v4 - with: - name: build-artifacts - - - name: Display structure of downloaded files - run: tree - - - name: Publish to Maven Central - run: ./mvnw deploy -DskipTests=true -Dmaven.javadoc.skip=true -B -V - - - name: Debug - if: ${{ failure() }} - run: | - echo "Failed" - tree \ No newline at end of file + build_artifact_id: + description: 'The id of the uploaded build artifacts.' + type: string + required: false + default: 'build-artifacts' +env: + BUILD_VERSION: ${{ inputs.build_version }} + +jobs: + PublishOnCentral: + name: 'Publish to Maven Central' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + cache: 'maven' + cache-dependency-path: '**/pom.xml' + server-id: 'central' + server-username: 'SERVER_USERNAME' + server-password: 'SERVER_PASSWORD' + + - name: (Info) Display build-version + run: echo ${{ inputs.build_version }} + + # - name: Download build artifacts + # uses: actions/download-artifact@v4 + # with: + # merge-multiple: true + # name: build-artifacts-${{ inputs.build_version }} + + - name: Set version + run: ./mvnw versions:set -DnewVersion=${{ inputs.build_version }} -DgenerateBackupPoms=false + + - name: Publish to Maven Central + run: ./mvnw -T1C --batch-mode deploy -Dgpg.signer=bc -Dcentral -DskipTests + env: + SERVER_USERNAME: ${{ secrets.SONATYPE_CENTRAL_USERNAME }} + SERVER_PASSWORD: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }} + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }} + MAVEN_GPG_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GITHUB_DEPENDENCY_GRAPH_ENABLED: false + + - name: (Info) Display structure of the files + if: always() + run: tree -D + + PublishGitHub: + name: 'Publish to GitHub packages' + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup JDK + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + cache: 'maven' + cache-dependency-path: '**/pom.xml' + server-id: 'github' + gpg-private-key: ${{ secrets.GPG_SIGNING_KEY }} + gpg-passphrase: ${{ secrets.GPG_SIGNING_KEY_PASSWORD }} + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + merge-multiple: true + name: build-artifacts-${{ inputs.build_version }} + + - name: Set version + run: ./mvnw versions:set -DnewVersion=${{ inputs.build_version }} -DgenerateBackupPoms=false + + - name: Publish to GitHub + run: ./mvnw deploy -DskipTests=true -Dmaven.javadoc.skip=true -B -V + env: + GITHUB_TOKEN: ${{ github.token }} diff --git a/.github/workflows/start_release.yml b/.github/workflows/start_release.yml index 4348fbe..e3a6dbd 100644 --- a/.github/workflows/start_release.yml +++ b/.github/workflows/start_release.yml @@ -1,6 +1,6 @@ # -name: '[ RELEASE ] Package & Deploy' +name: '[ Start ] Release artifacts, Build & Deploy' on: workflow_dispatch: @@ -49,6 +49,7 @@ jobs: packages: write UploadAssetsToRelease: + name: 'Upload assets to release' needs: [ ReleaseVersion, Build ] runs-on: ubuntu-latest permissions: @@ -57,6 +58,9 @@ jobs: BUILD_VERSION: ${{ needs.ReleaseVersion.outputs.build_version }} steps: + - name: (Info) build_artifact_id + run: echo "build_artifact_id=${{ needs.Build.outputs.build_artifact_id }}" + - uses: actions/download-artifact@v4 with: merge-multiple: true @@ -67,7 +71,10 @@ jobs: uses: softprops/action-gh-release@v2 with: files: | - ./**/build/libs/* + ./**/target/*.jar + ./**/target/*.jar.asc + ./**/target/*.pom + ./**/target/*.pom.asc ./LICENSE ./README.md @@ -76,6 +83,7 @@ jobs: uses: ./.github/workflows/maven_publish.yml with: build_version: ${{ needs.ReleaseVersion.outputs.build_version }} + build_artifact_id: ${{ needs.Build.outputs.build_artifact_id }} secrets: inherit permissions: packages: write diff --git a/README.md b/README.md index b64e992..8dc8045 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Java CI with Gradle](https://github.com/p3t/spring-curserpaging/actions/workflows/build.yml/badge.svg)](https://github.com/p3t/spring-curserpaging/actions/workflows/build.yml) +[![[ BUILD ] Build Project (Java/Maven)](https://github.com/p3t/spring-cursorpaging/actions/workflows/maven_build.yml/badge.svg)](https://github.com/p3t/spring-cursorpaging/actions/workflows/maven_build.yml) # Spring Data repository support for cursor based paging diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index 298ce08..0000000 --- a/build.gradle.kts +++ /dev/null @@ -1,3 +0,0 @@ -plugins { - base -} diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index 4fec1b3..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,24 +0,0 @@ -plugins { - `kotlin-dsl` -} - -repositories { - mavenCentral() - gradlePluginPortal() // so that external plugins can be resolved in dependencies section -} - -dependencies { - val kordampVersion: String by extra("0.54.0") -// implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:6.0.9") - implementation("io.freefair.gradle:lombok-plugin:8.10.2") - implementation("org.springframework.boot:spring-boot-gradle-plugin:3.3.5") - implementation("io.spring.gradle:dependency-management-plugin:1.1.6") -// implementation("org.kordamp.gradle:plugin-gradle-plugin:$kordampVersion") - implementation("org.kordamp.gradle:spotbugs-gradle-plugin:$kordampVersion") - implementation("org.kordamp.gradle:coveralls-gradle-plugin:$kordampVersion") - implementation("org.sonarqube:org.sonarqube.gradle.plugin:5.1.0.4882") - implementation("gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.2") - implementation("cl.franciscosolis:SonatypeCentralUpload:1.0.3") - testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.3") -} - diff --git a/buildSrc/src/main/kotlin/Dependencies.kt b/buildSrc/src/main/kotlin/Dependencies.kt deleted file mode 100644 index c4cf907..0000000 --- a/buildSrc/src/main/kotlin/Dependencies.kt +++ /dev/null @@ -1,3 +0,0 @@ -object Dependencies { - -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/Versions.kt b/buildSrc/src/main/kotlin/Versions.kt deleted file mode 100644 index 3bf8b20..0000000 --- a/buildSrc/src/main/kotlin/Versions.kt +++ /dev/null @@ -1,3 +0,0 @@ -object Versions { - const val springVersion = "3.3.5" -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/io.vigier.java-library-conventions.gradle.kts b/buildSrc/src/main/kotlin/io.vigier.java-library-conventions.gradle.kts deleted file mode 100644 index 856da1d..0000000 --- a/buildSrc/src/main/kotlin/io.vigier.java-library-conventions.gradle.kts +++ /dev/null @@ -1,143 +0,0 @@ -import org.gradle.api.tasks.testing.logging.TestExceptionFormat -import org.gradle.api.tasks.testing.logging.TestLogEvent - -// File: buildSrc/src/main/kotlin/java-project-conventions.gradle.kts -plugins { - id("java-library") - `jvm-test-suite` - id("io.freefair.lombok") - id("org.springframework.boot") apply false - id("io.spring.dependency-management") - `jacoco` - id("org.kordamp.gradle.spotbugs") - id("com.github.kt3k.coveralls") - id("org.kordamp.gradle.coveralls") - id("org.sonarqube") -} - -group = "io.vigier.cursorpaging" -version = findProperty("version") ?: System.getenv("BUILD_VERSION") ?: "0-SNAPSHOT" - -repositories { - mavenCentral() -} - -dependencyManagement { - imports { - mavenBom("org.springframework.boot:spring-boot-dependencies:${Versions.springVersion}") - } -} -// This is needed for sontarTypeCentralUpload! Has conflict with kordamp.java-project -java { - withSourcesJar() - withJavadocJar() -} -tasks.named("bootJar") { - enabled = false -} -tasks { - jacocoTestReport { - dependsOn(tasks.test) // tests are required to run before generating the report - reports { - xml.required = true - html.required = true - } - } - delombok { - enabled = false - } - jar { - archiveClassifier.set("") // needed to remove "-plain" when bootJar = false - } - test { - finalizedBy(tasks.jacocoTestReport) - testLogging { - events(TestLogEvent.FAILED, TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.STANDARD_OUT) - showExceptions = true - showCauses = true - showStackTraces = true - exceptionFormat = TestExceptionFormat.FULL - } - } -} - -config { - info { - inceptionYear = "2024" - vendor = "p3t/viger" - tags = listOf("paging", "spring", "jpa", "cursor") - description = "Cursor based paging support for Spring Data JPA" - - links { - scm = "https://github.com/p3t/spring-cursorpaging.git" - } - - people { - person { - id = "p3t" - name = "P. Vigier" - roles = listOf("developer", "maintainer") - } - } - - organization { - name = "p3t" - url = "https://github.com/p3t/spring-cursorpaging" - } - } - licensing { - enabled = false - licenses { - license { - id = "Apache-2.0" - primary = true - } - } - } - coverage { - coveralls { - enabled = false - } - } - quality { - spotbugs { - enabled = true - ignoreFailures = true - } - } -} - -ext["hibernate.version"] = "6.4.4.Final" -ext["junitVersion"] = findProperty("junitVersion") ?: "5.10.2" - -dependencies { - val lombokVersion: String by extra("1.18.32") - val junitVersion: String by extra("5.10.2") - val assertjVersion: String by extra("3.25.3") - - // Load BOM for Spring Boot. -// implementation(platform("org.springframework.boot:spring-boot-dependencies:3.2.5")) -// implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES)) - compileOnly("org.projectlombok:lombok:${lombokVersion}") - testCompileOnly("org.projectlombok:lombok:${lombokVersion}") - - annotationProcessor("org.projectlombok:lombok:${lombokVersion}") - testAnnotationProcessor("org.projectlombok:lombok:${lombokVersion}") - - // Testing - testImplementation("org.assertj:assertj-core:${assertjVersion}") -} - -java { - toolchain { - languageVersion = JavaLanguageVersion.of(17) - } -} - -testing { - suites { - val test by getting(JvmTestSuite::class) { - useJUnitJupiter() - } - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/io.vigier.java-publish-conventions.gradle.kts b/buildSrc/src/main/kotlin/io.vigier.java-publish-conventions.gradle.kts deleted file mode 100644 index 513d4f1..0000000 --- a/buildSrc/src/main/kotlin/io.vigier.java-publish-conventions.gradle.kts +++ /dev/null @@ -1,121 +0,0 @@ -import cl.franciscosolis.sonatypecentralupload.SonatypeCentralUploadTask - -plugins { - id("java-library") - id("maven-publish") - id("signing") - id("cl.franciscosolis.sonatype-central-upload") -} -version = findProperty("version") ?: System.getenv("BUILD_VERSION") ?: "0-SNAPSHOT" - -publishing { - val releaseVersion = version - repositories { - maven { - credentials { - username = System.getenv("GITHUB_ACTOR") - password = System.getenv("GITHUB_TOKEN") - } - name = "GitHubPackages" - url = uri("https://maven.pkg.github.com/p3t/spring-cursorpaging") - } - maven { - name = "staging" - url = layout.buildDirectory.dir("staging-deploy").get().asFile.toURI() - } - } - publications { - create("mavenJava") { - from(components["java"]) -// versionMapping { -// usage("java-api") { -// fromResolutionOf("runtimeClasspath") -// } -// usage("java-runtime") { -// fromResolutionResult() -// } -// } - } - withType { - pom { - version = releaseVersion.toString() - packaging = "jar" - name.set("spring-cursorpaging") - description.set("Cursor paging support for Spring Data") - url.set("https://github.com/p3t/spring-cursorpaging/") - inceptionYear.set("2024") - licenses { - license { - name.set("Apache2 license") - url.set("https://apache.org/licenses/LICENSE-2.0") - } - } - developers { - developer { - id.set("p3t") - name.set("Peter Vigier") - email.set("3204560+p3t@users.noreply.github.com") - } - } - scm { - connection.set("scm:git:git@github.com:p3t/spring-cursorpaging.git") - developerConnection.set("scm:git:ssh:git@github.com:p3t/spring-cursorpaging.git") - url.set("https://github.com/p3t/spring-cursorpaging") - } - } - } - } -} -signing { - val GPG_SIGNING_KEY_PASSWORD: String? by project - val GPG_SIGNING_KEY: String? by project - val GPG_KEY_ID: String? by project - - val signingKey = (GPG_SIGNING_KEY ?: System.getenv("GPG_SIGNING_KEY")) - val signingKeyId = (GPG_KEY_ID ?: System.getenv("GPG_KEY_ID")) - val signingKeyPassphrase = (GPG_SIGNING_KEY_PASSWORD ?: System.getenv("GPG_SIGNING_KEY_PASSWORD")) - - isRequired = true - - logger.info("Signing> Key ID: $signingKeyId") - logger.info("Signing> Password is present: {}", signingKeyPassphrase.orEmpty().length) - logger.info("Signing> Key is present: {}", signingKey.orEmpty().length) - - useInMemoryPgpKeys(signingKeyId, signingKey, signingKeyPassphrase) - sign(publishing.publications["mavenJava"]) -} - -tasks.named("sonatypeCentralUpload") { - dependsOn("jar", "sourcesJar", "javadocJar", "generatePomFileForMavenJavaPublication") - - val mavenCentralUsername: String? by project - val mavenCentralPassword: String? by project - - username = mavenCentralUsername ?: System.getenv("SONATYPE_CENTRAL_USERNAME") - password = mavenCentralPassword ?: System.getenv("SONATYPE_CENTRAL_PASSWORD") - - // This is a list of files to upload. Ideally you would point to your jar file, source and javadoc jar (required by central) - archives = files( - tasks.named("jar"), - tasks.named("sourcesJar"), - tasks.named("javadocJar"), -// tasks.named("signing"), - ) - // This is the pom file to upload. This is required by central - pom = file( - layout.buildDirectory.file("publications/mavenJava/pom-default.xml") -// tasks.publish.get().outputs.files.single() -// tasks.named("generatePomFileForMavenJavaPublication").get().outputs.files.single() - ) - - val GPG_SIGNING_KEY_PASSWORD: String? by project - val GPG_SIGNING_KEY: String? by project - - signingKey = (GPG_SIGNING_KEY ?: System.getenv("GPG_SIGNING_KEY")) - signingKeyPassphrase = (GPG_SIGNING_KEY_PASSWORD ?: System.getenv("GPG_SIGNING_KEY_PASSWORD")) - - logger.info("Signing> Password is present: {}", signingKeyPassphrase.isPresent) - logger.info("Signing> Key is present: {}", signingKey.isPresent) - - publishingType = "MANUAL" -} diff --git a/cursorpaging-examples/build.gradle.kts b/cursorpaging-examples/build.gradle.kts deleted file mode 100644 index 76ec3c2..0000000 --- a/cursorpaging-examples/build.gradle.kts +++ /dev/null @@ -1,2 +0,0 @@ -group = "io.vigier.cursorpaging.examples" -version = findProperty("version") ?: System.getenv("BUILD_VERSION") ?: "0-SNAPSHOT" \ No newline at end of file diff --git a/cursorpaging-examples/webapp-with-maven/build.gradle.kts b/cursorpaging-examples/webapp-with-maven/build.gradle.kts deleted file mode 100644 index 312bc27..0000000 --- a/cursorpaging-examples/webapp-with-maven/build.gradle.kts +++ /dev/null @@ -1,68 +0,0 @@ -// Gradle build to include the example in the project build -// While the maven pom.xml es executed separately - -plugins { - java - id("org.springframework.boot") - id("io.vigier.java-library-conventions") -} - -group = "io.vigier.cursorpaging.examples.webapp" -version = findProperty("version") ?: System.getenv("BUILD_VERSION") ?: "0-SNAPSHOT" - -dependencies { - val mapstructVersion: String by extra("1.5.5.Final") - - implementation(project(":cursorpaging-jpa")) - implementation(project(":cursorpaging-jpa-api")) - - implementation("org.springframework.boot:spring-boot-starter-data-jpa") - implementation("org.springframework.boot:spring-boot-starter-web") - implementation("org.springframework.boot:spring-boot-starter-validation") - implementation("org.springframework.hateoas:spring-hateoas") - implementation("org.springframework.retry:spring-retry") - implementation("org.springframework:spring-aspects") - implementation("org.apache.commons:commons-lang3") -// compileOnly("javax.xml.bind:jaxb-api") - - implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0") - implementation("org.mapstruct:mapstruct:${mapstructVersion}") - - annotationProcessor("org.mapstruct:mapstruct-processor:${mapstructVersion}") - annotationProcessor("org.hibernate:hibernate-jpamodelgen:6.6.1.Final") - -// implementation("org.springframework.boot:spring-boot-starter-data-mongodb") -// implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive") -// implementation("org.springframework.boot:spring-boot-starter-data-r2dbc") -// implementation("org.liquibase:liquibase-core") - - - runtimeOnly("org.postgresql:postgresql") -// runtimeOnly("org.postgresql:r2dbc-postgresql") - -// annotationProcessor("org.hibernate:hibernate-jpamodelgen") -// annotationProcessor("org.springframework.boot:spring-boot-configuration-processor") - - developmentOnly("org.springframework.boot:spring-boot-devtools") - developmentOnly("org.springframework.boot:spring-boot-docker-compose") - - testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.springframework.boot:spring-boot-testcontainers") - testImplementation("org.testcontainers:junit-jupiter") - testImplementation("org.testcontainers:postgresql") -// testImplementation("io.projectreactor:reactor-test") -// testImplementation("org.testcontainers:mongodb") -// testImplementation("org.testcontainers:r2dbc") -} - -tasks { - javadoc { - options { - (this as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet") - } - } - test { - useJUnitPlatform() - } - -} diff --git a/cursorpaging-jpa-api/build.gradle.kts b/cursorpaging-jpa-api/build.gradle.kts deleted file mode 100644 index 85e078a..0000000 --- a/cursorpaging-jpa-api/build.gradle.kts +++ /dev/null @@ -1,88 +0,0 @@ -plugins { - id("io.vigier.java-library-conventions") - id("io.vigier.java-publish-conventions") - id("com.google.protobuf") -} - -group = "io.vigier.cursorpaging" -ext["artifactId"] = findProperty("artifactId") ?: "cursorpaging-jpa-api" - -configurations { - compileOnly { - extendsFrom(configurations.annotationProcessor.get()) - } -} - -repositories { - mavenCentral() -} - -dependencies { - api(project(":cursorpaging-jpa")) - implementation("org.springframework:spring-core") - api("jakarta.validation:jakarta.validation-api") - - implementation("com.fasterxml.jackson.core:jackson-annotations") - implementation("com.fasterxml.jackson.core:jackson-core") - implementation("com.fasterxml.jackson.core:jackson-databind") -// implementation("com.fasterxml.jackson.core:jackson-datatype-jsr310") - - implementation("com.google.protobuf:protobuf-java:4.28.3") - - testImplementation("jakarta.persistence:jakarta.persistence-api") - testImplementation("org.hibernate.orm:hibernate-jpamodelgen") - testImplementation("org.assertj:assertj-core") - testImplementation("org.hibernate.orm:hibernate-core") - testImplementation("jakarta.transaction:jakarta.transaction-api") - testImplementation("org.springframework.boot:spring-boot-testcontainers") - testImplementation("org.springframework.boot:spring-boot-test") - testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.springframework.retry:spring-retry") - testImplementation("org.mockito:mockito-core") - testImplementation("org.mockito:mockito-junit-jupiter") - testImplementation("org.testcontainers:testcontainers") - testImplementation("org.testcontainers:junit-jupiter") - testImplementation("org.testcontainers:postgresql") - - testAnnotationProcessor("org.hibernate:hibernate-jpamodelgen:6.6.1.Final") - testRuntimeOnly("org.postgresql:postgresql") -} -publishing { - publications.named("mavenJava") { - pom { - description = "Serialization/Deserialization support of page-request for Spring-CursorPaging" - } - } -} -tasks { - withType { - useJUnitPlatform() - } - javadoc { - options { - (this as CoreJavadocOptions).addStringOption("Xdoclint:none", "-quiet") - } - } - processResources { - // On GitHub actions the proto file seems to be copied twice - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - } -} -protobuf { - protoc { - // Download from repositories - artifact = "com.google.protobuf:protoc:4.28.3" - } - generateProtoTasks { - java{ - } - } -} - -sourceSets { - main { - proto { - srcDir("src/main/protobuf") - } - } -} \ No newline at end of file diff --git a/cursorpaging-jpa-api/pom.xml b/cursorpaging-jpa-api/pom.xml index fa7d01d..456768f 100644 --- a/cursorpaging-jpa-api/pom.xml +++ b/cursorpaging-jpa-api/pom.xml @@ -58,11 +58,7 @@ protobuf-java compile - - org.hibernate.orm - hibernate-jpamodelgen - compile - + org.projectlombok @@ -70,6 +66,11 @@ provided + + org.hibernate.orm + hibernate-jpamodelgen + test + org.junit.jupiter junit-jupiter @@ -90,10 +91,23 @@ mockito-core test - + + + org.projectlombok + lombok-maven-plugin + + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + + io.github.ascopes protobuf-maven-plugin @@ -101,23 +115,4 @@ - - - RELEASE_BUILD - - - RELEASE_BUILD - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - - - - - diff --git a/cursorpaging-jpa/build.gradle.kts b/cursorpaging-jpa/build.gradle.kts deleted file mode 100644 index 559f26a..0000000 --- a/cursorpaging-jpa/build.gradle.kts +++ /dev/null @@ -1,53 +0,0 @@ -plugins { - id("io.vigier.java-library-conventions") - id("io.vigier.java-publish-conventions") -} - -group = "io.vigier.cursorpaging" - -ext["artifactId"] = findProperty("artifactId") ?: "cursorpaging-jpa" - - -dependencies { - implementation("org.springframework.boot:spring-boot-starter-data-jpa") - api("jakarta.validation:jakarta.validation-api") - api("jakarta.persistence:jakarta.persistence-api") - api("org.springframework.data:spring-data-jpa") - implementation("org.springframework.boot:spring-boot-autoconfigure") - implementation("org.yaml:snakeyaml") - - - testImplementation("org.hibernate.orm:hibernate-core") - testImplementation("jakarta.transaction:jakarta.transaction-api") - testImplementation("org.springframework.boot:spring-boot-testcontainers") - testImplementation("org.springframework.boot:spring-boot-test") - testImplementation("org.springframework.boot:spring-boot-starter-test") - testImplementation("org.springframework.retry:spring-retry") - testImplementation("org.mockito:mockito-core") - testImplementation("org.mockito:mockito-junit-jupiter") - testImplementation("org.testcontainers:testcontainers") - testImplementation("org.testcontainers:junit-jupiter") - testImplementation("org.testcontainers:postgresql") - testImplementation("org.assertj:assertj-core") - testAnnotationProcessor("org.hibernate:hibernate-jpamodelgen:6.6.1.Final") - testRuntimeOnly("org.postgresql:postgresql") -} - -publishing { - publications.named("mavenJava") { - pom { - description = "Cursor based paging support for Spring Data JPA repositories" - } - } -} - -tasks.test { - useJUnitPlatform() -} - -tasks.jacocoTestReport { - reports { - xml.required = true - } -} - diff --git a/cursorpaging-jpa/pom.xml b/cursorpaging-jpa/pom.xml index 8692f19..7ba4721 100644 --- a/cursorpaging-jpa/pom.xml +++ b/cursorpaging-jpa/pom.xml @@ -48,11 +48,7 @@ jakarta.persistence jakarta.persistence-api - - - - - + org.springframework.data spring-data-jpa @@ -73,12 +69,38 @@ provided + + + org.springframework.boot + spring-boot-starter-test + test + + + org.springframework.boot + spring-boot-starter + test + + + org.springframework.boot + spring-boot-starter-data-jpa + test + + + org.springframework + spring-aspects + test + org.hibernate.orm hibernate-core test + + org.yaml + snakeyaml + test + jakarta.transaction jakarta.transaction-api @@ -92,6 +114,7 @@ org.springframework.boot spring-boot-test + test org.springframework.retry @@ -146,25 +169,16 @@ org.projectlombok lombok-maven-plugin + + org.apache.maven.plugins + maven-source-plugin + + + org.apache.maven.plugins + maven-javadoc-plugin + - - - RELEASE_BUILD - - - RELEASE_BUILD - - - - - - - org.apache.maven.plugins - maven-gpg-plugin - - - - - + + diff --git a/cursorpaging-jpa/src/test/java/io/vigier/cursorpaging/jpa/itest/PostgreSqlTestConfiguration.java b/cursorpaging-jpa/src/test/java/io/vigier/cursorpaging/jpa/itest/PostgreSqlTestConfiguration.java index fb6b7d3..5e7a492 100644 --- a/cursorpaging-jpa/src/test/java/io/vigier/cursorpaging/jpa/itest/PostgreSqlTestConfiguration.java +++ b/cursorpaging-jpa/src/test/java/io/vigier/cursorpaging/jpa/itest/PostgreSqlTestConfiguration.java @@ -7,12 +7,14 @@ import org.springframework.boot.test.context.TestConfiguration; import org.springframework.boot.testcontainers.service.connection.ServiceConnection; import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; import org.springframework.retry.annotation.EnableRetry; import org.springframework.retry.annotation.Retryable; import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.junit.jupiter.Testcontainers; import org.testcontainers.utility.DockerImageName; +@Configuration @TestConfiguration( proxyBeanMethods = false ) @Testcontainers @EnableRetry diff --git a/cursorpaging-jpa/src/test/resources/application.yml b/cursorpaging-jpa/src/test/resources/application.yml index 974506f..03aadb5 100644 --- a/cursorpaging-jpa/src/test/resources/application.yml +++ b/cursorpaging-jpa/src/test/resources/application.yml @@ -3,7 +3,7 @@ spring: jpa: hibernate.ddl-auto: create database-platform: "org.hibernate.dialect.PostgreSQLDialect" - show-sql: true + show-sql: false datasource: driver-class-name: "org.postgresql.Driver" url: "jdbc:postgresql://localhost:5432/cursor-db" diff --git a/gradle.properties b/gradle.properties deleted file mode 100644 index 90d6c94..0000000 --- a/gradle.properties +++ /dev/null @@ -1 +0,0 @@ -version=0-SNAPSHOT \ No newline at end of file diff --git a/gradle/LICENSE_HEADER b/gradle/LICENSE_HEADER deleted file mode 100644 index 912d55b..0000000 --- a/gradle/LICENSE_HEADER +++ /dev/null @@ -1 +0,0 @@ -(c) 2024 p3t [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0) \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index 7f93135..0000000 Binary files a/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 3fa8f86..0000000 --- a/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,7 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip -networkTimeout=10000 -validateDistributionUrl=true -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew deleted file mode 100755 index 1aa94a4..0000000 --- a/gradlew +++ /dev/null @@ -1,249 +0,0 @@ -#!/bin/sh - -# -# Copyright © 2015-2021 the original authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -############################################################################## -# -# Gradle start up script for POSIX generated by Gradle. -# -# Important for running: -# -# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is -# noncompliant, but you have some other compliant shell such as ksh or -# bash, then to run this script, type that shell name before the whole -# command line, like: -# -# ksh Gradle -# -# Busybox and similar reduced shells will NOT work, because this script -# requires all of these POSIX shell features: -# * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». -# -# Important for patching: -# -# (2) This script targets any POSIX shell, so it avoids extensions provided -# by Bash, Ksh, etc; in particular arrays are avoided. -# -# The "traditional" practice of packing multiple parameters into a -# space-separated string is a well documented source of bugs and security -# problems, so this is (mostly) avoided, by progressively accumulating -# options in "$@", and eventually passing that to Java. -# -# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, -# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; -# see the in-line comments for details. -# -# There are tweaks for specific operating systems such as AIX, CygWin, -# Darwin, MinGW, and NonStop. -# -# (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt -# within the Gradle project. -# -# You can find Gradle at https://github.com/gradle/gradle/. -# -############################################################################## - -# Attempt to set APP_HOME - -# Resolve links: $0 may be a link -app_path=$0 - -# Need this for daisy-chained symlinks. -while - APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path - [ -h "$app_path" ] -do - ls=$( ls -ld "$app_path" ) - link=${ls#*' -> '} - case $link in #( - /*) app_path=$link ;; #( - *) app_path=$APP_HOME$link ;; - esac -done - -# This is normally unused -# shellcheck disable=SC2034 -APP_BASE_NAME=${0##*/} -# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD=maximum - -warn () { - echo "$*" -} >&2 - -die () { - echo - echo "$*" - echo - exit 1 -} >&2 - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "$( uname )" in #( - CYGWIN* ) cygwin=true ;; #( - Darwin* ) darwin=true ;; #( - MSYS* | MINGW* ) msys=true ;; #( - NONSTOP* ) nonstop=true ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD=java - if ! command -v java >/dev/null 2>&1 - then - die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -fi - -# Increase the maximum file descriptors if we can. -if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then - case $MAX_FD in #( - max*) - # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - MAX_FD=$( ulimit -H -n ) || - warn "Could not query maximum file descriptor limit" - esac - case $MAX_FD in #( - '' | soft) :;; #( - *) - # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC2039,SC3045 - ulimit -n "$MAX_FD" || - warn "Could not set maximum file descriptor limit to $MAX_FD" - esac -fi - -# Collect all arguments for the java command, stacking in reverse order: -# * args from the command line -# * the main class name -# * -classpath -# * -D...appname settings -# * --module-path (only if needed) -# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. - -# For Cygwin or MSYS, switch paths to Windows format before running java -if "$cygwin" || "$msys" ; then - APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) - CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) - - JAVACMD=$( cygpath --unix "$JAVACMD" ) - - # Now convert the arguments - kludge to limit ourselves to /bin/sh - for arg do - if - case $arg in #( - -*) false ;; # don't mess with options #( - /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath - [ -e "$t" ] ;; #( - *) false ;; - esac - then - arg=$( cygpath --path --ignore --mixed "$arg" ) - fi - # Roll the args list around exactly as many times as the number of - # args, so each arg winds up back in the position where it started, but - # possibly modified. - # - # NB: a `for` loop captures its iteration list before it begins, so - # changing the positional parameters here affects neither the number of - # iterations, nor the values presented in `arg`. - shift # remove old arg - set -- "$@" "$arg" # push replacement arg - done -fi - - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' - -# Collect all arguments for the java command: -# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, -# and any embedded shellness will be escaped. -# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be -# treated as '${Hostname}' itself on the command line. - -set -- \ - "-Dorg.gradle.appname=$APP_BASE_NAME" \ - -classpath "$CLASSPATH" \ - org.gradle.wrapper.GradleWrapperMain \ - "$@" - -# Stop when "xargs" is not available. -if ! command -v xargs >/dev/null 2>&1 -then - die "xargs is not available" -fi - -# Use "xargs" to parse quoted args. -# -# With -n1 it outputs one arg per line, with the quotes and backslashes removed. -# -# In Bash we could simply go: -# -# readarray ARGS < <( xargs -n1 <<<"$var" ) && -# set -- "${ARGS[@]}" "$@" -# -# but POSIX shell has neither arrays nor command substitution, so instead we -# post-process each arg (as a line of input to sed) to backslash-escape any -# character that might be a shell metacharacter, then use eval to reverse -# that process (while maintaining the separation between arguments), and wrap -# the whole thing up as a single "set" statement. -# -# This will of course break if any of these variables contains a newline or -# an unmatched quote. -# - -eval "set -- $( - printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | - xargs -n1 | - sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | - tr '\n' ' ' - )" '"$@"' - -exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 93e3f59..0000000 --- a/gradlew.bat +++ /dev/null @@ -1,92 +0,0 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%"=="" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto execute - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* - -:end -@rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/pom.xml b/pom.xml index 6e25330..70ba989 100644 --- a/pom.xml +++ b/pom.xml @@ -14,19 +14,11 @@ cursorpaging-jpa-api - Spring-CursorPagingm + Spring-CursorPaging Cursor based paging support for Spring Data https://github.com/p3t/spring-cursorpaging/ 2024 - - - github - GitHub Packages - https://maven.pkg.github.com/p3t/spring-cursorpaging/ - - - Apache2 license @@ -64,17 +56,17 @@ - - jakarta.validation - jakarta.validation-api - 3.1.0 - compile - - - jakarta.persistence - jakarta.persistence-api - 3.2.0 - + + + + + + + + + + + org.hibernate.common @@ -147,6 +139,13 @@ import pom + + org.springframework.boot + spring-boot-starter-test + ${springboot.version} + import + pom + org.hibernate.orm @@ -246,6 +245,28 @@ ${delombok.output} false + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + + jar-no-fork + + package + + @@ -259,9 +280,9 @@ sign - - bc - + + + @@ -273,10 +294,16 @@ true central - uploaded + validated + Spring-CursorPaging + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.1 + @@ -289,4 +316,41 @@ + + + github + + + !central + + + + + github + GitHub Packages + https://maven.pkg.github.com/p3t/spring-cursorpaging/ + + + + + central + + + central + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + org.sonatype.central + central-publishing-maven-plugin + + + + + \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts deleted file mode 100644 index ef3965c..0000000 --- a/settings.gradle.kts +++ /dev/null @@ -1,38 +0,0 @@ -pluginManagement { -// val springBootPluginVersion: String by settings // use project property with version - plugins { - id("com.gradle.develocity") version ("3.17.2") - id("com.google.protobuf") version "0.9.4" -// id("org.springframework.boot") version "${springBootPluginVersion}" - } - resolutionStrategy { - } - repositories { - } -} - -plugins { - id("com.gradle.develocity") -} - -dependencyResolutionManagement { - repositories { - mavenCentral() - } -} - - - -rootProject.name = "spring-cursorpaging" - -include("cursorpaging-jpa", "cursorpaging-jpa-api") -include("cursorpaging-examples:webapp-with-maven") -//project("cursorpaging-example-webapp") -// .projectDir = file("cursorpaging-examples/webapp-with-maven") - -develocity { - buildScan { - termsOfUseUrl.set("https://gradle.com/help/legal-terms-of-use") - termsOfUseAgree.set("yes") - } -} \ No newline at end of file diff --git a/version.txt b/version.txt deleted file mode 100644 index 3e3795f..0000000 --- a/version.txt +++ /dev/null @@ -1 +0,0 @@ -0-SNAPSHOT \ No newline at end of file