From 471f5f253fe0eb140deb8712bda994c20dedf7ba Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 10 Oct 2025 15:08:07 +0800 Subject: [PATCH 1/5] Replace `jvmArgs` --- build.gradle.kts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index b9a1e402c..36817112a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -105,13 +105,9 @@ tasks.withType().configureEach { // Required to test configuration cache in tests when using withDebug() // https://github.com/gradle/gradle/issues/22765#issuecomment-1339427241 jvmArgs( - "--add-opens", - "java.base/java.util=ALL-UNNAMED", - "--add-opens", - "java.base/java.util.concurrent.atomic=ALL-UNNAMED", - "--add-opens", - "java.base/java.lang.invoke=ALL-UNNAMED", - "--add-opens", - "java.base/java.net=ALL-UNNAMED", + "--add-opens=java.base/java.util=ALL-UNNAMED", + "--add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED", + "--add-opens=java.base/java.lang.invoke=ALL-UNNAMED", + "--add-opens=java.base/java.net=ALL-UNNAMED", ) } From 25e1e723659b9b3ff406539c646aa4d4d69932a3 Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 10 Oct 2025 15:07:38 +0800 Subject: [PATCH 2/5] Replace `runWithDebug` with `run` --- .../plugins/shadow/ShadowPluginSpec.groovy | 18 +++++++++--------- .../shadow/util/PluginSpecification.groovy | 4 ---- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy index fda372688..4f0bc3f91 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy @@ -256,7 +256,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('server/build/libs/server-all.jar') when: - runWithDebug(':server:shadowJar') + run(':server:shadowJar') then: serverOutput.exists() @@ -311,7 +311,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('server/build/libs/server-all.jar') when: - runWithDebug(':server:shadowJar') + run(':server:shadowJar') then: serverOutput.exists() @@ -364,7 +364,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = file('server/build/libs/server-all.jar') when: - runWithDebug(':server:shadowJar') + run(':server:shadowJar') then: contains(serverOutput, [ @@ -419,7 +419,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = file('server/build/libs/server-all.jar') when: - runWithDebug(':server:shadowJar') + run(':server:shadowJar') then: contains(serverOutput, [ @@ -472,7 +472,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = file('server/build/libs/server-all.jar') when: - runWithDebug(':server:shadowJar') + run(':server:shadowJar') then: contains(serverOutput, [ @@ -550,7 +550,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('impl/build/libs/impl-all.jar') when: - runWithDebug(':impl:shadowJar') + run(':impl:shadowJar') then: serverOutput.exists() @@ -626,7 +626,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('impl/build/libs/impl-all.jar') when: - runWithDebug(':impl:shadowJar') + run(':impl:shadowJar') then: serverOutput.exists() @@ -840,7 +840,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - runWithDebug('shadowJar') + run('shadowJar') then: contains(output, ['api.properties', 'implementation.properties', @@ -1036,7 +1036,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('impl/build/libs/impl-1.0-all.jar') when: - runWithDebug(':impl:shadowJar') + run(':impl:shadowJar') then: serverOutput.exists() diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy index 92e53591b..68b8047e6 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy @@ -76,10 +76,6 @@ abstract class PluginSpecification extends Specification { return result } - BuildResult runWithDebug(String... tasks) { - return run(tasks.toList(), { it.withDebug(true) }) - } - BuildResult runWithFailure(List tasks, Function runnerFunction = { it }) { def result = runnerFunction.apply(runner(tasks)).buildAndFail() assertNoDeprecationWarnings(result) From 98737af42ffd08861bd5817a5ad867a4e04e755a Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 10 Oct 2025 15:12:23 +0800 Subject: [PATCH 3/5] Replace `run` with `runWithSuccess` --- .../plugins/shadow/ApplicationSpec.groovy | 8 +-- .../shadow/ConfigurationCacheSpec.groovy | 16 +++--- .../ConfigureShadowRelocationSpec.groovy | 2 +- .../plugins/shadow/FilteringSpec.groovy | 26 ++++----- .../PropertiesFileTransformerSpec.groovy | 10 ++-- .../plugins/shadow/PublishingSpec.groovy | 8 +-- .../plugins/shadow/RelocationSpec.groovy | 12 ++--- .../plugins/shadow/ShadowPluginSpec.groovy | 54 +++++++++---------- .../plugins/shadow/TransformerSpec.groovy | 34 ++++++------ .../shadow/caching/AbstractCachingSpec.groovy | 2 +- .../shadow/util/PluginSpecification.groovy | 6 +-- 11 files changed, 89 insertions(+), 89 deletions(-) diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy index 724d74e2e..13d35e39f 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy @@ -45,7 +45,7 @@ class ApplicationSpec extends PluginSpecification { settingsFile << "rootProject.name = 'myapp'" when: - BuildResult result = run('runShadow') + BuildResult result = runWithSuccess('runShadow') then: 'tests that runShadow executed and exited' assert result.output.contains('TestApp: Hello World! (foo)') @@ -123,7 +123,7 @@ class ApplicationSpec extends PluginSpecification { """.stripIndent() when: - BuildResult result = run('runShadow') + BuildResult result = runWithSuccess('runShadow') then: 'tests that runShadow executed and exited' assert result.output.contains('Running application with JDK 17') @@ -187,7 +187,7 @@ class ApplicationSpec extends PluginSpecification { settingsFile << "rootProject.name = 'myapp'" when: - run('shadowDistZip') + runWithSuccess('shadowDistZip') then: 'Check that the distribution zip was created' File zip = getFile('build/distributions/myapp-shadow-1.0.zip') @@ -239,7 +239,7 @@ class ApplicationSpec extends PluginSpecification { settingsFile << "rootProject.name = 'myapp'" when: - run(ShadowApplicationPlugin.SHADOW_INSTALL_TASK_NAME) + runWithSuccess(ShadowApplicationPlugin.SHADOW_INSTALL_TASK_NAME) then: 'Check that the proper jar file was installed' File installedJar = getFile('build/install/myapp-shadow/lib/myapp-1.0-all.jar') diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy index 9bb5ef2a0..babc4e5f9 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy @@ -52,8 +52,8 @@ class ConfigurationCacheSpec extends PluginSpecification { settingsFile << "rootProject.name = 'myapp'" when: - run('shadowJar') - def result = run('shadowJar') + runWithSuccess('shadowJar') + def result = runWithSuccess('shadowJar') then: result.output.contains("Reusing configuration cache.") @@ -68,9 +68,9 @@ class ConfigurationCacheSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') output.delete() - def result = run('shadowJar') + def result = runWithSuccess('shadowJar') then: contains(output, ['a.properties', 'b.properties']) @@ -120,9 +120,9 @@ class ConfigurationCacheSpec extends PluginSpecification { def output = getFile('server/build/libs/server-all.jar') when: - run('shadowJar', '-s') + runWithSuccess('shadowJar', '-s') output.delete() - def result = run('shadowJar', '-s') + def result = runWithSuccess('shadowJar', '-s') then: output.exists() @@ -163,8 +163,8 @@ class ConfigurationCacheSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar', '-s') - def result = run('shadowJar', '-s') + runWithSuccess('shadowJar', '-s') + def result = runWithSuccess('shadowJar', '-s') then: result.output.contains(":lib:shadowJar UP-TO-DATE") diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy index 2c5af9c15..d1a56632e 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy @@ -18,7 +18,7 @@ class ConfigureShadowRelocationSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar', '-s') + runWithSuccess('shadowJar', '-s') then: contains(output, [ diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy index 970e33e8b..bf028d3bc 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy @@ -29,7 +29,7 @@ class FilteringSpec extends PluginSpecification { def 'include all dependencies'() { when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties', 'a2.properties', 'b.properties']) @@ -46,7 +46,7 @@ class FilteringSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties', 'b.properties']) @@ -80,7 +80,7 @@ class FilteringSpec extends PluginSpecification { '''.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties', 'a2.properties', 'b.properties', 'c.properties']) @@ -115,7 +115,7 @@ class FilteringSpec extends PluginSpecification { '''.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties', 'a2.properties', 'b.properties', 'c.properties']) @@ -149,7 +149,7 @@ class FilteringSpec extends PluginSpecification { '''.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties', 'a2.properties', 'b.properties', 'c.properties']) @@ -161,7 +161,7 @@ class FilteringSpec extends PluginSpecification { buildFile.text = buildFile.text.replace('exclude(dependency(\'shadow:d:1.0\'))', 'exclude(dependency(\'shadow:c:1.0\'))') - BuildResult result = run('shadowJar') + BuildResult result = runWithSuccess('shadowJar') then: assert result.task(':shadowJar').outcome == TaskOutcome.SUCCESS @@ -198,7 +198,7 @@ class FilteringSpec extends PluginSpecification { '''.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties', 'a2.properties', 'b.properties', 'c.properties']) @@ -213,7 +213,7 @@ class FilteringSpec extends PluginSpecification { } '''.stripIndent() - BuildResult result = run('shadowJar') + BuildResult result = runWithSuccess('shadowJar') then: assert result.task(':shadowJar').outcome == TaskOutcome.SUCCESS @@ -253,7 +253,7 @@ class FilteringSpec extends PluginSpecification { '''.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['d.properties', 'shadow/Passed.class']) @@ -305,7 +305,7 @@ class FilteringSpec extends PluginSpecification { File serverOutput = getFile('server/build/libs/server-1.0-all.jar') when: - run(':server:shadowJar') + runWithSuccess(':server:shadowJar') then: serverOutput.exists() @@ -359,7 +359,7 @@ class FilteringSpec extends PluginSpecification { File serverOutput = getFile('server/build/libs/server-1.0-all.jar') when: - run(':server:shadowJar') + runWithSuccess(':server:shadowJar') then: serverOutput.exists() @@ -387,7 +387,7 @@ class FilteringSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties', 'b.properties']) @@ -421,7 +421,7 @@ class FilteringSpec extends PluginSpecification { '''.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties', 'a2.properties', 'b.properties', 'c.properties']) diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PropertiesFileTransformerSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PropertiesFileTransformerSpec.groovy index 34ace1f52..62de4f8b0 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PropertiesFileTransformerSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PropertiesFileTransformerSpec.groovy @@ -34,7 +34,7 @@ class PropertiesFileTransformerSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -87,7 +87,7 @@ class PropertiesFileTransformerSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: output.exists() @@ -121,7 +121,7 @@ class PropertiesFileTransformerSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: output.exists() @@ -158,7 +158,7 @@ class PropertiesFileTransformerSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: output.exists() @@ -202,7 +202,7 @@ class PropertiesFileTransformerSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: output.exists() diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy index 6ce01faff..9dde49d38 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy @@ -57,7 +57,7 @@ class PublishingSpec extends PluginSpecification { """.stripIndent() when: - run('publish') + runWithSuccess('publish') then: File publishedFile = publishingRepo.rootDir.file('shadow/maven-all/1.0/maven-all-1.0.jar').canonicalFile @@ -125,7 +125,7 @@ class PublishingSpec extends PluginSpecification { """.stripIndent() when: - run('publish') + runWithSuccess('publish') then: File publishedFile = publishingRepo.rootDir.file('shadow/maven-all/1.0/maven-all-1.0-my-classifier.my-ext').canonicalFile @@ -206,7 +206,7 @@ class PublishingSpec extends PluginSpecification { """.stripMargin() when: - run('publish') + runWithSuccess('publish') then: File publishedFile = publishingRepo.rootDir.file('shadow/maven-all/1.0/maven-all-1.0.jar').canonicalFile @@ -270,7 +270,7 @@ class PublishingSpec extends PluginSpecification { """.stripIndent() when: - run('publish') + runWithSuccess('publish') then: File mainJar = publishingRepo.rootDir.file('com/acme/maven/1.0/maven-1.0.jar').canonicalFile diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy index a72008197..253961e9e 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy @@ -27,7 +27,7 @@ class RelocationSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, [ @@ -95,7 +95,7 @@ class RelocationSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, [ @@ -158,7 +158,7 @@ class RelocationSpec extends PluginSpecification { '''.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, [ @@ -230,7 +230,7 @@ class RelocationSpec extends PluginSpecification { '''.stripIndent() when: - run(':app:shadowJar') + runWithSuccess(':app:shadowJar') then: File appOutput = getFile('app/build/libs/app-all.jar') @@ -271,7 +271,7 @@ class RelocationSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, [ @@ -316,7 +316,7 @@ class RelocationSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: noExceptionThrown() diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy index 4f0bc3f91..8675cf47f 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy @@ -80,7 +80,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run(['shadowJar']) { + runWithSuccess(['shadowJar']) { it.withGradleVersion(version) it.withDebug(true) it.withTestKitDir(getTestKitDir()) @@ -126,7 +126,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -153,7 +153,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output("shadow.jar"), ['shadow/Passed.class', 'junit/framework/Test.class']) @@ -199,7 +199,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('server/build/libs/server-all.jar') when: - run(':server:shadowJar') + runWithSuccess(':server:shadowJar') then: serverOutput.exists() @@ -256,7 +256,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('server/build/libs/server-all.jar') when: - run(':server:shadowJar') + runWithSuccess(':server:shadowJar') then: serverOutput.exists() @@ -311,7 +311,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('server/build/libs/server-all.jar') when: - run(':server:shadowJar') + runWithSuccess(':server:shadowJar') then: serverOutput.exists() @@ -364,7 +364,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = file('server/build/libs/server-all.jar') when: - run(':server:shadowJar') + runWithSuccess(':server:shadowJar') then: contains(serverOutput, [ @@ -419,7 +419,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = file('server/build/libs/server-all.jar') when: - run(':server:shadowJar') + runWithSuccess(':server:shadowJar') then: contains(serverOutput, [ @@ -472,7 +472,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = file('server/build/libs/server-all.jar') when: - run(':server:shadowJar') + runWithSuccess(':server:shadowJar') then: contains(serverOutput, [ @@ -550,7 +550,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('impl/build/libs/impl-all.jar') when: - run(':impl:shadowJar') + runWithSuccess(':impl:shadowJar') then: serverOutput.exists() @@ -626,7 +626,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('impl/build/libs/impl-all.jar') when: - run(':impl:shadowJar') + runWithSuccess(':impl:shadowJar') then: serverOutput.exists() @@ -680,7 +680,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('server/build/libs/server.jar') when: - run(':server:jar') + runWithSuccess(':server:jar') then: serverOutput.exists() @@ -738,7 +738,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('server/build/libs/server-all.jar') when: - run(':server:shadowJar') + runWithSuccess(':server:shadowJar') then: serverOutput.exists() @@ -775,7 +775,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties', 'META-INF/a.properties']) @@ -802,7 +802,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties']) @@ -840,7 +840,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['api.properties', 'implementation.properties', @@ -865,7 +865,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: contains(output, ['a.properties']) @@ -892,7 +892,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: JarFile jar = new JarFile(output) @@ -907,7 +907,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -939,7 +939,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -961,7 +961,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -988,7 +988,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -1036,7 +1036,7 @@ class ShadowPluginSpec extends PluginSpecification { File serverOutput = getFile('impl/build/libs/impl-1.0-all.jar') when: - run(':impl:shadowJar') + runWithSuccess(':impl:shadowJar') then: serverOutput.exists() @@ -1110,7 +1110,7 @@ class ShadowPluginSpec extends PluginSpecification { settingsFile << "rootProject.name = 'myapp'" when: - BuildResult result = run('runShadow') + BuildResult result = runWithSuccess('runShadow') then: 'tests that runShadow executed and exited' assert result.output.contains('TestApp: Hello World! (foo)') @@ -1170,7 +1170,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - BuildResult result = run('runShadow') + BuildResult result = runWithSuccess('runShadow') then: 'tests that runShadow executed and exited' assert result.output.contains('TestApp: Hello World! (foo)') @@ -1212,7 +1212,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - BuildResult result = run('runShadow') + BuildResult result = runWithSuccess('runShadow') then: 'tests that runShadow executed and exited' assert result.output.contains('TestApp: Hello World! (foo)') @@ -1238,7 +1238,7 @@ class ShadowPluginSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy index 7bed060ce..840bbd5ec 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy @@ -41,7 +41,7 @@ class TransformerSpec extends PluginSpecification { """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -81,7 +81,7 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -121,7 +121,7 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -176,7 +176,7 @@ com.mysql.jdbc.Driver'''.stripIndent()) """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -224,7 +224,7 @@ org.mortbay.log.Factory'''.stripIndent() """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -261,7 +261,7 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() 'three # NOTE: No newline terminates this line/file' when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -297,7 +297,7 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -330,7 +330,7 @@ two # NOTE: No newline terminates this line/file """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -366,7 +366,7 @@ two # NOTE: No newline terminates this line/file """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -410,7 +410,7 @@ two # NOTE: No newline terminates this line/file """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -462,7 +462,7 @@ two # NOTE: No newline terminates this line/file """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -509,7 +509,7 @@ two # NOTE: No newline terminates this line/file """.stripIndent() when: - run('jar', 'shadowJar') + runWithSuccess('jar', 'shadowJar') then: File jar = getFile('build/libs/shadow-1.0.jar') @@ -569,7 +569,7 @@ two # NOTE: No newline terminates this line/file """.stripIndent() when: - run('jar', 'shadowJar') + runWithSuccess('jar', 'shadowJar') then: File jar = getFile('build/libs/shadow-1.0.jar') @@ -628,7 +628,7 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -672,7 +672,7 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: output.exists() @@ -715,7 +715,7 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( """.stripIndent() when: - run('shadowJar') + runWithSuccess('shadowJar') then: assert output.exists() @@ -745,7 +745,7 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( """.stripIndent() when: - run('shadowJar', '--warning-mode=all') + runWithSuccess('shadowJar', '--warning-mode=all') then: assert output.exists() diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy index 3c0ed8c9b..316f3e510 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy @@ -36,7 +36,7 @@ abstract class AbstractCachingSpec extends PluginSpecification { BuildResult runWithCacheEnabled(String... arguments) { List cacheArguments = ['--build-cache'] cacheArguments.addAll(arguments) - return run(cacheArguments) + return runWithSuccess(cacheArguments) } BuildResult runInAlternateDirWithCacheEnabled(String... arguments) { diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy index 68b8047e6..e8cc1c90d 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy @@ -66,11 +66,11 @@ abstract class PluginSpecification extends Specification { runner.withArguments(["-Dorg.gradle.warning.mode=all", "--configuration-cache", "--stacktrace"] + tasks.toList()) } - BuildResult run(String... tasks) { - run(tasks.toList()) + BuildResult runWithSuccess(String... tasks) { + runWithSuccess(tasks.toList()) } - BuildResult run(List tasks, Function runnerFunction = { it }) { + BuildResult runWithSuccess(List tasks, Function runnerFunction = { it }) { def result = runnerFunction.apply(runner(tasks)).build() assertNoDeprecationWarnings(result) return result From 69a43cc2c2ff80be547d2244226b2fceafd5ecbe Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 10 Oct 2025 15:21:30 +0800 Subject: [PATCH 4/5] Cleanups --- .../plugins/shadow/ShadowPluginSpec.groovy | 61 ------------------- .../plugins/shadow/TransformerSpec.groovy | 2 +- .../shadow/caching/AbstractCachingSpec.groovy | 2 +- .../shadow/util/PluginSpecification.groovy | 29 ++++++--- 4 files changed, 23 insertions(+), 71 deletions(-) diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy index 8675cf47f..540bd2033 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy @@ -2,16 +2,13 @@ package com.github.jengelman.gradle.plugins.shadow import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.util.PluginSpecification -import org.gradle.api.JavaVersion import org.gradle.api.Project import org.gradle.api.artifacts.Configuration import org.gradle.api.plugins.JavaPlugin import org.gradle.testfixtures.ProjectBuilder import org.gradle.testkit.runner.BuildResult import spock.lang.Ignore -import spock.lang.IgnoreIf import spock.lang.Issue -import spock.lang.Unroll import java.util.jar.Attributes import java.util.jar.JarFile @@ -55,64 +52,6 @@ class ShadowPluginSpec extends PluginSpecification { } - @IgnoreIf({ - // Gradle 8.3 doesn't support Java 21. - JavaVersion.current().majorVersion.toInteger() >= 21 - }) - @Unroll - def 'Compatible with Gradle #version'() { - given: - File one = buildJar('one.jar').insertFile('META-INF/services/shadow.Shadow', - 'one # NOTE: No newline terminates this line/file').write() - - repo.module('shadow', 'two', '1.0').insertFile('META-INF/services/shadow.Shadow', - 'two # NOTE: No newline terminates this line/file').publish() - - buildFile << """ - dependencies { - implementation 'junit:junit:3.8.2' - implementation files('${escapedPath(one)}') - } - - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { - mergeServiceFiles() - } - """.stripIndent() - - when: - runWithSuccess(['shadowJar']) { - it.withGradleVersion(version) - it.withDebug(true) - it.withTestKitDir(getTestKitDir()) - } - - then: - assert output.exists() - - where: - version << ['8.3'] - } - - def 'Error in Gradle versions < 8.3'() { - given: - buildFile << """ - dependencies { - implementation 'junit:junit:3.8.2' - } - - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { - mergeServiceFiles() - } - """.stripIndent() - - expect: - runWithFailure(['shadowJar']) { - it.withGradleVersion('7.0') - it.withDebug(true) - it.withTestKitDir(getTestKitDir()) - } - } - def 'shadow copy'() { given: URL artifact = this.class.classLoader.getResource('test-artifact-1.0-SNAPSHOT.jar') diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy index 840bbd5ec..1ba44e918 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy @@ -745,7 +745,7 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( """.stripIndent() when: - runWithSuccess('shadowJar', '--warning-mode=all') + runWithSuccess('shadowJar') then: assert output.exists() diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy index 316f3e510..f54c7bb9f 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy @@ -43,7 +43,7 @@ abstract class AbstractCachingSpec extends PluginSpecification { List cacheArguments = ['--build-cache'] cacheArguments.addAll(arguments) // TODO: Use PluginSpecification.run here to reuse flags, but cache tests failed for now, need to investigate. - return runner.withProjectDir(alternateDir.toFile()).withArguments(cacheArguments).build() + return runner().withProjectDir(alternateDir.toFile()).withArguments(cacheArguments).build() } void assertShadowJarHasResult(TaskOutcome expectedOutcome) { diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy index e8cc1c90d..71efa6f25 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/util/PluginSpecification.groovy @@ -8,6 +8,7 @@ import spock.lang.Specification import spock.lang.TempDir import java.nio.file.Path +import java.nio.file.Paths import java.util.function.Function import java.util.jar.JarEntry import java.util.jar.JarFile @@ -17,7 +18,15 @@ abstract class PluginSpecification extends Specification { @TempDir Path dir - public static final String TEST_GRADLE_VERSION = System.getProperty("TEST_GRADLE_VERSION") + private static final String TEST_GRADLE_VERSION = System.getProperty("TEST_GRADLE_VERSION") + + private static final Path TEST_KIT_DIR + + static { + def gradleUserHome = System.getenv("GRADLE_USER_HOME") + ?: Paths.get(System.getProperty("user.home"), ".gradle").toAbsolutePath().toString() + TEST_KIT_DIR = Paths.get(gradleUserHome, "testkit") + } AppendableMavenFileRepository repo @@ -54,20 +63,19 @@ abstract class PluginSpecification extends Specification { """.stripIndent() } - GradleRunner getRunner() { + GradleRunner runner(Collection tasks = Collections.emptyList()) { + def extraArgs = ["--warning-mode=fail", "--configuration-cache", "--stacktrace"] GradleRunner.create() .withGradleVersion(TEST_GRADLE_VERSION) .withProjectDir(dir.toFile()) + .withTestKitDir(TEST_KIT_DIR.toFile()) .forwardOutput() .withPluginClasspath() - } - - GradleRunner runner(Collection tasks) { - runner.withArguments(["-Dorg.gradle.warning.mode=all", "--configuration-cache", "--stacktrace"] + tasks.toList()) + .withArguments(extraArgs + tasks) } BuildResult runWithSuccess(String... tasks) { - runWithSuccess(tasks.toList()) + return runWithSuccess(tasks.toList()) } BuildResult runWithSuccess(List tasks, Function runnerFunction = { it }) { @@ -76,6 +84,10 @@ abstract class PluginSpecification extends Specification { return result } + BuildResult runWithFailure(String... tasks) { + return runWithFailure(tasks.toList()) + } + BuildResult runWithFailure(List tasks, Function runnerFunction = { it }) { def result = runnerFunction.apply(runner(tasks)).buildAndFail() assertNoDeprecationWarnings(result) @@ -90,7 +102,8 @@ abstract class PluginSpecification extends Specification { static boolean containsDeprecationWarning(String output) { output.contains("has been deprecated and is scheduled to be removed in Gradle") || - output.contains("has been deprecated. This is scheduled to be removed in Gradle") + output.contains("has been deprecated. This is scheduled to be removed in Gradle") || + output.contains("will fail with an error in Gradle") } File getBuildFile() { From 13d9c0510c2678b8dcb3ecdfe835eedc98b1bf94 Mon Sep 17 00:00:00 2001 From: Goooler Date: Fri, 10 Oct 2025 15:39:56 +0800 Subject: [PATCH 5/5] Remove some ignored tests --- .../plugins/shadow/ShadowPluginSpec.groovy | 132 ------------------ 1 file changed, 132 deletions(-) diff --git a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy index 540bd2033..97be7aa45 100644 --- a/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy +++ b/src/test/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy @@ -7,7 +7,6 @@ import org.gradle.api.artifacts.Configuration import org.gradle.api.plugins.JavaPlugin import org.gradle.testfixtures.ProjectBuilder import org.gradle.testkit.runner.BuildResult -import spock.lang.Ignore import spock.lang.Issue import java.util.jar.Attributes @@ -984,137 +983,6 @@ class ShadowPluginSpec extends PluginSpecification { ]) } - @Issue('SHADOW-143') - @Ignore("This spec requires > 15 minutes and > 8GB of disk space to run") - def "check large zip files with zip64 enabled"() { - given: - repo.module('shadow', 'a', '1.0') - .insertFile('a.properties', 'a') - .insertFile('a2.properties', 'a2') - .publish() - - file('src/main/java/myapp/Main.java') << """ - package myapp; - public class Main { - public static void main(String[] args) { - System.out.println("TestApp: Hello World! (" + args[0] + ")"); - } - } - """.stripIndent() - - buildFile << """ - apply plugin: 'application' - - application { - mainClass = 'myapp.Main' - } - - dependencies { - implementation 'shadow:a:1.0' - } - - def generatedResourcesDir = new File(project.layout.buildDirectory.asFile.get(), "generated-resources") - - task generateResources { - doLast { - def rnd = new Random() - def buf = new byte[128 * 1024] - for (x in 0..255) { - def dir = new File(generatedResourcesDir, x.toString()) - dir.mkdirs() - for (y in 0..255) { - def file = new File(dir, y.toString()) - rnd.nextBytes(buf) - file.bytes = buf - } - } - } - } - - sourceSets { - main { - output.dir(generatedResourcesDir, builtBy: generateResources) - } - } - - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { - zip64 = true - } - - runShadow { - args 'foo' - } - """.stripIndent() - - settingsFile << "rootProject.name = 'myapp'" - - when: - BuildResult result = runWithSuccess('runShadow') - - then: 'tests that runShadow executed and exited' - assert result.output.contains('TestApp: Hello World! (foo)') - - - } - - @Issue("SHADOW-303") - @Ignore("Plugin has been deprecated") - def "doesn't error when adding aspectj plugin"() { - given: - buildFile.text = """ - buildscript { - repositories { - maven { - url = "https://maven.eveoh.nl/content/repositories/releases" - } - } - - dependencies { - classpath "nl.eveoh:gradle-aspectj:2.0" - } - } - """.stripIndent() - - buildFile << defaultBuildScript - - buildFile << """ - project.ext { - aspectjVersion = '1.8.12' - } - - apply plugin: 'aspectj' - apply plugin: 'application' - - application { - mainClass = 'myapp.Main' - } - - repositories { - mavenCentral() - } - - runShadow { - args 'foo' - } - - """ - - file('src/main/java/myapp/Main.java') << """ - package myapp; - public class Main { - public static void main(String[] args) { - System.out.println("TestApp: Hello World! (" + args[0] + ")"); - } - } - """.stripIndent() - - when: - BuildResult result = runWithSuccess('runShadow') - - then: 'tests that runShadow executed and exited' - assert result.output.contains('TestApp: Hello World! (foo)') - } - @Issue("https://github.com/GradleUp/shadow/issues/609") def "doesn't error when using application mainClass property"() { given: