From a3b25b08e391d8e3ca918653f682794393f18670 Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:29:00 +1100 Subject: [PATCH 01/12] Enable `org.gradle.toolchains.foojay-resolver-convention` plugin. --- settings.gradle | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/settings.gradle b/settings.gradle index e69de29..91f1c2b 100644 --- a/settings.gradle +++ b/settings.gradle @@ -0,0 +1,10 @@ +plugins { + id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0' +} + + +dependencyResolutionManagement { + repositories { + mavenCentral() + } +} \ No newline at end of file From 4cc8a791c30f6943a120ec29ac0b21bf7b24136c Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:29:19 +1100 Subject: [PATCH 02/12] Enable `com.gradle.develocity` plugin. --- settings.gradle | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/settings.gradle b/settings.gradle index 91f1c2b..47404e7 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,7 +1,18 @@ plugins { + id 'com.gradle.develocity' version '3.19' id 'org.gradle.toolchains.foojay-resolver-convention' version '0.9.0' } +develocity { + buildScan { + final def isCI = System.getenv('CI') != null; + termsOfUseUrl = "https://gradle.com/help/legal-terms-of-use" + termsOfUseAgree = "yes" + publishing.onlyIf { true } + tag(isCI ? 'CI' : 'Local') + uploadInBackground = !isCI + } +} dependencyResolutionManagement { repositories { From dc86c97bfd2411fd270ebf0b69c3ef5533fb49ec Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:29:46 +1100 Subject: [PATCH 03/12] Set `CI:true` in `master.yml`, `release.yml` and `pull_request.yml`. --- .github/workflows/master.yml | 2 ++ .github/workflows/pull_request.yml | 2 ++ .github/workflows/release.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 6073cf3..221ce09 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -21,3 +21,5 @@ jobs: java-version: '11.0.23' - name: build test and publish run: ./gradlew assemble && ./gradlew check --info && ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -x check --info --stacktrace + env: + CI: true diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 007bfd2..1379be0 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -21,3 +21,5 @@ jobs: java-version: '11.0.23' - name: build and test run: ./gradlew assemble && ./gradlew check --info --stacktrace + env: + CI: true diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 090fc88..fee61a3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,3 +25,5 @@ jobs: java-version: '11.0.23' - name: build test and publish run: ./gradlew assemble && ./gradlew check --info && ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -x check --info --stacktrace + env: + CI: true From 2b7ce184e922cc41cba3883db8afab8f49ce15be Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:30:05 +1100 Subject: [PATCH 04/12] Update `README.MD` to reference `Java 11` instead of `Java 8`. --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4f5622d..fbfd620 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Latest Release](https://maven-badges.herokuapp.com/maven-central/com.graphql-java/java-dataloader/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java/java-dataloader/) [![Apache licensed](https://img.shields.io/hexpm/l/plug.svg?maxAge=2592000)](https://github.com/graphql-java/java-dataloader/blob/master/LICENSE) -This small and simple utility library is a pure Java 8 port of [Facebook DataLoader](https://github.com/facebook/dataloader). +This small and simple utility library is a pure Java 11 port of [Facebook DataLoader](https://github.com/facebook/dataloader). It can serve as integral part of your application's data layer to provide a consistent API over various back-ends and reduce message communication overhead through batching and caching. @@ -15,7 +15,7 @@ are resolved independently and, with a true graph of objects, you may be fetchin A naive implementation of graphql data fetchers can easily lead to the dreaded "n+1" fetch problem. Most of the code is ported directly from Facebook's reference implementation, with one IMPORTANT adaptation to make -it work for Java 8. ([more on this below](#manual-dispatching)). +it work for Java 11. ([more on this below](#manual-dispatching)). Before reading on, be sure to take a short dive into the [original documentation](https://github.com/facebook/dataloader/blob/master/README.md) provided by Lee Byron (@leebyron) @@ -774,10 +774,10 @@ This library was originally written for use within a [VertX world](http://vertx. itself. All the heavy lifting has been done by this project : [vertx-dataloader](https://github.com/engagingspaces/vertx-dataloader) including the extensive testing (which itself came from Facebook). -This particular port was done to reduce the dependency on Vertx and to write a pure Java 8 implementation with no dependencies and also +This particular port was done to reduce the dependency on Vertx and to write a pure Java 11 implementation with no dependencies and also to use the more normative Java CompletableFuture. -[vertx-core](http://vertx.io/docs/vertx-core/java/) is not a lightweight library by any means so having a pure Java 8 implementation is +[vertx-core](http://vertx.io/docs/vertx-core/java/) is not a lightweight library by any means so having a pure Java 11 implementation is very desirable. From 25832e34987418b936764d3718c185ca08997cbe Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:30:36 +1100 Subject: [PATCH 05/12] Configure gradle project wide settings. --- gradle.properties | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gradle.properties b/gradle.properties index 0394946..0db64ab 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,18 @@ +# Project-wide Gradle settings. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx4096m + +# When configured, Gradle will run in parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +org.gradle.parallel=true +org.gradle.caching=true + +# Bespoke settings. projectTitle = Java Dataloader projectDescription = Port of Facebook Dataloader for Java \ No newline at end of file From 240f86ac2a3345fb5fa1d09a3d172d3d96009ee7 Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:30:57 +1100 Subject: [PATCH 06/12] Update gradle wrapper to latest version (8.11.1). --- gradle/wrapper/gradle-wrapper.properties | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index d2880ba..e2847c8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 9e593c5a6dfe1df18ddd66a9c626d8d8b1721456 Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:31:18 +1100 Subject: [PATCH 07/12] Externalise dependency versions and update `junit` and `caffeine` to latest versions. --- gradle.properties | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 0db64ab..22d5603 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,4 +15,13 @@ org.gradle.caching=true # Bespoke settings. projectTitle = Java Dataloader -projectDescription = Port of Facebook Dataloader for Java \ No newline at end of file +projectDescription = Port of Facebook Dataloader for Java + +# Dependency versions. +junit_version=5.11.3 +hamcrest_version=2.2 +slf4j_version=1.7.30 +awaitility_version=2.0.0 +reactor_core_version=3.6.6 +caffeine_version=3.1.8 +reactive_streams_version=1.0.3 \ No newline at end of file From 11ebae9156e2d4bb79201518ad41401347e911ef Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:31:46 +1100 Subject: [PATCH 08/12] Modernise gradle build configuration. --- build.gradle | 86 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/build.gradle b/build.gradle index ccbcec6..70d3918 100644 --- a/build.gradle +++ b/build.gradle @@ -3,10 +3,13 @@ import java.text.SimpleDateFormat plugins { id 'java' id 'java-library' + id 'jvm-test-suite' id 'maven-publish' id 'signing' - id "biz.aQute.bnd.builder" version "6.2.0" - id "io.github.gradle-nexus.publish-plugin" version "1.0.0" + id 'groovy' + id 'biz.aQute.bnd.builder' version '6.2.0' + id 'io.github.gradle-nexus.publish-plugin' version '1.0.0' + id 'com.github.ben-manes.versions' version '0.51.0' } java { @@ -53,60 +56,65 @@ repositories { mavenLocal() } -apply plugin: 'groovy' - jar { manifest { attributes('Automatic-Module-Name': 'org.dataloader', - '-exportcontents': 'org.dataloader.*', - '-removeheaders': 'Private-Package') + '-exportcontents': 'org.dataloader.*', + '-removeheaders': 'Private-Package') } } -def slf4jVersion = '1.7.30' -def reactiveStreamsVersion = '1.0.3' - dependencies { - api 'org.slf4j:slf4j-api:' + slf4jVersion - api 'org.reactivestreams:reactive-streams:' + reactiveStreamsVersion - - testImplementation 'org.slf4j:slf4j-simple:' + slf4jVersion - testImplementation 'org.awaitility:awaitility:2.0.0' - testImplementation "org.hamcrest:hamcrest:2.2" - testImplementation 'io.projectreactor:reactor-core:3.6.6' - testImplementation 'com.github.ben-manes.caffeine:caffeine:2.9.0' - testImplementation platform('org.junit:junit-bom:5.10.2') - testImplementation 'org.junit.jupiter:junit-jupiter-api' - testImplementation 'org.junit.jupiter:junit-jupiter-params' - testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine' - testImplementation 'io.projectreactor:reactor-core:3.6.6' + api "org.slf4j:slf4j-api:$slf4j_version" + api "org.reactivestreams:reactive-streams:$reactive_streams_version" } task sourcesJar(type: Jar) { dependsOn classes - classifier 'sources' + archiveClassifier.set('sources') from sourceSets.main.allSource } -task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir -} - javadoc { options.encoding = 'UTF-8' } +task javadocJar(type: Jar, dependsOn: javadoc) { + archiveClassifier.set('javadoc') + from javadoc.destinationDir +} + artifacts { archives sourcesJar archives javadocJar } -test { - testLogging { - exceptionFormat = 'full' +testing { + suites { + test { + useJUnitJupiter(junit_version) + dependencies { + // Testing dependencies + implementation platform("org.junit:junit-bom:$junit_version") + implementation 'org.junit.jupiter:junit-jupiter-api' + implementation 'org.junit.jupiter:junit-jupiter-params' + implementation 'org.junit.jupiter:junit-jupiter-engine' + implementation "org.slf4j:slf4j-simple:$slf4j_version" + implementation "org.awaitility:awaitility:$awaitility_version" + implementation "org.hamcrest:hamcrest:$hamcrest_version" + implementation "io.projectreactor:reactor-core:$reactor_core_version" + implementation "com.github.ben-manes.caffeine:caffeine:$caffeine_version" + } + + targets.configureEach { + testTask.configure { + testLogging { + exceptionFormat = 'full' + } + } + } + } } - useJUnitPlatform() } publishing { @@ -180,9 +188,15 @@ tasks.withType(PublishToMavenRepository) { dependsOn build } - -task myWrapper(type: Wrapper) { - gradleVersion = '6.6.1' - distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip" +def isNonStable = { String version -> + def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) } + def regex = /^[0-9,.v-]+(-r)?$/ + return !stableKeyword && !(version ==~ regex) } +// https://github.com/ben-manes/gradle-versions-plugin +tasks.named("dependencyUpdates").configure { + rejectVersionIf { + isNonStable(it.candidate.version) + } +} \ No newline at end of file From a38f74189f4be8c77e1078d0f6b097f9cd938bd0 Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:34:54 +1100 Subject: [PATCH 09/12] Use `actions/checkout@v4` instead of `actions/checkout@v1` --- .github/workflows/master.yml | 2 +- .github/workflows/pull_request.yml | 2 +- .github/workflows/release.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 221ce09..a8e622a 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -13,7 +13,7 @@ jobs: MAVEN_CENTRAL_PGP_KEY: ${{ secrets.MAVEN_CENTRAL_PGP_KEY }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 - name: Set up JDK 11 uses: actions/setup-java@v1 diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1379be0..dc14596 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -13,7 +13,7 @@ jobs: buildAndTest: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 - name: Set up JDK 11 uses: actions/setup-java@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fee61a3..c37b2f9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,7 +17,7 @@ jobs: RELEASE_VERSION: ${{ github.event.inputs.version }} steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 - name: Set up JDK 11 uses: actions/setup-java@v1 From 5514c8cfffc31f165460f6c857d6b5fde4d4e32d Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:36:24 +1100 Subject: [PATCH 10/12] Use `actions/setup-java@v4` instead of `actions/setup-java@v1` --- .github/workflows/master.yml | 6 ++++-- .github/workflows/pull_request.yml | 6 ++++-- .github/workflows/release.yml | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index a8e622a..f5339e2 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -16,9 +16,11 @@ jobs: - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: - java-version: '11.0.23' + java-version: '11' + distribution: 'temurin' + check-latest: true - name: build test and publish run: ./gradlew assemble && ./gradlew check --info && ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -x check --info --stacktrace env: diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index dc14596..6f11e7a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -16,9 +16,11 @@ jobs: - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: - java-version: '11.0.23' + java-version: '11' + distribution: 'temurin' + check-latest: true - name: build and test run: ./gradlew assemble && ./gradlew check --info --stacktrace env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c37b2f9..ee351c4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,9 +20,11 @@ jobs: - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 - name: Set up JDK 11 - uses: actions/setup-java@v1 + uses: actions/setup-java@v4 with: - java-version: '11.0.23' + java-version: '11' + distribution: 'temurin' + check-latest: true - name: build test and publish run: ./gradlew assemble && ./gradlew check --info && ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -x check --info --stacktrace env: From 691e48147f9085b41dbbb7b8a925086cb54c082d Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:37:10 +1100 Subject: [PATCH 11/12] add `gradle/actions/setup-gradle@v4` to pipelines. --- .github/workflows/master.yml | 4 ++++ .github/workflows/pull_request.yml | 4 ++++ .github/workflows/release.yml | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index f5339e2..3febe71 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -21,6 +21,10 @@ jobs: java-version: '11' distribution: 'temurin' check-latest: true + # Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: build test and publish run: ./gradlew assemble && ./gradlew check --info && ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -x check --info --stacktrace env: diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 6f11e7a..d482821 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -21,6 +21,10 @@ jobs: java-version: '11' distribution: 'temurin' check-latest: true + # Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: build and test run: ./gradlew assemble && ./gradlew check --info --stacktrace env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ee351c4..5474744 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,6 +25,10 @@ jobs: java-version: '11' distribution: 'temurin' check-latest: true + # Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies. + # See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 - name: build test and publish run: ./gradlew assemble && ./gradlew check --info && ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository -x check --info --stacktrace env: From 85f38c2075c21d41503d4240019156ad246cabea Mon Sep 17 00:00:00 2001 From: Harrison Cole Date: Fri, 13 Dec 2024 16:44:16 +1100 Subject: [PATCH 12/12] Replace `gradle/wrapper-validation-action@v1` with `gradle/actions/wrapper-validation@v3` --- .github/workflows/master.yml | 2 +- .github/workflows/pull_request.yml | 2 +- .github/workflows/release.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 3febe71..01b89bc 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -14,7 +14,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v1 + - uses: gradle/actions/wrapper-validation@v3 - name: Set up JDK 11 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index d482821..f16bf96 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v1 + - uses: gradle/actions/wrapper-validation@v3 - name: Set up JDK 11 uses: actions/setup-java@v4 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5474744..a574a68 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,7 +18,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: gradle/wrapper-validation-action@v1 + - uses: gradle/actions/wrapper-validation@v3 - name: Set up JDK 11 uses: actions/setup-java@v4 with: