From a2aff2ff07efec9c80c5a5bade5ab603cafe70fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-R=C3=A9my=20Falleri?= Date: Wed, 13 Nov 2024 14:41:41 +0100 Subject: [PATCH] feat: update build to be compatible with gradle 9. --- .github/workflows/build-test-gumtree.yml | 14 -------- build.gradle | 43 ++++-------------------- core/build.gradle | 28 ++++++--------- dist-native/build.gradle | 14 +++++--- dist/build.gradle | 14 +++++--- 5 files changed, 36 insertions(+), 77 deletions(-) diff --git a/.github/workflows/build-test-gumtree.yml b/.github/workflows/build-test-gumtree.yml index e177bdc59..3b5d5cf84 100644 --- a/.github/workflows/build-test-gumtree.yml +++ b/.github/workflows/build-test-gumtree.yml @@ -40,20 +40,6 @@ jobs: with: name: benchmark-report path: benchmark/build/reports/analysis.html - - name: generate jacoco report - run: ./gradlew jacocoRootReport - - name: upload coverage report - uses: actions/upload-artifact@v4 - with: - name: coverage-report - path: build/reports/jacoco/jacocoRootReport/html/ - - name: generate test report - run: ./gradlew testReport - - name: upload test report - uses: actions/upload-artifact@v4 - with: - name: test-report - path: build/reports/tests - name: upload snapshot package env: ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPEUSERNAME }} diff --git a/build.gradle b/build.gradle index 46d5c5186..88093dfc4 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'jacoco' - id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' + id 'io.github.gradle-nexus.publish-plugin' version '2.0.0' } nexusPublishing { @@ -25,8 +25,11 @@ allprojects { subprojects { apply plugin: 'java' - sourceCompatibility = '17' - targetCompatibility = '17' + + java { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } compileJava { options.compilerArgs << '-Xlint:deprecation' @@ -112,40 +115,6 @@ configure(subprojects.findAll { it.name.startsWith('gen.antlr4') }) { } } -def jacocoProjectsNames = ['core', 'gen.jdt', 'gen.c', 'gen.ruby', 'gen.js', 'gen.srcml', 'gen.css'] -def jacocoProjects = subprojects.findAll { it.name in jacocoProjectsNames } -configure(jacocoProjects) { - apply plugin: 'jacoco' - - jacocoTestReport { - reports { - html.required = true - xml.required = true - csv.required = false - } - } -} - -task testReport(type: TestReport) { - destinationDirectory.set(file("$layout.buildDirectory/reports/tests")) - reportOn subprojects*.test -} - -task jacocoRootReport(type: JacocoReport, group: 'Coverage reports') { - description = 'Generates an aggregate report from all subprojects' - dependsOn(jacocoProjects.test) - - getAdditionalSourceDirs().from = files(jacocoProjects.sourceSets.main.allSource.srcDirs) - getSourceDirectories().from = files(jacocoProjects.sourceSets.main.allSource.srcDirs) - getClassDirectories().from = files(jacocoProjects.sourceSets.main.output) - getExecutionData().from = files(jacocoProjects.jacocoTestReport.executionData) - - reports { - html.required = true - xml.required = true - } -} - def projectDescriptions = [ 'client': 'GumTree abstract client module.', 'client.diff': 'GumTree diff client.', diff --git a/core/build.gradle b/core/build.gradle index 2dd5e9cb7..e6c4f6715 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'info.solidsoft.pitest' version '1.7.0' + id 'jacoco' } description = 'GumTree core module.' @@ -11,23 +11,15 @@ dependencies { implementation 'org.jgrapht:jgrapht-core:1.5.1' } -pitest { - targetClasses = ['com.github.gumtreediff.*'] - targetTests = ['com.github.gumtreediff.test.TestTree', - 'com.github.gumtreediff.test.TestMetadata', - 'com.github.gumtreediff.test.TestTreeUtils', - 'com.github.gumtreediff.test.TestMappingStore', - 'com.github.gumtreediff.test.TestTreeClassifier'] - threads = 4 - outputFormats = ['XML', 'HTML'] - timestampedReports = false - junit5PluginVersion = '0.15' +test { + finalizedBy jacocoTestReport } -allprojects { - gradle.projectsEvaluated { - tasks.withType(JavaCompile) { - options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" - } +jacocoTestReport { + dependsOn test + reports { + html.required = true + xml.required = false + csv.required = false } -} +} \ No newline at end of file diff --git a/dist-native/build.gradle b/dist-native/build.gradle index 03c10f11f..3b32a6b52 100644 --- a/dist-native/build.gradle +++ b/dist-native/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.github.johnrengelman.shadow' version "8.1.1" + id 'com.gradleup.shadow' version '8.3.5' id 'application' } @@ -31,9 +31,15 @@ distributions { } } -mainClassName = 'com.github.gumtreediff.client.Run' -applicationName = 'gumtree' -archivesBaseName = 'gumtree' +application { + mainClass = 'com.github.gumtreediff.client.Run' + applicationName = 'gumtree' +} + +tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + archiveBaseName.set('gumtree') +} + shadowDistZip.enabled = true distTar.enabled = false distZip.enabled = false diff --git a/dist/build.gradle b/dist/build.gradle index 54d06dcee..42a107f97 100644 --- a/dist/build.gradle +++ b/dist/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'com.github.johnrengelman.shadow' version "8.1.1" + id 'com.gradleup.shadow' version '8.3.5' id 'application' } @@ -45,9 +45,15 @@ distributions { } } -mainClassName = 'com.github.gumtreediff.client.Run' -applicationName = 'gumtree' -archivesBaseName = 'gumtree' +application { + mainClass = 'com.github.gumtreediff.client.Run' + applicationName = 'gumtree' +} + +tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + archiveBaseName.set('gumtree') +} + shadowDistZip.enabled = true distTar.enabled = false distZip.enabled = false