diff --git a/.github/workflows/ci-build-manual-crf.yml b/.github/workflows/ci-build-manual-crf.yml index b3f47bd7f8..3cf6146adf 100644 --- a/.github/workflows/ci-build-manual-crf.yml +++ b/.github/workflows/ci-build-manual-crf.yml @@ -18,10 +18,10 @@ jobs: with: fetch-tags: true fetch-depth: 0 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: - java-version: '17.0.10+7' + java-version: '21' distribution: 'temurin' cache: 'gradle' - name: Build with Gradle diff --git a/.github/workflows/ci-build-manual-eval.yml b/.github/workflows/ci-build-manual-eval.yml index ed480485d4..41095443f9 100644 --- a/.github/workflows/ci-build-manual-eval.yml +++ b/.github/workflows/ci-build-manual-eval.yml @@ -20,10 +20,10 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: - java-version: '17.0.10+7' + java-version: '21' distribution: 'temurin' cache: 'gradle' - name: Build with Gradle diff --git a/.github/workflows/ci-build-manual-full.yml b/.github/workflows/ci-build-manual-full.yml index 9c5876ad2a..11f4dd2235 100644 --- a/.github/workflows/ci-build-manual-full.yml +++ b/.github/workflows/ci-build-manual-full.yml @@ -18,10 +18,10 @@ jobs: with: fetch-tags: true fetch-depth: 0 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: - java-version: '17.0.10+7' + java-version: '21' distribution: 'temurin' cache: 'gradle' - name: Build with Gradle diff --git a/.github/workflows/ci-build-unstable.yml b/.github/workflows/ci-build-unstable.yml index 117d29c1e1..b6cde5305d 100644 --- a/.github/workflows/ci-build-unstable.yml +++ b/.github/workflows/ci-build-unstable.yml @@ -13,11 +13,11 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Set up JDK 11 + - name: Set up JDK 21 uses: actions/setup-java@v4 with: - java-version: '11' - distribution: 'adopt' + java-version: '21' + distribution: 'temurin' cache: 'gradle' - name: Build with Gradle run: ./gradlew clean assemble --info --stacktrace --no-daemon diff --git a/Dockerfile.crf b/Dockerfile.crf index c57b3126e3..4ffbc84fbe 100644 --- a/Dockerfile.crf +++ b/Dockerfile.crf @@ -13,7 +13,7 @@ # ------------------- # build builder image # ------------------- -FROM eclipse-temurin:17.0.15_6-jdk AS builder +FROM eclipse-temurin:21-jdk AS builder USER root @@ -66,7 +66,7 @@ RUN rm -rf grobid-source # ------------------- # build runtime image # ------------------- -FROM eclipse-temurin:17.0.15_6-jre +FROM eclipse-temurin:21-jre RUN apt-get update && \ apt-get -y upgrade && \ diff --git a/Dockerfile.delft b/Dockerfile.delft index 8d92aedd94..9fa74eb519 100644 --- a/Dockerfile.delft +++ b/Dockerfile.delft @@ -15,7 +15,7 @@ # build builder image # ------------------- -FROM eclipse-temurin:17.0.15_6-jdk AS builder +FROM eclipse-temurin:21-jdk AS builder USER root @@ -122,8 +122,9 @@ COPY --from=builder /opt/java/openjdk ${JAVA_HOME} # install jep RUN pip3 install jep==4.0.3 - -ENV LD_LIBRARY_PATH=/usr/local/lib/python3.8/dist-packages/jep:grobid-home/lib/lin-64:grobid-home/lib/lin-64/jep:${LD_LIBRARY_PATH} +# Get the Python version dynamically and set LD_LIBRARY_PATH accordingly +ENV PYTHON_VERSION=$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1,2) +ENV LD_LIBRARY_PATH=/usr/local/lib/python${PYTHON_VERSION}/dist-packages/jep:grobid-home/lib/lin-64:grobid-home/lib/lin-64/jep:${LD_LIBRARY_PATH} # remove libjep.so because we are providing our own version in the virtual env above RUN rm /opt/grobid/grobid-home/lib/lin-64/jep/libjep.so diff --git a/Dockerfile.evaluation b/Dockerfile.evaluation index b70ef9ca25..fa41c61419 100644 --- a/Dockerfile.evaluation +++ b/Dockerfile.evaluation @@ -12,7 +12,7 @@ # build builder image # ------------------- -FROM eclipse-temurin:17.0.15_6-jdk AS builder +FROM eclipse-temurin:21-jdk AS builder USER root @@ -115,8 +115,9 @@ COPY --from=builder /opt/java/openjdk ${JAVA_HOME} # install jep RUN pip3 install jep==4.0.3 - -ENV LD_LIBRARY_PATH=/usr/local/lib/python3.8/dist-packages/jep:grobid-home/lib/lin-64:grobid-home/lib/lin-64/jep:${LD_LIBRARY_PATH} +# Get the Python version dynamically and set LD_LIBRARY_PATH accordingly +ENV PYTHON_VERSION=$(python3 --version | cut -d' ' -f2 | cut -d'.' -f1,2) +ENV LD_LIBRARY_PATH=/usr/local/lib/python${PYTHON_VERSION}/dist-packages/jep:grobid-home/lib/lin-64:grobid-home/lib/lin-64/jep:${LD_LIBRARY_PATH} # remove libjep.so because we are providing our own version in the virtual env above RUN rm /opt/grobid/grobid-home/lib/lin-64/jep/libjep.so diff --git a/build.gradle b/build.gradle index 4e54782d31..ed559f01bc 100644 --- a/build.gradle +++ b/build.gradle @@ -1,19 +1,9 @@ -buildscript { - repositories { - mavenLocal() - mavenCentral() - maven { - url 'https://plugins.gradle.org/m2/' - } - gradlePluginPortal() - } - dependencies { - classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.0' - classpath "gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0" - classpath 'com.adarshr:gradle-test-logger-plugin:2.0.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21" - classpath "net.researchgate:gradle-release:3.0.2" - } +plugins { + id 'org.jetbrains.kotlin.jvm' version '2.0.0' apply false + id 'com.gradleup.shadow' version '8.3.8' apply false + id 'com.adarshr.test-logger' version '4.0.0' apply false + id 'com.github.kt3k.coveralls' version '2.12.2' apply false + id 'net.researchgate.release' version '3.1.0' apply false } repositories { @@ -59,6 +49,7 @@ def getJavaLibraryPath = { } apply plugin: 'jacoco' +apply plugin: 'com.github.kt3k.coveralls' jacoco { toolVersion = '0.8.8' @@ -70,7 +61,7 @@ def getGitRevision() { try { def stdout = new ByteArrayOutputStream() println("Checking git under ${rootProject.rootDir}") - exec { + project.exec { workingDir rootProject.rootDir commandLine 'git', 'describe', '--tags', '--always', '--first-parent' standardOutput = stdout @@ -94,11 +85,6 @@ tasks.register('collectGitRevision') { } allprojects { - apply plugin: 'java-library' - apply plugin: 'base' - apply plugin: 'com.github.kt3k.coveralls' - apply plugin: 'com.adarshr.test-logger' - apply plugin: 'org.jetbrains.kotlin.jvm' apply plugin: 'net.researchgate.release' group = "org.grobid" @@ -114,6 +100,8 @@ allprojects { subprojects { apply plugin: 'java' apply plugin: 'maven-publish' + apply plugin: 'org.jetbrains.kotlin.jvm' + apply plugin: 'com.adarshr.test-logger' publishing { publications { @@ -127,14 +115,15 @@ subprojects { } } - sourceCompatibility = 1.11 - targetCompatibility = 1.11 + java { + toolchain { + languageVersion = JavaLanguageVersion.of(21) + } + } - tasks.withType(KotlinCompile).configureEach { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { kotlinOptions { - jvmTarget = JavaVersion.VERSION_11 + jvmTarget = "21" } } @@ -149,7 +138,6 @@ subprojects { configurations { all*.exclude group: 'org.slf4j', module: "slf4j-log4j12" all*.exclude group: 'log4j', module: "log4j" - implementation.setCanBeResolved(true) } ext { @@ -173,9 +161,9 @@ subprojects { because("Only needed to run tests in a version of IntelliJ IDEA that bundles older versions") } testImplementation('org.junit.jupiter:junit-jupiter') - testImplementation 'org.easymock:easymock:5.1.0' - testImplementation "org.powermock:powermock-api-easymock:2.0.7" - testImplementation "org.powermock:powermock-module-junit4:2.0.7" + testImplementation 'org.easymock:easymock:5.6.0' + testImplementation "org.powermock:powermock-api-easymock:2.0.9" + testImplementation "org.powermock:powermock-module-junit4:2.0.9" testImplementation "org.xmlunit:xmlunit-matchers:2.10.0" testImplementation "org.xmlunit:xmlunit-legacy:2.10.0" testImplementation "org.hamcrest:hamcrest-all:1.3" @@ -203,7 +191,7 @@ subprojects { tasks.register('sourceJar', Jar) { description = 'A jar that contains source code' archiveClassifier = 'sources' - from project.sourceSets.main.java + from sourceSets.main.allSource } artifacts { @@ -211,7 +199,7 @@ subprojects { archives jar } - test { + tasks.withType(Test) { useJUnitPlatform() testLogging.showStandardStreams = true @@ -223,7 +211,11 @@ subprojects { if (JavaVersion.current().compareTo(JavaVersion.VERSION_1_8) > 0) { jvmArgs "--add-opens", "java.base/java.util.stream=ALL-UNNAMED", - "--add-opens", "java.base/java.io=ALL-UNNAMED", "--add-opens", "java.xml/jdk.xml.internal=ALL-UNNAMED" + "--add-opens", "java.base/java.io=ALL-UNNAMED", + "--add-opens", "java.xml/jdk.xml.internal=ALL-UNNAMED", + // PowerMock compatibility with Java 21 - TODO: Replace PowerMock with Mockito/JUnit Jupiter + "--add-opens", "java.base/java.lang=ALL-UNNAMED", + "--add-opens", "java.base/java.util=ALL-UNNAMED" } systemProperty "java.library.path", "${javaLibraryPath}" @@ -233,7 +225,7 @@ subprojects { /** SUBPROJECTS **/ project("grobid-core") { - apply plugin: 'com.github.johnrengelman.shadow' + apply plugin: 'com.gradleup.shadow' apply plugin: 'jacoco' configurations { @@ -351,9 +343,11 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile project(":grobid-service") { apply plugin: 'application' apply plugin: 'jacoco' - apply plugin: 'com.github.johnrengelman.shadow' + apply plugin: 'com.gradleup.shadow' - mainClassName = 'org.grobid.service.main.GrobidServiceApplication' + application { + mainClass = 'org.grobid.service.main.GrobidServiceApplication' + } tasks.run { @@ -436,7 +430,7 @@ project(":grobid-service") { } project(":grobid-trainer") { - apply plugin: 'com.github.johnrengelman.shadow' + apply plugin: 'com.gradleup.shadow' apply plugin: 'jacoco' dependencies { @@ -541,7 +535,7 @@ project(":grobid-trainer") { trainerTasks.each { taskName, mainClassName -> tasks.create(name: taskName, type: JavaExec, group: 'modeltraining') { - main = mainClassName + mainClass = mainClassName classpath = sourceSets.main.runtimeClasspath def javaLibraryPath = getJavaLibraryPath() if (JavaVersion.current().compareTo(JavaVersion.VERSION_1_8) > 0) { @@ -555,7 +549,7 @@ project(":grobid-trainer") { complexTrainerTasks.each { taskName, mainClassNameAndArgs -> tasks.create(name: taskName, type: JavaExec, group: 'modeltraining') { - main = mainClassNameAndArgs[0] + mainClass = mainClassNameAndArgs[0] classpath = sourceSets.main.runtimeClasspath def javaLibraryPath = getJavaLibraryPath() if (JavaVersion.current().compareTo(JavaVersion.VERSION_1_8) > 0) { @@ -580,7 +574,7 @@ project(":grobid-trainer") { // ./gradlew PrepareDOIMatching -Pp2t=ABS_PATH_TO_PMC/PMC_sample_1943 // ./gradlew EvaluateDOIMatching -Pp2t=ABS_PATH_TO_PMC/PMC_sample_1943 task(jatsEval, dependsOn: 'classes', type: JavaExec, group: 'modelevaluation') { - main = 'org.grobid.trainer.evaluation.EndToEndEvaluation' + mainClass = 'org.grobid.trainer.evaluation.EndToEndEvaluation' classpath = sourceSets.main.runtimeClasspath args 'nlm', getArg('p2t', '.'), getArg('run', '0'), getArg('fileRatio', '1.0'), getArg('flavor', '') def javaLibraryPath = getJavaLibraryPath() @@ -593,7 +587,7 @@ project(":grobid-trainer") { } task(teiEval, dependsOn: 'classes', type: JavaExec, group: 'modelevaluation') { - main = 'org.grobid.trainer.evaluation.EndToEndEvaluation' + mainClass = 'org.grobid.trainer.evaluation.EndToEndEvaluation' classpath = sourceSets.main.runtimeClasspath args 'tei', getArg('p2t', '.'), getArg('run', '0'), getArg('fileRatio', '1.0'), getArg('flavor', '') def javaLibraryPath = getJavaLibraryPath() @@ -607,7 +601,7 @@ project(":grobid-trainer") { } task(PrepareDOIMatching, dependsOn: 'classes', type: JavaExec, group: 'modelevaluation') { - main = 'org.grobid.trainer.evaluation.EvaluationDOIMatching' + mainClass = 'org.grobid.trainer.evaluation.EvaluationDOIMatching' classpath = sourceSets.main.runtimeClasspath args 'data', getArg('p2t', '.') def javaLibraryPath = getJavaLibraryPath() @@ -622,7 +616,7 @@ project(":grobid-trainer") { } task(EvaluateDOIMatching, dependsOn: 'classes', type: JavaExec, group: 'modelevaluation') { - main = 'org.grobid.trainer.evaluation.EvaluationDOIMatching' + mainClass = 'org.grobid.trainer.evaluation.EvaluationDOIMatching' classpath = sourceSets.main.runtimeClasspath args 'eval', getArg('p2t', '.') @@ -662,16 +656,16 @@ tasks.register("codeCoverageReport", JacocoReport) { // XML -> coveralls, // HTML -> for manual check reports { - xml.enabled true - html.enabled true - csv.enabled true + xml.required = true + html.required = true + csv.required = true } } /** COVERALLS **/ coveralls { - sourceDirs = files(subprojects.sourceSets.main.allSource.srcDirs).files.absolutePath + sourceDirs = files(subprojects.findAll { it.plugins.hasPlugin('java') }.sourceSets.main.allSource.srcDirs).files.absolutePath } tasks.coveralls { @@ -679,7 +673,7 @@ tasks.coveralls { } wrapper { - gradleVersion "7.2" + gradleVersion "9.0.0" } build.dependsOn project.getSubprojects().collect({ it.getTasks().getByName("build") }) @@ -691,4 +685,4 @@ release { git { requireBranch.set('master') } -} \ No newline at end of file +} diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 7454180f2a..1b33c55baa 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ffed3a254e..2a84e188b8 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.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists