You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2022/03/03 21:55:19 UTC

[groovy] 01/01: Gradle 7.2 for Java 16+

This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch groovy3-java16
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit b8c403d21b7df013c05f175f44472e49aea75805
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Thu Mar 3 15:54:58 2022 -0600

    Gradle 7.2 for Java 16+
---
 build.gradle                                       | 37 ++++-----
 .../groovy/gradle/ReleaseInfoGenerator.groovy      |  3 +-
 .../gradle/WriteExtensionDescriptorTask.groovy     |  4 +-
 gradle.properties                                  | 96 +++++++++++-----------
 gradle/assemble.gradle                             |  2 +
 gradle/test.gradle                                 |  6 +-
 gradle/wrapper/gradle-wrapper.properties           |  2 +-
 .../groovy/reflection/ReflectionUtils.java         | 20 +++--
 .../groovy/runtime/ProxyGeneratorAdapter.java      | 18 ++--
 subprojects/groovy-json/build.gradle               |  6 +-
 subprojects/groovy-servlet/build.gradle            | 17 ++--
 subprojects/groovy-test-junit5/build.gradle        |  6 +-
 subprojects/groovy-test/build.gradle               | 12 +--
 subprojects/groovy-testng/build.gradle             |  6 +-
 subprojects/groovy-yaml/build.gradle               |  4 +-
 15 files changed, 122 insertions(+), 117 deletions(-)

diff --git a/build.gradle b/build.gradle
index 20d6de6..7b4b796 100644
--- a/build.gradle
+++ b/build.gradle
@@ -26,21 +26,16 @@ buildscript {
         }
         mavenCentral()
         maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
-        maven {
-            url "https://plugins.gradle.org/m2/"
-        }
-        maven {
-            url 'https://jitpack.io'
-        }
+        maven { url 'https://plugins.gradle.org/m2/' }
+        maven { url 'https://jitpack.io' }
     }
 
     dependencies {
         // using the old "classpath" style of plugins because the new one doesn't play well with multi-modules
         classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.8'
-        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3"
-        //classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.11.0'
-        classpath "org.nosphere.apache:creadur-rat-gradle:0.7.0"
-        classpath "gradle.plugin.com.github.jk1:gradle-license-report:1.3"
+        classpath 'org.jfrog.buildinfo:build-info-extractor-gradle:3.0.3'
+        classpath 'org.nosphere.apache:creadur-rat-gradle:0.7.0'
+        classpath 'gradle.plugin.com.github.jk1:gradle-license-report:1.3'
     }
 }
 
@@ -61,12 +56,11 @@ buildScanRecipes {
 ext.modules = {
     subprojects.findAll{ !['performance', 'binary-compatibility'].contains(it.name) }
 }
-ext.isReleaseVersion = !groovyVersion.toLowerCase().endsWith("snapshot")
+ext.isReleaseVersion = !groovyVersion.toLowerCase().endsWith('snapshot')
 
 apply from: 'gradle/bad-practices.gradle'
-//apply from: 'gradle/indy.gradle'
 apply from: 'gradle/publish.gradle'
-apply plugin: "com.github.jk1.dependency-license-report"
+apply plugin: 'com.github.jk1.dependency-license-report'
 
 File javaHome = new File(System.getProperty('java.home'))
 logger.lifecycle "Using Java from $javaHome (version ${System.getProperty('java.version')})"
@@ -115,7 +109,7 @@ task(copyTestResources, type: Copy)
 test.dependsOn(copyTestResources)
 
 repositories {
-    // todo Some repos are needed only for some configs. Declare them just for the configuration once Gradle allows this.
+    // TODO: Some repos are needed only for some configs. Declare them just for the configuration once Gradle allows this.
     maven { url 'https://repository.jboss.org/nexus/content/groups/m2-release-proxy' } // tools
 }
 
@@ -351,12 +345,13 @@ task dgmConverter(dependsOn:compileJava) {
     // Gradle classloading magic with Groovy will only work if it finds a *jar*
     // on classpath. This "bootstrap jar" contains the minimal compiler, without .groovy compiled files
 
-task bootstrapJar(type:Jar ) {
+task bootstrapJar(type: Jar) {
     dependsOn compileJava, dgmConverter
 
     from compileJava.destinationDir
     from dgmConverter.outputDir
 
+    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
     destinationDir = file("$buildDir/bootstrap")
     classifier = 'bootstrap'
 }
@@ -366,6 +361,10 @@ allprojects {
         compileOnly "com.github.spotbugs:spotbugs-annotations:$spotbugsAnnotationsVersion"
     }
 
+    tasks.withType(AbstractCopyTask) {
+        duplicatesStrategy = DuplicatesStrategy.WARN
+    }
+
     tasks.withType(JavaCompile) {
         options.encoding = 'UTF-8'
         options.incremental = true
@@ -431,7 +430,7 @@ apply from: 'gradle/test.gradle'
 apply from: 'gradle/groovydoc.gradle'
 apply from: 'gradle/docs.gradle'
 apply from: 'gradle/assemble.gradle'
-apply from: 'gradle/upload.gradle'
+//apply from: 'gradle/upload.gradle' -- TODO: migrate to Gradle 7
 apply from: 'gradle/idea.gradle'
 apply from: 'gradle/eclipse.gradle'
 apply from: 'gradle/quality.gradle'
@@ -467,8 +466,8 @@ licenseReport {
 def checkRepo(repo) {
     if (repo instanceof MavenArtifactRepository) {
         def repoUrl = repo.url.toString()
-        if (repoUrl.startsWith("http://")) {
-            throw new GradleException("Build should not use insecure HTTP-based URLs for repositories. Found: " + repoUrl)
+        if (repoUrl.startsWith('http://')) {
+            throw new GradleException("Build should not use insecure HTTP-based URLs for repositories. Found: $repoUrl")
         }
     }
 }
@@ -484,7 +483,7 @@ project.afterEvaluate {
 
 def UNSTABLE = /^([\d.-]+(alpha|beta|rc|ea|b|m)[\d.-]+(groovy[\d.-]+)?|2.4.0-b[\d.]+|200\d{5}(\.\d{6})?|2004-03-19)$/
 // ignore non-stable releases
-tasks.named("dependencyUpdates")?.configure {
+tasks.named('dependencyUpdates')?.configure {
     gradleReleaseChannel = 'current'
     rejectVersionIf {
         !(it.currentVersion.toLowerCase() ==~ UNSTABLE) && it.candidate.version.toLowerCase() ==~ UNSTABLE
diff --git a/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/ReleaseInfoGenerator.groovy b/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/ReleaseInfoGenerator.groovy
index b29193c..d0c357c 100644
--- a/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/ReleaseInfoGenerator.groovy
+++ b/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/ReleaseInfoGenerator.groovy
@@ -28,7 +28,8 @@ import java.text.SimpleDateFormat
 
 @CompileStatic
 class ReleaseInfoGenerator extends DefaultTask {
-    String description = "Generates the release info properties file"
+    @Input
+    String description = 'Generates the release info properties file'
 
     @Input
     String version
diff --git a/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/WriteExtensionDescriptorTask.groovy b/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/WriteExtensionDescriptorTask.groovy
index 2e16102..e604c4c 100644
--- a/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/WriteExtensionDescriptorTask.groovy
+++ b/buildSrc/src/main/groovy/org/codehaus/groovy/gradle/WriteExtensionDescriptorTask.groovy
@@ -27,12 +27,11 @@ import org.gradle.api.tasks.OutputFile
  * A Gradle task to generate module descriptor files for Groovy extension modules.
  */
 class WriteExtensionDescriptorTask extends DefaultTask {
-    String description = 'Generates the org.codehaus.groovy.runtime.ExtensionModule descriptor file of a module'
+    @Input String description = 'Generates the org.codehaus.groovy.runtime.ExtensionModule descriptor file of a module'
     @Input String extensionClasses = ''
     @Input String staticExtensionClasses = ''
     @OutputFile File descriptor = computeDescriptorFile()
 
-
     private File computeDescriptorFile() {
         def metaInfDir = new File("${project.buildDir}/resources/main/META-INF/groovy")
         return new File(metaInfDir, "org.codehaus.groovy.runtime.ExtensionModule")
@@ -50,4 +49,3 @@ staticExtensionClasses=${staticExtensionClasses}"""
     }
 
 }
-
diff --git a/gradle.properties b/gradle.properties
index b64dc2e..6669015 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,48 +1,48 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements.  See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You under the Apache License, Version 2.0
-# (the "License"); you may not use this file except in compliance with
-# the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-groovyVersion = 3.0.10-SNAPSHOT
-# bundle version format: major('.'minor('.'micro('.'qualifier)?)?)? (first 3 only digits)
-groovyBundleVersion = 3.0.10.SNAPSHOT
-
-binaryCompatibilityBaseline = 3.0.5
-gradle_version=6.9.2
-
-groovyJUnit_ms=512m
-groovyJUnit_mx=2g
-groovyJUnit_permSize=64m
-groovyJUnit_maxPermSize=256m
-
-javacMain_mx=512m
-groovycMain_mx=1g
-groovycTest_mx=1g
-
-javaDoc_mx=1g
-
-# adjust if needed for different jdk versions
-#org.gradle.jvmargs=-ea -Xmx1500m
-org.gradle.jvmargs=-Xms800m -Xmx2g -XX:MaxMetaspaceSize=512m -XX:+UseG1GC
-
-# enable the Gradle build cache
-org.gradle.caching=true
-
-# enable --parallel
-org.gradle.parallel=true
-
-# prefer jars over class folders on the compile classpath
-org.gradle.java.compile-classpath-packaging=true
-
-# enables watching the file-system
-org.gradle.unsafe.watch-fs=true
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+groovyVersion = 3.0.10-SNAPSHOT
+# bundle version format: major('.'minor('.'micro('.'qualifier)?)?)? (first 3 only digits)
+groovyBundleVersion = 3.0.10.SNAPSHOT
+
+binaryCompatibilityBaseline = 3.0.5
+gradle_version=7.2
+
+groovyJUnit_ms=512m
+groovyJUnit_mx=2g
+groovyJUnit_permSize=64m
+groovyJUnit_maxPermSize=256m
+
+javacMain_mx=512m
+groovycMain_mx=1g
+groovycTest_mx=1g
+
+javaDoc_mx=1g
+
+# adjust if needed for different jdk versions
+#org.gradle.jvmargs=-ea -Xmx1500m
+org.gradle.jvmargs=-Xms800m -Xmx2g -XX:MaxMetaspaceSize=512m -XX:+UseG1GC
+
+# enable the Gradle build cache
+org.gradle.caching=true
+
+# enable --parallel
+org.gradle.parallel=true
+
+# prefer jars over class folders on the compile classpath
+org.gradle.java.compile-classpath-packaging=true
+
+# enables watching the file-system
+org.gradle.unsafe.watch-fs=true
diff --git a/gradle/assemble.gradle b/gradle/assemble.gradle
index 9cb26cf..a074dec 100644
--- a/gradle/assemble.gradle
+++ b/gradle/assemble.gradle
@@ -165,6 +165,7 @@ allprojects {
 
     def producedJars = [jar]
     jar {
+        duplicatesStrategy = DuplicatesStrategy.WARN
         appendix = 'raw'
         manifest {
             from(allManifest) {
@@ -179,6 +180,7 @@ allprojects {
     if (rootProject.indyCapable()) {
         task jarWithIndy(type: Jar) {
             dependsOn compileGroovyWithIndy
+            duplicatesStrategy = DuplicatesStrategy.WARN
             classifier = 'indy'
             appendix = 'raw'
             from sourceSets.main.java.outputDir
diff --git a/gradle/test.gradle b/gradle/test.gradle
index cd9d2b6..f53a78c 100644
--- a/gradle/test.gradle
+++ b/gradle/test.gradle
@@ -53,10 +53,8 @@ allprojects {
 
     // create an Indy test suite
     if (rootProject.indyCapable()) {
-        def dependencies = configurations.testRuntime.incoming.dependencies.findAll {
-            it.name.startsWith('groovy')
-        }.collect {
-            it.name
+        def dependencies = configurations.testRuntimeOnly.incoming.dependencies.findResults {
+            if (it.name.startsWith('groovy')) return it.name
         }
         task testWithIndy(type: Test) {
             systemProperties 'groovy.target.indy': true
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index ec991f9..ffed3a2 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.9.2-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
diff --git a/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java b/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
index 411b79d..83c7b55 100644
--- a/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
+++ b/src/main/java/org/codehaus/groovy/reflection/ReflectionUtils.java
@@ -133,6 +133,14 @@ public class ReflectionUtils {
         }
     }
 
+    private static boolean classShouldBeIgnored(final Class c, final Collection<String> extraIgnoredPackages) {
+        return (c != null
+                && (c.isSynthetic()
+                    || (c.getPackage() != null
+                        && (IGNORED_PACKAGES.contains(c.getPackage().getName())
+                          || extraIgnoredPackages.contains(c.getPackage().getName())))));
+    }
+
     public static List<Method> getDeclaredMethods(final Class<?> type, final String name, final Class<?>... parameterTypes) {
         return doGetMethods(type, name, parameterTypes, Class::getDeclaredMethods);
     }
@@ -225,12 +233,12 @@ public class ReflectionUtils {
         }
     }
 
-    private static boolean classShouldBeIgnored(final Class c, final Collection<String> extraIgnoredPackages) {
-        return (c != null
-                && (c.isSynthetic()
-                    || (c.getPackage() != null
-                        && (IGNORED_PACKAGES.contains(c.getPackage().getName())
-                          || extraIgnoredPackages.contains(c.getPackage().getName())))));
+    public static boolean isSealed(Class<?> c) {
+        try {
+            return Boolean.TRUE.equals(Class.class.getMethod("isSealed").invoke(c));
+        } catch (ReflectiveOperationException | SecurityException ignore) {
+        }
+        return false;
     }
 
     private static class ClassContextHelper extends SecurityManager {
diff --git a/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java b/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
index 23c4017..c7cf63f 100644
--- a/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
+++ b/src/main/java/org/codehaus/groovy/runtime/ProxyGeneratorAdapter.java
@@ -61,6 +61,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicLong;
 
+import static org.codehaus.groovy.reflection.ReflectionUtils.isSealed;
+
 /**
  * A proxy generator responsible for mapping a map of closures to a class implementing a list of interfaces. For
  * example, the following code:
@@ -145,7 +147,7 @@ public class ProxyGeneratorAdapter extends ClassVisitor implements Opcodes {
             final ClassLoader proxyLoader,
             final boolean emptyBody,
             final Class delegateClass) {
-        super(CompilerConfiguration.ASM_API_VERSION, new ClassWriter(0));
+        super(CompilerConfiguration.ASM_API_VERSION, new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS));
         this.loader = proxyLoader != null ? createInnerLoader(proxyLoader, interfaces) : findClassLoader(superClass, interfaces);
         this.visitedMethods = new LinkedHashSet<Object>();
         this.delegatedClosures = closureMap.isEmpty() ? EMPTY_DELEGATECLOSURE_MAP : new HashMap<String, Boolean>();
@@ -172,11 +174,13 @@ public class ProxyGeneratorAdapter extends ClassVisitor implements Opcodes {
         this.superClass = fixedSuperClass;
 
         // create the base list of classes which have possible methods to be overloaded
-        this.classList = new LinkedHashSet<Class>();
+        this.classList = new LinkedHashSet<>();
         this.classList.add(superClass);
         if (generateDelegateField) {
-            classList.add(delegateClass);
-            Collections.addAll(this.classList, delegateClass.getInterfaces());
+            this.classList.add(delegateClass);
+            for (Class<?> i : delegateClass.getInterfaces()) {
+                if (!isSealed(i)) this.classList.add(i);
+            }
         }
         if (interfaces != null) {
             Collections.addAll(this.classList, interfaces);
@@ -185,9 +189,9 @@ public class ProxyGeneratorAdapter extends ClassVisitor implements Opcodes {
         this.emptyBody = emptyBody;
 
         // generate bytecode
-        ClassWriter writer = (ClassWriter) cv;
-        this.visit(Opcodes.V1_5, ACC_PUBLIC, proxyName, null, null, null);
-        byte[] b = writer.toByteArray();
+        int bytecodeVersion = CompilerConfiguration.JDK_TO_BYTECODE_VERSION_MAP.get(CompilerConfiguration.DEFAULT.getTargetBytecode());
+        this.visit(bytecodeVersion, ACC_PUBLIC, proxyName, null, null, null);
+        byte[] b = ((ClassWriter) cv).toByteArray();
 //        CheckClassAdapter.verify(new ClassReader(b), true, new PrintWriter(System.err));
         cachedClass = loader.defineClass(proxyName.replace('/', '.'), b);
         // cache no-arg constructor
diff --git a/subprojects/groovy-json/build.gradle b/subprojects/groovy-json/build.gradle
index d9674ff..6b2e5ca 100644
--- a/subprojects/groovy-json/build.gradle
+++ b/subprojects/groovy-json/build.gradle
@@ -21,9 +21,9 @@ dependencies {
     testImplementation project(':groovy-test')
     testImplementation project(':groovy-dateutil')
     testImplementation 'net.javacrumbs.json-unit:json-unit:2.9.0'
-    testRuntime 'com.google.code.gson:gson:2.8.7' // json-unit requires gson, jackson1, or jackson2
-    testRuntime "org.slf4j:slf4j-api:$slf4jVersion"
-    testRuntime project(':groovy-ant') // for JavadocAssertionTests
+    testRuntimeOnly project(':groovy-ant') // for JavadocAssertionTests
+    testRuntimeOnly 'com.google.code.gson:gson:2.8.7' // json-unit requires gson, jackson1, or jackson2
+    testRuntimeOnly "org.slf4j:slf4j-api:$slf4jVersion"
 }
 
 eclipse.classpath.file.whenMerged {
diff --git a/subprojects/groovy-servlet/build.gradle b/subprojects/groovy-servlet/build.gradle
index eb83925..5857fd4 100644
--- a/subprojects/groovy-servlet/build.gradle
+++ b/subprojects/groovy-servlet/build.gradle
@@ -17,22 +17,17 @@
  *  under the License.
  */
 dependencies {
-    api("javax.servlet:javax.servlet-api:$servletApiVersion") { dep ->
-        provided dep
-    }
-    api("javax.servlet.jsp:javax.servlet.jsp-api:$jspApiVersion") { dep ->
-        provided dep
+    api rootProject  // ServletBinding extends Binding...
+    api "javax.servlet:javax.servlet-api:$servletApiVersion"
+    api("javax.servlet.jsp:javax.servlet.jsp-api:$jspApiVersion") {
         exclude(group: 'javax.servlet', module: 'javax.servlet-api')
     }
 
-    api rootProject  // ServletBinding extends Binding...
-    // needed for MarkupBuilder
-    implementation project(':groovy-xml')
-    // needed by TemplateServlet
-    implementation project(':groovy-templates')
+    implementation project(':groovy-xml') // for MarkupBuilder
+    implementation project(':groovy-templates') // by TemplateServlet
 
     testImplementation "jmock:jmock:$jmockVersion"
-    testImplementation rootProject.sourceSets.test.runtimeClasspath
     testImplementation project(':groovy-json')
     testImplementation project(':groovy-test')
+    testImplementation rootProject.sourceSets.test.runtimeClasspath
 }
diff --git a/subprojects/groovy-test-junit5/build.gradle b/subprojects/groovy-test-junit5/build.gradle
index d998353..f30695c 100644
--- a/subprojects/groovy-test-junit5/build.gradle
+++ b/subprojects/groovy-test-junit5/build.gradle
@@ -29,10 +29,10 @@ dependencies {
     implementation("org.junit.jupiter:junit-jupiter-engine:$junit5Version") {
         exclude(group: 'org.apiguardian', module: 'apiguardian-api')
     }
-    testImplementation "org.junit.jupiter:junit-jupiter-params:$junit5Version"
-    testRuntime "org.junit.platform:junit-platform-engine:$junit5PlatformVersion"
-    testRuntime "org.junit.platform:junit-platform-runner:$junit5PlatformVersion"
     testImplementation project(':groovy-test')
+    testImplementation "org.junit.jupiter:junit-jupiter-params:$junit5Version"
+    testRuntimeOnly "org.junit.platform:junit-platform-engine:$junit5PlatformVersion"
+    testRuntimeOnly "org.junit.platform:junit-platform-runner:$junit5PlatformVersion"
 }
 
 tasks.withType(JavaCompile) {
diff --git a/subprojects/groovy-test/build.gradle b/subprojects/groovy-test/build.gradle
index d70e688..e47c951 100644
--- a/subprojects/groovy-test/build.gradle
+++ b/subprojects/groovy-test/build.gradle
@@ -22,14 +22,14 @@ ext {
 }
 
 dependencies {
-    api rootProject   // GroovyTestCase uses Closure...
-    api "junit:junit:$junitVersion" // GroovyTestCase extends TestCase...
-    // groovy-ant needed for FileNameFinder used in AllTestSuite and JavadocAssertionTestSuite
-    testRuntime(project(':groovy-ant')) {
+    api rootProject // GroovyTestCase uses Closure
+    api "junit:junit:$junitVersion" // GroovyTestCase extends TestCase
+
+    testRuntimeOnly(project(':groovy-ant')) { // for FileNameFinder (used in AllTestSuite and JavadocAssertionTestSuite)
         transitive = false // bring in just what we need below
     }
-    testRuntime "org.apache.ant:ant:$antVersion"
-    testRuntime "org.apache.ant:ant-launcher:$antVersion"
+    testRuntimeOnly "org.apache.ant:ant:$antVersion"
+    testRuntimeOnly "org.apache.ant:ant-launcher:$antVersion"
 }
 
 eclipse.classpath.file.whenMerged {
diff --git a/subprojects/groovy-testng/build.gradle b/subprojects/groovy-testng/build.gradle
index 3e5545e..b16facd 100644
--- a/subprojects/groovy-testng/build.gradle
+++ b/subprojects/groovy-testng/build.gradle
@@ -18,12 +18,12 @@
  */
 dependencies {
     api rootProject // TestNgRunner implements GroovyRunner...
-    runtime('org.testng:testng:7.5') {
-        exclude(group: 'com.google.inject', module: 'guice')
+    runtimeOnly('org.testng:testng:7.5') {
         exclude(group: 'com.google.code.findbugs', module: 'jsr305')
-        exclude(group: 'junit', module: 'junit')
+        exclude(group: 'com.google.inject', module: 'guice')
         exclude(group: 'org.apache.ant', module: 'ant')
         exclude(group: 'org.yaml', module: 'snakeyaml')
+        exclude(group: 'junit', module: 'junit')
     }
     testImplementation project(':groovy-test')
 }
diff --git a/subprojects/groovy-yaml/build.gradle b/subprojects/groovy-yaml/build.gradle
index f413bf7..32fedd6 100644
--- a/subprojects/groovy-yaml/build.gradle
+++ b/subprojects/groovy-yaml/build.gradle
@@ -27,8 +27,8 @@ dependencies {
     implementation "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
     implementation project(':groovy-json')
     testImplementation project(':groovy-test')
-    testRuntime "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"
-    testRuntime project(':groovy-ant') // for JavadocAssertionTests
+    testRuntimeOnly project(':groovy-ant') // for JavadocAssertionTests
+    testRuntimeOnly "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"
 }
 
 eclipse.classpath.file.whenMerged {