Skip to content

Commit

Permalink
Merge pull request #167 from Hc747/master
Browse files Browse the repository at this point in the history
Modernise/update Gradle configuration and misc. polishing.
  • Loading branch information
bbakerman authored Dec 16, 2024
2 parents 229109d + 85f38c2 commit 1c19b6b
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 54 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ jobs:
MAVEN_CENTRAL_PGP_KEY: ${{ secrets.MAVEN_CENTRAL_PGP_KEY }}

steps:
- uses: actions/checkout@v1
- uses: gradle/wrapper-validation-action@v1
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v3
- 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
# 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:
CI: true
16 changes: 12 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,19 @@ jobs:
buildAndTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: gradle/wrapper-validation-action@v1
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v3
- 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
# 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:
CI: true
16 changes: 12 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,19 @@ jobs:
RELEASE_VERSION: ${{ github.event.inputs.version }}

steps:
- uses: actions/checkout@v1
- uses: gradle/wrapper-validation-action@v1
- uses: actions/checkout@v4
- uses: gradle/actions/wrapper-validation@v3
- 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
# 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:
CI: true
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand Down Expand Up @@ -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.


Expand Down
86 changes: 50 additions & 36 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}
27 changes: 26 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,27 @@
# 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
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
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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 {
mavenCentral()
}
}

0 comments on commit 1c19b6b

Please sign in to comment.