From 3e0f0f8dc8b56fd91b24d03636c49a800d56b87e Mon Sep 17 00:00:00 2001 From: Bert Massop Date: Sun, 29 Jun 2025 17:31:07 +0200 Subject: [PATCH] Show Fred version from Gradle script The workflow used to rely on Fred's freenet.node.Version having a main(...) method that prints the version information. That method has been removed, breaking this build. Compile a version string in Gradle by invoking the related methods on the Version class. --- .github/workflows/gradle.yml | 2 -- build.gradle | 13 +++++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 2d20cbb58..66b1dd7d3 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -177,8 +177,6 @@ jobs: # TODO: Also print the checksums of other dependency JARs which Gradle has obtained from the # Internet or the local system. echo 'Checksums of fred JARs:' ; sha256sum ../fred/build/output/* - echo 'fred version:' - java -classpath '../fred/build/output/freenet.jar' 'freenet.node.Version' if [ "${{matrix.WoT-builder}}" = "ant" ] ; then ant clean && ant elif [ "${{matrix.WoT-builder}}" = "gradle" ] ; then diff --git a/build.gradle b/build.gradle index d6a301113..806ab7e07 100644 --- a/build.gradle +++ b/build.gradle @@ -36,8 +36,21 @@ task compileDb4o(type: Exec) { "-Djavac.target.version=" + targetCompatibility } +task showFredVersion { + doLast { + URL[] classpath = sourceSets.main.runtimeClasspath.files.collect { it.toURL() } as URL[] + def cl = new URLClassLoader(classpath) + def cls = Class.forName("freenet.node.Version", true, cl) + def publicVersion = cls.getMethod("publicVersion").invoke(null) + def buildNumber = cls.getMethod("buildNumber").invoke(null) + def cvsRevision = cls.getMethod("cvsRevision").invoke(null) + println("Using Fred version " + publicVersion + " build #" + buildNumber + " (" + cvsRevision + ")") + } +} + compileJava { dependsOn 'compileDb4o' + dependsOn 'showFredVersion' } task prepareVersionFile(type: Copy) {