Skip to content

Commit 55486c9

Browse files
committed
Add Java 25 and Gradle 9.x build compatibility
- Update Gradle wrapper to 9.1.0 for Java 25 class file version (69) support - Update asciidoctor plugin to 4.0.2 for Gradle 9.x compatibility - Add XmlParser import to idea.gradle for Groovy 4.x package relocation - Add maven-publish based publishing (upload-publish.gradle) for Gradle 9.x - Fix sourceJar task dependency on grammar generation - Disable deprecated plugins incompatible with Gradle 9.x
1 parent 34e9abe commit 55486c9

File tree

38 files changed

+1130
-275
lines changed

38 files changed

+1130
-275
lines changed

build.gradle

Lines changed: 62 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -34,46 +34,57 @@ buildscript {
3434

3535
dependencies {
3636
// using the old "classpath" style of plugins because the new one doesn't play well with multi-modules
37-
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.8'
38-
classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3'
37+
// Updated asciidoctor plugin for Gradle 9.x compatibility (backported from GROOVY_4_0_X)
38+
classpath 'org.asciidoctor:asciidoctor-gradle-jvm:4.0.2'
39+
// classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:6.0.4'
3940
//classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
4041
classpath 'org.nosphere.apache:creadur-rat-gradle:0.8.1'
41-
classpath 'gradle.plugin.com.github.jk1:gradle-license-report:1.3'
42+
// classpath 'gradle.plugin.com.github.jk1:gradle-license-report:1.3'
4243
}
4344
}
4445

4546
plugins {
46-
id 'me.champeau.buildscan-recipes' version '0.2.3'
47-
id 'com.github.spotbugs' version '4.6.0'
48-
id 'com.github.ben-manes.versions' version '0.42.0' // 0.43 requires gradle 7+
49-
id 'com.github.blindpirate.osgi' version '0.0.6'
50-
id 'org.sonarqube' version '3.0'
47+
// Disabled for Gradle 9.x compatibility - buildscan-recipes uses deprecated APIs
48+
// id 'me.champeau.buildscan-recipes' version '0.2.3'
49+
id 'com.github.spotbugs' version '6.4.2'
50+
id 'com.github.ben-manes.versions' version '0.51.0'
51+
id 'io.github.goooler.osgi' version '0.8.6'
52+
id 'org.sonarqube' version '6.0.1.5171'
5153
}
5254

53-
buildScanRecipes {
54-
recipe 'git-commit', baseUrl: 'https://github.com/apache/groovy/tree'
55-
recipe 'teamcity', baseUrl: 'https://ci.groovy-lang.org', guest: 'true'
56-
recipes 'git-status', 'gc-stats', 'teamcity', 'travis-ci'
57-
}
55+
// Disabled for Gradle 9.x compatibility
56+
// buildScanRecipes {
57+
// recipe 'git-commit', baseUrl: 'https://github.com/apache/groovy/tree'
58+
// recipe 'teamcity', baseUrl: 'https://ci.groovy-lang.org', guest: 'true'
59+
// recipes 'git-status', 'gc-stats', 'teamcity', 'travis-ci'
60+
// }
5861

5962
ext.modules = {
6063
subprojects.findAll{ !['performance', 'binary-compatibility'].contains(it.name) }
6164
}
6265
ext.isReleaseVersion = !groovyVersion.toLowerCase().endsWith('snapshot')
6366

6467
apply from: 'gradle/bad-practices.gradle'
65-
apply from: 'gradle/publish.gradle'
66-
apply plugin: 'com.github.jk1.dependency-license-report'
68+
// TODO: Fix publish.gradle for Gradle 9.x compatibility - artifactory plugin API changed
69+
// apply from: 'gradle/publish.gradle'
70+
// Disabled for Gradle 9.x - jk1 plugin uses deprecated APIs
71+
// apply plugin: 'com.github.jk1.dependency-license-report'
6772

6873
File javaHome = new File(System.getProperty('java.home'))
6974
logger.lifecycle "Using Java from $javaHome (version ${System.getProperty('java.version')})"
7075

7176
allprojects {
7277
apply plugin: 'java-library'
7378

74-
buildDir = 'target'
75-
sourceCompatibility = 1.8
76-
targetCompatibility = 1.8
79+
layout.buildDirectory = file('target')
80+
java {
81+
sourceCompatibility = JavaVersion.VERSION_1_8
82+
targetCompatibility = JavaVersion.VERSION_1_8
83+
}
84+
85+
// Stub for provided() method (normally from pomconfigurer.gradle via upload.gradle)
86+
ext.providedDeps = []
87+
ext.provided = { ext.providedDeps << it }
7788

7889
group = 'org.codehaus.groovy'
7990
version = groovyVersion
@@ -98,9 +109,9 @@ allprojects {
98109

99110
apply plugin: 'groovy'
100111
apply from: "${rootProject.projectDir}/gradle/indy.gradle"
112+
// Updated for asciidoctor-gradle-jvm 4.x (backported from GROOVY_4_0_X)
101113
apply from: "${rootProject.projectDir}/gradle/asciidoctor.gradle"
102-
103-
tasks.withType(org.asciidoctor.gradle.AsciidoctorTask) {
114+
tasks.withType(org.asciidoctor.gradle.jvm.AsciidoctorTask) {
104115
outputs.cacheIf { true }
105116
}
106117
}
@@ -129,7 +140,7 @@ configurations {
129140

130141
ext {
131142
antVersion = '1.10.15'
132-
asmVersion = '9.8'
143+
asmVersion = '9.9'
133144
antlrVersion = '2.7.7'
134145
antlr4Version = '4.9.0'
135146
bridgerVersion = '1.6.Final'
@@ -267,15 +278,16 @@ sourceSets {
267278
}
268279

269280
task sourceJar(type: Jar) {
270-
classifier = 'sources'
281+
dependsOn 'ensureGrammars', 'generateGrammarSource'
282+
archiveClassifier = 'sources'
271283
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
272284
from sourceSets.main.allSource
273285
from sourceSets.antlr2.allSource
274286
}
275287

276288
subprojects {
277289
task sourceJar(type: Jar) {
278-
classifier = 'sources'
290+
archiveClassifier = 'sources'
279291
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
280292
from sourceSets.main.allSource
281293
}
@@ -314,14 +326,16 @@ task ensureGrammars {
314326

315327
compileJava {
316328
dependsOn ensureGrammars, generateGrammarSource
317-
options.fork(memoryMaximumSize: javacMain_mx)
329+
options.fork = true
330+
options.forkOptions.memoryMaximumSize = javacMain_mx
318331

319332
doLast {
333+
def javaOutputDir = compileJava.destinationDirectory.get().asFile.canonicalPath
320334
ant.java(classname:'org.jboss.bridger.Bridger', classpath: rootProject.configurations.tools.asPath, outputproperty: 'stdout') {
321-
arg(value: "${sourceSets.main.java.outputDir.canonicalPath}/org/codehaus/groovy/runtime/DefaultGroovyMethods.class")
322-
arg(value: "${sourceSets.main.java.outputDir.canonicalPath}/org/codehaus/groovy/runtime/StringGroovyMethods.class")
323-
arg(value: "${sourceSets.main.java.outputDir.canonicalPath}/org/codehaus/groovy/classgen/Verifier.class")
324-
arg(value: "${sourceSets.main.java.outputDir.canonicalPath}/org/codehaus/groovy/ast/tools/GeneralUtils.class")
335+
arg(value: "${javaOutputDir}/org/codehaus/groovy/runtime/DefaultGroovyMethods.class")
336+
arg(value: "${javaOutputDir}/org/codehaus/groovy/runtime/StringGroovyMethods.class")
337+
arg(value: "${javaOutputDir}/org/codehaus/groovy/classgen/Verifier.class")
338+
arg(value: "${javaOutputDir}/org/codehaus/groovy/ast/tools/GeneralUtils.class")
325339
}
326340
ant.echo('Bridger (groovy): ' + ant.properties.stdout)
327341
}
@@ -356,12 +370,12 @@ task dgmConverter(dependsOn:compileJava) {
356370
task bootstrapJar(type: Jar) {
357371
dependsOn compileJava, dgmConverter
358372

359-
from compileJava.destinationDir
373+
from compileJava.destinationDirectory
360374
from dgmConverter.outputDir
361375

362376
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
363-
destinationDir = file("$buildDir/bootstrap")
364-
classifier = 'bootstrap'
377+
destinationDirectory = file("$buildDir/bootstrap")
378+
archiveClassifier = 'bootstrap'
365379
}
366380

367381
allprojects {
@@ -387,16 +401,17 @@ allprojects {
387401
task compileGroovyWithIndy(type: GroovyCompile) {
388402
source = sourceSets.main.groovy
389403
classpath = compileGroovy.classpath
390-
sourceCompatibility = 1.8
391-
targetCompatibility = 1.8
404+
sourceCompatibility = JavaVersion.VERSION_1_8
405+
targetCompatibility = JavaVersion.VERSION_1_8
392406
groovyOptions.optimizationOptions['indy'] = true
393-
destinationDir = file("$buildDir/classes/indy")
407+
destinationDirectory = file("$buildDir/classes/indy")
394408
}
395409
}
396410

397411
tasks.withType(GroovyCompile) {
398412
groovyOptions.forkOptions.jvmArgs += ['-Dgroovy.antlr4.cache.threshold=100']
399-
groovyOptions.fork(memoryMaximumSize: groovycMain_mx)
413+
groovyOptions.fork = true
414+
groovyOptions.forkOptions.memoryMaximumSize = groovycMain_mx
400415
groovyOptions.encoding = 'UTF-8'
401416
//options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation'
402417
groovyClasspath = files(
@@ -412,7 +427,8 @@ allprojects {
412427
}
413428

414429
compileTestGroovy {
415-
groovyOptions.fork(memoryMaximumSize: groovycTest_mx)
430+
groovyOptions.fork = true
431+
groovyOptions.forkOptions.memoryMaximumSize = groovycTest_mx
416432
}
417433

418434
task checkCompatibility {
@@ -438,7 +454,9 @@ apply from: 'gradle/test.gradle'
438454
apply from: 'gradle/groovydoc.gradle'
439455
apply from: 'gradle/docs.gradle'
440456
apply from: 'gradle/assemble.gradle'
441-
apply from: 'gradle/upload.gradle'
457+
// Legacy upload.gradle (uses deprecated maven plugin) - replaced by upload-publish.gradle
458+
// apply from: 'gradle/upload.gradle'
459+
apply from: 'gradle/upload-publish.gradle'
442460
apply from: 'gradle/idea.gradle'
443461
apply from: 'gradle/eclipse.gradle'
444462
apply from: 'gradle/quality.gradle'
@@ -451,12 +469,13 @@ if (file('user.gradle').exists()) {
451469

452470
apply from: 'gradle/signing.gradle'
453471

454-
licenseReport {
455-
excludeGroups = [
456-
'com.googlecode', // openbeans has no pom but is ASLv2
457-
'org.multiverse' // we never include this optional dependency of an optional dependency
458-
]
459-
}
472+
// Disabled - plugin not loaded
473+
// licenseReport {
474+
// excludeGroups = [
475+
// 'com.googlecode', // openbeans has no pom but is ASLv2
476+
// 'org.multiverse' // we never include this optional dependency of an optional dependency
477+
// ]
478+
// }
460479

461480
// UNCOMMENT THE FOLLOWING TASKS IF YOU WANT TO RUN LICENSE CHECKING
462481
//task licenseFormatCustom(type:nl.javadude.gradle.plugins.license.License) {

buildSrc/src/main/groovy/org/codehaus/groovy/gradle/JarJarTask.groovy

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.gradle.api.DefaultTask
2424
import org.gradle.api.file.FileCollection
2525
import org.gradle.api.java.archives.Manifest
2626
import org.gradle.api.tasks.CacheableTask
27+
import org.gradle.api.tasks.Classpath
2728
import org.gradle.api.tasks.Input
2829
import org.gradle.api.tasks.InputFile
2930
import org.gradle.api.tasks.InputFiles
@@ -41,15 +42,18 @@ class JarJarTask extends DefaultTask {
4142
private List<Action<? super Manifest>> manifestTweaks = []
4243

4344
@InputFile
45+
@Classpath
4446
File from
4547

4648
@InputFiles
49+
@Classpath
4750
FileCollection repackagedLibraries
4851

4952
@InputFiles
53+
@Classpath
5054
FileCollection jarjarToolClasspath
5155

52-
@InputFiles
56+
@Input
5357
@org.gradle.api.tasks.Optional
5458
List<String> untouchedFiles = []
5559

@@ -94,12 +98,15 @@ class JarJarTask extends DefaultTask {
9498
def tmpJar = new File(temporaryDir, "${outputFile.name}.${Integer.toHexString(UUID.randomUUID().hashCode())}.tmp")
9599
def manifestFile = new File(temporaryDir, 'MANIFEST.MF')
96100

101+
// Use fixed date/timestamp for reproducible builds (backported from GROOVY_4_0_X)
102+
String tstamp = Date.parse('yyyy-MM-dd HH:mm', '1980-02-01 00:00').getTime().toString()
103+
97104
// First step is to create a repackaged jar
98105
outputFile.parentFile.mkdirs()
99106
try {
100107
project.ant {
101108
taskdef name: 'jarjar', classname: JARJAR_CLASS_NAME, classpath: jarjarToolClasspath.asPath
102-
jarjar(jarfile: tmpJar, filesonly: true) {
109+
jarjar(jarfile: tmpJar, filesonly: true, modificationtime: tstamp) {
103110
zipfileset(
104111
src: originalJar,
105112
excludes: (untouchedFiles + excludes).join(','))
@@ -128,7 +135,7 @@ class JarJarTask extends DefaultTask {
128135

129136
if (createManifest) {
130137
// next step is to generate an OSGI manifest using the newly repackaged classes
131-
def mf = project.rootProject.convention.plugins.osgi.osgiManifest {
138+
def mf = project.rootProject.extensions.osgi.osgiManifest {
132139
symbolicName = project.name
133140
instruction 'Import-Package', '*;resolution:=optional'
134141
classesDir = tmpJar
@@ -147,7 +154,7 @@ class JarJarTask extends DefaultTask {
147154

148155
// so that we can put it into the final jar
149156
project.ant.copy(file: tmpJar, tofile: outputFile)
150-
project.ant.jar(destfile: outputFile, update: true, index: true, manifest: manifestFile) {
157+
project.ant.jar(destfile: outputFile, update: true, index: true, modificationtime: tstamp, manifest: manifestFile) {
151158
manifest {
152159
// because we don't want to use JDK 1.8.0_91, we don't care and it will
153160
// introduce cache misses

0 commit comments

Comments
 (0)