From db0a08c9d5595956ee49610d66a9a2f6efc97d8f Mon Sep 17 00:00:00 2001 From: sebthom Date: Sun, 26 Oct 2025 15:40:50 +0100 Subject: [PATCH] build: upgrade to Gradle 8.14.3, Bnd Gradle Plugins 7.1.0, Gradle JDK 21 - Use JDK 21 to run Gradle - Fix all Gradle deprecation warnings, e.g. "Invocation of Task.project at execution time has been deprecated." --- .github/workflows/validate.yml | 2 +- build.gradle | 10 +++---- gradle/java-compiler-settings.gradle | 33 +++++++++++++--------- gradle/manifest-gen.gradle | 36 ++++++++++++++++++++---- gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 56 insertions(+), 27 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index d2211f125..9415225e7 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -65,7 +65,7 @@ jobs: cache: gradle - name: Build with Gradle 🏗️ - run: ./gradlew build testOlderJavas + run: ./gradlew build testOlderJavas --warning-mode=all - name: Upload Test Results if: always() diff --git a/build.gradle b/build.gradle index 412ce914b..58e641466 100644 --- a/build.gradle +++ b/build.gradle @@ -17,12 +17,12 @@ buildscript { repositories { mavenCentral() maven { - url "https://plugins.gradle.org/m2/" + url = "https://plugins.gradle.org/m2/" } } dependencies { - classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:6.4.0" - classpath "org.xtext:xtext-gradle-plugin:4.0.0" + classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:7.1.0" // https://github.com/bndtools/bnd/releases + classpath "org.xtext:xtext-gradle-plugin:4.0.0" // https://github.com/xtext/xtext-gradle-plugin/releases } } @@ -175,7 +175,7 @@ subprojects { } task clean(type: Delete) { - group 'Build' - description 'Deletes the local repositories' + group = 'Build' + description = 'Deletes the local repositories' delete 'build' } diff --git a/gradle/java-compiler-settings.gradle b/gradle/java-compiler-settings.gradle index b74710586..aa51c0870 100644 --- a/gradle/java-compiler-settings.gradle +++ b/gradle/java-compiler-settings.gradle @@ -50,28 +50,28 @@ tasks.withType(JavaCompile) { } task sourcesJar(type: Jar, dependsOn: classes) { - group 'Build' - description 'Assembles a jar archive containing the sources.' + group = 'Build' + description = 'Assembles a jar archive containing the sources.' archiveClassifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: javadoc) { - group 'Build' - description 'Assembles a jar archive containing the JavaDoc output.' + group = 'Build' + description = 'Assembles a jar archive containing the JavaDoc output.' archiveClassifier = 'javadoc' from javadoc.destinationDir } -ext.signMethod = { jarfile -> +ext.signMethod = { jarfile -> println "Signing $jarfile" def SIGNING_SERVICE = 'https://cbi.eclipse.org/jarsigner/sign' def STDOUT_FORMAT = ' %{size_upload} bytes uploaded, %{size_download} bytes downloaded (%{time_total} s)\\n' - ProcessBuilder curl_pb = new ProcessBuilder("curl", + ProcessBuilder curl_pb = new ProcessBuilder("curl", "--fail", "--silent", "--show-error", "--output", "${jarfile}-signed", "--form", "file=@${jarfile}", - "--write-out", STDOUT_FORMAT, + "--write-out", STDOUT_FORMAT, SIGNING_SERVICE); println String.join(" ", curl_pb.command()); curl_pb.directory(new File("${project.buildDir}")); @@ -82,10 +82,10 @@ ext.signMethod = { jarfile -> println curl_process.text if (curl_process.exitValue() != 0) { - throw new GradleException("Failed to run curl"); + throw new GradleException("Failed to run curl"); } - ProcessBuilder mv_pb = new ProcessBuilder("mv", + ProcessBuilder mv_pb = new ProcessBuilder("mv", "${jarfile}-signed", jarfile) println String.join(" ", mv_pb.command()); mv_pb.directory(new File("${project.buildDir}")); @@ -93,15 +93,20 @@ ext.signMethod = { jarfile -> mv_process.waitFor() if (curl_process.exitValue() != 0) { - throw new GradleException("Failed to run mv"); + throw new GradleException("Failed to run mv"); } } task signJar(description: 'Sign JARs with Eclipse Signing Service', group: 'Build'){ - doLast { - signMethod("${project.buildDir}/libs/${project.name}-${project.version}.jar") - signMethod("${project.buildDir}/libs/${project.name}-${project.version}-sources.jar") - signMethod("${project.buildDir}/libs/${project.name}-${project.version}-javadoc.jar") + def projectBase = "${project.buildDir}/libs/${project.name}-${project.version}" + + // Declare inputs/outputs for config-cache friendliness + inputs.property('projectBase', projectBase) + + doLast { + signMethod("${projectBase}.jar") + signMethod("${projectBase}-sources.jar") + signMethod("${projectBase}-javadoc.jar") } } signJar.dependsOn jar, sourcesJar, javadocJar diff --git a/gradle/manifest-gen.gradle b/gradle/manifest-gen.gradle index 6e2ff592e..9ebebed6a 100644 --- a/gradle/manifest-gen.gradle +++ b/gradle/manifest-gen.gradle @@ -1,12 +1,12 @@ /****************************************************************************** * Copyright (c) 2016 TypeFox and others. - * + * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License v. 2.0 which is available at * http://www.eclipse.org/legal/epl-2.0, * or the Eclipse Distribution License v. 1.0 which is available at * http://www.eclipse.org/org/documents/edl-v10.php. - * + * * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause ******************************************************************************/ apply plugin: "biz.aQute.bnd.builder" @@ -26,27 +26,51 @@ jar.bundle.bnd ( "-savemanifest": "build/tmp/bnd/MANIFEST.MF", ) +// Workaround for Gradle 8 deprecation: avoid Bnd accessing Task.project at execution time +// by supplying needed Gradle Project properties via Providers to the Bnd builder. +// See: https://github.com/bndtools/bnd/issues/6346#issuecomment-2450176628 +tasks.named('jar') { + // The bnd plugin contributes a 'bundle { }' configuration on Jar tasks + bundle { + properties.put('project.group', providers.provider { project.group?.toString() ?: '' }) + properties.put('project.name', providers.provider { project.name }) + properties.put('project.version', providers.provider { project.version?.toString() ?: '' }) + properties.put('project.path', providers.provider { project.path }) + properties.put('projectDir', providers.provider { project.projectDir?.absolutePath ?: '' }) + properties.put('rootDir', providers.provider { project.rootDir?.absolutePath ?: '' }) + properties.put('buildDir', providers.provider { project.buildDir?.absolutePath ?: '' }) + } +} + //------------------------------------------------------ // Generate a manifest for the source bundle def sourcesManifestFile = "$buildDir/tmp/sourcesJar/MANIFEST.MF" task genSourcesManifest { + def projectName = project.name + def projectTitle = project.findProperty('title') ?: '' + + // Declare inputs/outputs for config-cache friendliness + inputs.property('projectName', projectName) + inputs.property('projectTitle', projectTitle) + inputs.property('qualifiedVersion', qualifiedVersion) outputs.file(sourcesManifestFile) + doLast { def f = new File(sourcesManifestFile) f.parentFile.mkdirs() def writer = new PrintWriter(f) writer.println("Manifest-Version: 1.0") writer.println("Bundle-ManifestVersion: 2") - writer.println("Bundle-SymbolicName: ${project.name}.source") + writer.println("Bundle-SymbolicName: ${projectName}.source") writer.println("Bundle-Version: ${qualifiedVersion}") - if (project.hasProperty('title')) - writer.println("Bundle-Name: ${project.title} Sources") + if (projectTitle) + writer.println("Bundle-Name: ${projectTitle} Sources") else writer.println("Bundle-Name: Sources") writer.println("Bundle-Vendor: Eclipse LSP4J") - writer.println("Eclipse-SourceBundle: ${project.name};version=\"${qualifiedVersion}\"") + writer.println("Eclipse-SourceBundle: ${projectName};version=\"${qualifiedVersion}\"") writer.close() } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index a80b22ce5..d4081da47 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME