From 18bb86e612e46771688804bd1ebf2f6ed9efafcc Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 25 Dec 2024 22:49:10 +0800 Subject: [PATCH 1/7] Declare maven repos in settings.gradle --- .../shadow/BasePluginSpecification.groovy | 21 +++++++-- .../shadow/ConfigurationCacheSpec.groovy | 4 +- .../plugins/shadow/PublishingSpec.groovy | 1 - .../plugins/shadow/ShadowPluginSpec.groovy | 45 +++++++------------ .../caching/MinimizationCachingSpec.groovy | 4 +- 5 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy index f3393d6ec..8f22b640d 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy @@ -27,9 +27,7 @@ abstract class BasePluginSpecification extends Specification { buildFile << defaultBuildScript - settingsFile << ''' - rootProject.name = 'shadow' - ''' + settingsFile << settingsBuildScript } def cleanup() { @@ -50,10 +48,25 @@ abstract class BasePluginSpecification extends Specification { integTest } - repositories { maven { url = "${repo.uri}" } } + repositories { + maven { url = "${repo.uri}" } + } """.stripIndent() } + String getSettingsBuildScript() { + return """ + dependencyResolutionManagement { + repositories { + maven { url = "${repo.uri}" } + mavenCentral() + } + } + + rootProject.name = 'shadow' + """ + } + GradleRunner getRunner() { GradleRunner.create() .withProjectDir(dir.toFile()) diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy index 253db82bc..1da30fa4a 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy @@ -91,7 +91,7 @@ class ConfigurationCacheSpec extends BasePluginSpecification { """.stripIndent() file('client/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -110,7 +110,6 @@ class ConfigurationCacheSpec extends BasePluginSpecification { } } - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(':client') } """.stripIndent() @@ -149,7 +148,6 @@ class ConfigurationCacheSpec extends BasePluginSpecification { apply plugin: 'java' apply plugin: 'com.gradleup.shadow' - repositories { maven { url = "${repo.uri}" } } dependencies { implementation "junit:junit:3.8.2" } diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy index 6f2616897..753ff614a 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy @@ -149,7 +149,6 @@ class PublishingSpec extends BasePluginSpecification { version = "1.0" group = 'shadow' - repositories { maven { url = "${repo.uri}" } } publishing { repositories { maven { diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy index 623056ca8..3c2dc9a97 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy @@ -174,7 +174,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('client/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -190,7 +190,6 @@ class ShadowPluginSpec extends BasePluginSpecification { apply plugin: 'java' apply plugin: 'com.gradleup.shadow' - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(':client') } """.stripIndent() @@ -226,7 +225,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('client/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -248,7 +247,6 @@ class ShadowPluginSpec extends BasePluginSpecification { minimize() } - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(':client') } """.stripIndent() @@ -284,7 +282,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('client/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -303,7 +301,6 @@ class ShadowPluginSpec extends BasePluginSpecification { } } - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(':client') } """.stripIndent() @@ -338,7 +335,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('client/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + """.stripIndent() file('server/src/main/java/server/Server.java') << """ @@ -356,7 +353,6 @@ class ShadowPluginSpec extends BasePluginSpecification { } } - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(':client') } """.stripIndent() @@ -392,7 +388,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('client/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -411,7 +407,6 @@ class ShadowPluginSpec extends BasePluginSpecification { } } - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(':client') } """.stripIndent() @@ -445,7 +440,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('client/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -464,7 +459,6 @@ class ShadowPluginSpec extends BasePluginSpecification { } } - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(':client') } """.stripIndent() @@ -505,7 +499,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('lib/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + """.stripIndent() file('api/src/main/java/api/Entity.java') << """ @@ -521,7 +515,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('api/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' implementation project(':lib') @@ -542,7 +536,6 @@ class ShadowPluginSpec extends BasePluginSpecification { minimize() } - repositories { maven { url = "${repo.uri}" } } dependencies { api project(':api') } """.stripIndent() @@ -584,7 +577,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('lib/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + """.stripIndent() file('api/src/main/java/api/Entity.java') << """ @@ -600,7 +593,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('api/build.gradle') << """ apply plugin: 'java-library' - repositories { maven { url = "${repo.uri}" } } + dependencies { api project(':lib') } """.stripIndent() @@ -618,7 +611,7 @@ class ShadowPluginSpec extends BasePluginSpecification { minimize() } - repositories { maven { url = "${repo.uri}" } } + dependencies { api project(':api') } """.stripIndent() @@ -652,7 +645,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('client/build.gradle') << """ apply plugin: 'java' apply plugin: 'com.gradleup.shadow' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' } tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { @@ -672,7 +665,6 @@ class ShadowPluginSpec extends BasePluginSpecification { file('server/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(path: ':client', configuration: 'shadow') } """.stripIndent() @@ -709,7 +701,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('client/build.gradle') << """ apply plugin: 'java' apply plugin: 'com.gradleup.shadow' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' } tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { @@ -730,7 +722,6 @@ class ShadowPluginSpec extends BasePluginSpecification { apply plugin: 'java' apply plugin: 'com.gradleup.shadow' - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(path: ':client', configuration: 'shadow') } """.stripIndent() @@ -1003,7 +994,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('lib/build.gradle') << """ apply plugin: 'java' version = '1.0' - repositories { maven { url = "${repo.uri}" } } + """.stripIndent() file('api/src/main/java/api/UnusedEntity.java') << """ @@ -1014,7 +1005,7 @@ class ShadowPluginSpec extends BasePluginSpecification { file('api/build.gradle') << """ apply plugin: 'java' version = '1.0' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' implementation project(':lib') @@ -1026,7 +1017,7 @@ class ShadowPluginSpec extends BasePluginSpecification { apply plugin: 'com.gradleup.shadow' version = '1.0' - repositories { maven { url = "${repo.uri}" } } + dependencies { api project(':api') } shadowJar.minimize() @@ -1133,10 +1124,6 @@ class ShadowPluginSpec extends BasePluginSpecification { mainClass.set('myapp.Main') } - repositories { - mavenCentral() - } - runShadow { args 'foo' } diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/MinimizationCachingSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/MinimizationCachingSpec.groovy index 460fcc108..05c3acf12 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/MinimizationCachingSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/MinimizationCachingSpec.groovy @@ -20,7 +20,7 @@ class MinimizationCachingSpec extends AbstractCachingSpec { file('client/build.gradle') << """ apply plugin: 'java' - repositories { maven { url = "${repo.uri}" } } + dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -33,7 +33,6 @@ class MinimizationCachingSpec extends AbstractCachingSpec { apply plugin: 'java' apply plugin: 'com.gradleup.shadow' - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(':client') } """.stripIndent() @@ -61,7 +60,6 @@ class MinimizationCachingSpec extends AbstractCachingSpec { } } - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(':client') } """.stripIndent() assertShadowJarExecutes() From ca8e64ceb92dbbca43b46206d324574e33c0242f Mon Sep 17 00:00:00 2001 From: Zongle Wang Date: Wed, 25 Dec 2024 23:24:46 +0800 Subject: [PATCH 2/7] Remove unused integTest source set --- .../gradle/plugins/shadow/BasePluginSpecification.groovy | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy index 8f22b640d..f24063850 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy @@ -44,10 +44,6 @@ abstract class BasePluginSpecification extends Specification { version = "1.0" group = 'shadow' - sourceSets { - integTest - } - repositories { maven { url = "${repo.uri}" } } From eb539e91ecda9748b33c2dd27971254d1459080a Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 25 Dec 2024 23:10:03 +0800 Subject: [PATCH 3/7] Replace hardcodes and remove extra comments --- .../plugins/shadow/ApplicationSpec.groovy | 2 +- .../shadow/BasePluginSpecification.groovy | 34 ++++---- .../shadow/ConfigurationCacheSpec.groovy | 12 ++- .../ConfigureShadowRelocationSpec.groovy | 2 +- .../plugins/shadow/FilteringSpec.groovy | 64 +++++++-------- .../plugins/shadow/PublishingSpec.groovy | 6 +- .../plugins/shadow/RelocationSpec.groovy | 29 ++----- .../plugins/shadow/ShadowPluginSpec.groovy | 77 +++++++------------ .../plugins/shadow/TransformerSpec.groovy | 57 ++++---------- .../shadow/caching/AbstractCachingSpec.groovy | 2 +- .../caching/MinimizationCachingSpec.groovy | 16 ++-- .../caching/RelocationCachingSpec.groovy | 2 +- .../caching/ShadowJarCachingSpec.groovy | 14 ++-- .../caching/TransformCachingSpec.groovy | 16 ++-- 14 files changed, 134 insertions(+), 199 deletions(-) diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy index 77c888a38..9d4652cc1 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy @@ -120,7 +120,7 @@ class ApplicationSpec extends BasePluginSpecification { } rootProject.name = 'myapp' - """.stripIndent() + """.stripIndent() + getSettingsBuildScript(false) when: BuildResult result = run('runShadow') diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy index f24063850..d28d6caab 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy @@ -1,5 +1,6 @@ package com.github.jengelman.gradle.plugins.shadow +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jengelman.gradle.plugins.shadow.util.AppendableJar import com.github.jengelman.gradle.plugins.shadow.util.AppendableMavenFileRepository import org.codehaus.plexus.util.IOUtil @@ -25,32 +26,37 @@ abstract class BasePluginSpecification extends Specification { repo = repo() repo.module('junit', 'junit', '3.8.2').use(testJar).publish() - buildFile << defaultBuildScript - + buildFile << getDefaultBuildScript('java', true, true) + buildFile << System.lineSeparator() settingsFile << settingsBuildScript + settingsFile << System.lineSeparator() } def cleanup() { println buildFile.text } - String getDefaultBuildScript(String javaPlugin = 'java') { + String getDefaultBuildScript( + String javaPlugin = 'java', + boolean withGroup = false, + boolean withVersion = false + ) { + def groupInfo = withGroup ? "group = 'shadow'" : "" + def versionInfo = withVersion ? "version = '1.0'" : "" + return """ plugins { id '${javaPlugin}' id 'com.gradleup.shadow' } - version = "1.0" - group = 'shadow' - - repositories { - maven { url = "${repo.uri}" } - } - """.stripIndent() + $groupInfo + $versionInfo + """.stripIndent().trim() } - String getSettingsBuildScript() { + String getSettingsBuildScript(boolean withRootProject = true) { + def rootProjectInfo = withRootProject ? "rootProject.name = 'shadow'" : "" return """ dependencyResolutionManagement { repositories { @@ -59,10 +65,12 @@ abstract class BasePluginSpecification extends Specification { } } - rootProject.name = 'shadow' - """ + $rootProjectInfo + """.stripIndent().trim() } + static def shadowJar = "tasks.named('shadowJar', ${ShadowJar.class.name})".trim() + GradleRunner getRunner() { GradleRunner.create() .withProjectDir(dir.toFile()) diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy index 1da30fa4a..04c45d705 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy @@ -60,7 +60,7 @@ class ConfigurationCacheSpec extends BasePluginSpecification { def "configuration caching supports includes"() { given: buildFile << """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { exclude 'a2.properties' } """.stripIndent() @@ -101,10 +101,9 @@ class ConfigurationCacheSpec extends BasePluginSpecification { public class Server {} """.stripIndent() file('server/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { minimize { exclude(dependency('junit:junit:.*')) } @@ -145,14 +144,13 @@ class ConfigurationCacheSpec extends BasePluginSpecification { public class Lib {} """.stripIndent() file('lib/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript dependencies { implementation "junit:junit:3.8.2" } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { configurations = [project.configurations.compileClasspath] } diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy index 654ef5800..ab24ff0b5 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy @@ -5,7 +5,7 @@ class ConfigureShadowRelocationSpec extends BasePluginSpecification { def "auto relocate plugin dependencies"() { given: buildFile << """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { enableRelocation = true } diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy index 903586ce5..e62faa231 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy @@ -36,11 +36,9 @@ class FilteringSpec extends BasePluginSpecification { def 'exclude files'() { given: buildFile << """ - // tag::excludeFile[] - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { exclude 'a2.properties' } - // end::excludeFile[] """.stripIndent() when: @@ -63,19 +61,17 @@ class FilteringSpec extends BasePluginSpecification { .dependsOn('c') .publish() - buildFile << ''' - // tag::excludeDep[] + buildFile << """ dependencies { implementation 'shadow:d:1.0' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { dependencies { exclude(dependency('shadow:d:1.0')) } } - // end::excludeDep[] - '''.stripIndent() + """.stripIndent() when: run('shadowJar') @@ -98,19 +94,17 @@ class FilteringSpec extends BasePluginSpecification { .dependsOn('c') .publish() - buildFile << ''' - // tag::excludeDepWildcard[] + buildFile << """ dependencies { implementation 'shadow:d:1.0' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { dependencies { exclude(dependency('shadow:d:.*')) } } - // end::excludeDepWildcard[] - '''.stripIndent() + """.stripIndent() when: run('shadowJar') @@ -133,17 +127,17 @@ class FilteringSpec extends BasePluginSpecification { .dependsOn('c') .publish() - buildFile << ''' + buildFile << """ dependencies { implementation 'shadow:d:1.0' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { dependencies { exclude(dependency('shadow:d:1.0')) } } - '''.stripIndent() + """.stripIndent() when: run('shadowJar') @@ -181,17 +175,17 @@ class FilteringSpec extends BasePluginSpecification { .dependsOn('c') .publish() - buildFile << ''' + buildFile << """ dependencies { implementation 'shadow:d:1.0' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { dependencies { exclude(dependency('shadow:d:1.0')) } } - '''.stripIndent() + """.stripIndent() when: run('shadowJar') @@ -233,17 +227,17 @@ class FilteringSpec extends BasePluginSpecification { public class Passed {} '''.stripIndent() - buildFile << ''' + buildFile << """ dependencies { implementation 'shadow:d:1.0' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { dependencies { include(dependency('shadow:d:1.0')) } } - '''.stripIndent() + """.stripIndent() when: run('shadowJar') @@ -269,7 +263,7 @@ class FilteringSpec extends BasePluginSpecification { """.stripIndent() file('client/build.gradle') << """ - ${defaultBuildScript} + ${getDefaultBuildScript('java', false, true)} dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -280,19 +274,17 @@ class FilteringSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - ${defaultBuildScript} + ${getDefaultBuildScript('java', false, true)} - // tag::excludeProject[] dependencies { implementation project(':client') } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { dependencies { exclude(project(':client')) } } - // end::excludeProject[] """.stripIndent() File serverOutput = getFile('server/build/libs/server-1.0-all.jar') @@ -324,7 +316,7 @@ class FilteringSpec extends BasePluginSpecification { """.stripIndent() file('client/build.gradle') << """ - ${defaultBuildScript} + ${getDefaultBuildScript('java', false, true)} dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -335,18 +327,16 @@ class FilteringSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - ${defaultBuildScript} + ${getDefaultBuildScript('java', false, true)} dependencies { implementation project(':client') } - // tag::excludeSpec[] - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { dependencies { exclude(dependency { it.moduleGroup == 'junit' }) } } - // end::excludeSpec[] """.stripIndent() File serverOutput = getFile('server/build/libs/server-1.0-all.jar') @@ -370,13 +360,11 @@ class FilteringSpec extends BasePluginSpecification { def 'verify exclude precedence over include'() { given: buildFile << """ - // tag::excludeOverInclude[] - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { include '*.jar' include '*.properties' exclude 'a2.properties' } - // end::excludeOverInclude[] """.stripIndent() when: @@ -401,17 +389,17 @@ class FilteringSpec extends BasePluginSpecification { .dependsOn('c') .publish() - buildFile << ''' + buildFile << """ dependencies { implementation 'shadow:d:1.0' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { dependencies { exclude(dependency('shadow:d:1.0')) } } - '''.stripIndent() + """.stripIndent() when: run('shadowJar') diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy index 753ff614a..9b95a42f0 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/PublishingSpec.groovy @@ -35,7 +35,7 @@ class PublishingSpec extends BasePluginSpecification { shadow 'shadow:b:1.0' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { archiveClassifier = '' archiveBaseName = 'maven-all' } @@ -116,7 +116,7 @@ class PublishingSpec extends BasePluginSpecification { } } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { archiveClassifier = 'my-classifier' archiveExtension = 'my-ext' archiveBaseName = 'maven-all' @@ -188,7 +188,7 @@ class PublishingSpec extends BasePluginSpecification { shadow project(':b') } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { archiveClassifier = '' archiveBaseName = 'maven-all' } diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy index 0b7d9d004..ad13dc73b 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy @@ -15,7 +15,7 @@ class RelocationSpec extends BasePluginSpecification { implementation 'junit:junit:3.8.2' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { relocate 'junit.textui', 'a' relocate 'junit.framework', 'b' manifest { @@ -80,8 +80,7 @@ class RelocationSpec extends BasePluginSpecification { implementation 'junit:junit:3.8.2' } - // tag::relocateFilter[] - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { relocate('junit.textui', 'a') { exclude 'junit.textui.TestRunner' } @@ -89,7 +88,6 @@ class RelocationSpec extends BasePluginSpecification { include 'junit.framework.Test*' } } - // end::relocateFilter[] """.stripIndent() when: @@ -137,11 +135,9 @@ class RelocationSpec extends BasePluginSpecification { implementation 'junit:junit:3.8.2' } - // tag::relocate[] - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { relocate 'junit.framework', 'shadow.junit' } - // end::relocate[] """.stripIndent() file('src/main/java/shadow/ShadowTest.java') << ''' @@ -184,7 +180,6 @@ class RelocationSpec extends BasePluginSpecification { file('core/build.gradle') << """ apply plugin: 'java-library' - repositories { maven { url = "${repo.uri}" } } dependencies { api 'junit:junit:3.8.2' } """.stripIndent() @@ -200,13 +195,11 @@ class RelocationSpec extends BasePluginSpecification { and: 'App project with shadow, relocation, and project dependency' file('app/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript - repositories { maven { url = "${repo.uri}" } } dependencies { implementation project(':core') } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { relocate 'core', 'app.core' relocate 'junit.framework', 'app.junit.framework' } @@ -263,7 +256,7 @@ class RelocationSpec extends BasePluginSpecification { implementation 'shadow:dep:1.0' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { relocate 'foo', 'bar' } """.stripIndent() @@ -290,22 +283,14 @@ class RelocationSpec extends BasePluginSpecification { def "does not error on relocating java9 classes"() { given: buildFile << """ - repositories { - mavenCentral() - maven { - url = 'https://repository.mapr.com/nexus/content/groups/mapr-public/releases' - } - } - dependencies { implementation 'org.slf4j:slf4j-api:1.7.21' implementation group: 'io.netty', name: 'netty-all', version: '4.0.23.Final' implementation group: 'com.google.protobuf', name: 'protobuf-java', version: '2.5.0' implementation group: 'org.apache.zookeeper', name: 'zookeeper', version: '3.4.6' - implementation group: 'org.hbase', name: 'asynchbase', version: '1.7.0-mapr-1603' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { zip64 = true relocate 'com.google.protobuf', 'shaded.com.google.protobuf' relocate 'io.netty', 'shaded.io.netty' diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy index 3c2dc9a97..f49a0338e 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy @@ -77,7 +77,7 @@ class ShadowPluginSpec extends BasePluginSpecification { implementation files('${escapedPath(one)}') } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { mergeServiceFiles() } """.stripIndent() @@ -101,7 +101,7 @@ class ShadowPluginSpec extends BasePluginSpecification { implementation 'junit:junit:3.8.2' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { mergeServiceFiles() } """.stripIndent() @@ -118,7 +118,7 @@ class ShadowPluginSpec extends BasePluginSpecification { URL project = this.class.classLoader.getResource('test-project-1.0-SNAPSHOT.jar') buildFile << """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${artifact.path}') from('${project.path}') } @@ -141,14 +141,12 @@ class ShadowPluginSpec extends BasePluginSpecification { buildFile << """ dependencies { implementation 'junit:junit:3.8.2' } - // tag::rename[] - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { archiveBaseName = 'shadow' archiveClassifier = null archiveVersion = null archiveVersion.convention(null) } - // end::rename[] """.stripIndent() when: @@ -187,8 +185,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript dependencies { implementation project(':client') } @@ -240,10 +237,9 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { minimize() } @@ -292,10 +288,9 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { minimize { exclude(dependency('junit:junit:.*')) } @@ -344,10 +339,9 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { minimize { exclude(project(':client')) } @@ -398,10 +392,9 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { minimize { exclude(project(':client')) } @@ -450,10 +443,9 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { minimize { exclude(project(':client')) } @@ -529,10 +521,9 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('impl/build.gradle') << """ - apply plugin: 'java-library' - apply plugin: 'com.gradleup.shadow' + ${getDefaultBuildScript('java-library')} - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { minimize() } @@ -604,14 +595,12 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('impl/build.gradle') << """ - apply plugin: 'java-library' - apply plugin: 'com.gradleup.shadow' + ${getDefaultBuildScript('java-library')} - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { minimize() } - dependencies { api project(':api') } """.stripIndent() @@ -643,12 +632,11 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('client/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript dependencies { implementation 'junit:junit:3.8.2' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { relocate 'junit.framework', 'client.junit.framework' } """.stripIndent() @@ -699,12 +687,11 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('client/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript dependencies { implementation 'junit:junit:3.8.2' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { relocate 'junit.framework', 'client.junit.framework' } """.stripIndent() @@ -719,8 +706,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript dependencies { implementation project(path: ':client', configuration: 'shadow') } """.stripIndent() @@ -820,7 +806,7 @@ class ShadowPluginSpec extends BasePluginSpecification { .insertFile('runtimeOnly.properties', 'runtimeOnly') .publish() - buildFile.text = getDefaultBuildScript('java-library') + buildFile.text = getDefaultBuildScript('java-library', true, true) buildFile << """ dependencies { api 'shadow:api:1.0' @@ -913,19 +899,15 @@ class ShadowPluginSpec extends BasePluginSpecification { given: buildFile << """ - // tag::shadowConfig[] dependencies { shadow 'junit:junit:3.8.2' } - // end::shadowConfig[] - // tag::jarManifest[] jar { manifest { attributes 'Class-Path': '/libs/a.jar' } } - // end::jarManifest[] """.stripIndent() when: @@ -971,7 +953,7 @@ class ShadowPluginSpec extends BasePluginSpecification { buildFile << """ dependencies { shadow 'junit:junit:3.8.2' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { zip64 = true entryCompression = org.gradle.api.tasks.bundling.ZipEntryCompression.STORED } @@ -1013,8 +995,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('impl/build.gradle') << """ - apply plugin: 'java-library' - apply plugin: 'com.gradleup.shadow' + ${getDefaultBuildScript('java-library')} version = '1.0' @@ -1088,7 +1069,7 @@ class ShadowPluginSpec extends BasePluginSpecification { } } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { zip64 = true } @@ -1149,7 +1130,7 @@ class ShadowPluginSpec extends BasePluginSpecification { @Issue("https://github.com/GradleUp/shadow/pull/459") def 'exclude gradleApi() by default'() { given: - buildFile.text = getDefaultBuildScript('java-gradle-plugin') + buildFile.text = getDefaultBuildScript('java-gradle-plugin', true, true) file('src/main/java/my/plugin/MyPlugin.java') << """ package my.plugin; diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy index 1e3686980..b47370ecf 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy @@ -28,11 +28,9 @@ class TransformerSpec extends BasePluginSpecification { buildFile << """ import ${ServiceFileTransformer.name} - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') - } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { transform(ServiceFileTransformer) { exclude 'META-INF/services/com.acme.*' } @@ -68,11 +66,9 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() buildFile << """ import ${ServiceFileTransformer.name} - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') - } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { transform(ServiceFileTransformer) { path = 'META-INF/foo' } @@ -108,11 +104,9 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() .write() buildFile << """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') - } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { mergeServiceFiles { exclude 'META-INF/services/com.acme.*' } @@ -161,11 +155,9 @@ com.mysql.jdbc.Driver'''.stripIndent()) .write() buildFile << """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') - } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { mergeServiceFiles() relocate('org.apache', 'myapache') { exclude 'org.apache.axis.components.compiler.Jikes' @@ -213,11 +205,9 @@ org.mortbay.log.Factory'''.stripIndent() 'two # NOTE: No newline terminates this line/file').write() buildFile << """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') - } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { mergeServiceFiles('META-INF/foo') } """.stripIndent() @@ -251,7 +241,7 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() implementation files('${escapedPath(one)}') } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { mergeServiceFiles() } """.stripIndent() @@ -284,11 +274,9 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() buildFile << """ import ${AppendingTransformer.name} - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') - } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { transform(AppendingTransformer) { resource = 'test.properties' } @@ -319,11 +307,9 @@ two # NOTE: No newline terminates this line/file 'two # NOTE: No newline terminates this line/file').write() buildFile << """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') - } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { append('test.properties') } """.stripIndent() @@ -400,7 +386,7 @@ two # NOTE: No newline terminates this line/file } } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { manifest { attributes 'Test-Entry': 'PASSED' attributes 'New-Entry': 'NEW' @@ -448,12 +434,9 @@ two # NOTE: No newline terminates this line/file buildFile << """ import ${XmlAppendingTransformer.name} - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(xml1)}') from('${escapedPath(xml2)}') - } - - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { transform(XmlAppendingTransformer) { resource = 'properties.xml' } @@ -499,7 +482,7 @@ two # NOTE: No newline terminates this line/file } } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { manifest { attributes 'Test-Entry': 'PASSED' attributes 'New-Entry': 'NEW' @@ -559,7 +542,7 @@ two # NOTE: No newline terminates this line/file } } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { manifest { attributes 'Test-Entry': 'PASSED' attributes 'New-Entry': 'NEW' @@ -616,12 +599,9 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( buildFile << """ import ${GroovyExtensionModuleTransformer.name} - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') - } - - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { transform(GroovyExtensionModuleTransformer) } """.stripIndent() @@ -660,12 +640,9 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( buildFile << """ import ${GroovyExtensionModuleTransformer.name} - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') - } - - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { transform(GroovyExtensionModuleTransformer) } """.stripIndent() @@ -704,11 +681,9 @@ extensionClasses=com.acme.bar.SomeExtension,com.acme.bar.AnotherExtension staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write() buildFile << """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') - } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { mergeGroovyExtensionModules() } """.stripIndent() @@ -738,7 +713,7 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( buildFile << """ import com.github.jengelman.gradle.plugins.shadow.transformers.${transformer} - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { transform(${transformer})${configuration} } """.stripIndent() diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy index 15a08ced3..da4afc8fc 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/AbstractCachingSpec.groovy @@ -29,7 +29,7 @@ abstract class AbstractCachingSpec extends BasePluginSpecification { } void changeConfigurationTo(String content) { - buildFile.text = defaultBuildScript + buildFile.text = getDefaultBuildScript('java', true, true) buildFile << content } diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/MinimizationCachingSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/MinimizationCachingSpec.groovy index 05c3acf12..69bb06c88 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/MinimizationCachingSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/MinimizationCachingSpec.groovy @@ -2,7 +2,11 @@ package com.github.jengelman.gradle.plugins.shadow.caching class MinimizationCachingSpec extends AbstractCachingSpec { File output - String shadowJarTask = ":server:shadowJar" + + @Override + String getShadowJarTask() { + return ":server:shadowJar" + } /** * Ensure that we get a cache miss when minimization is added and that caching works with minimization @@ -30,8 +34,7 @@ class MinimizationCachingSpec extends AbstractCachingSpec { """.stripIndent() file('server/build.gradle') << """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' + $defaultBuildScript dependencies { implementation project(':client') } """.stripIndent() @@ -50,11 +53,8 @@ class MinimizationCachingSpec extends AbstractCachingSpec { ]) when: - file('server/build.gradle').text = """ - apply plugin: 'java' - apply plugin: 'com.gradleup.shadow' - - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + file('server/build.gradle') << """ + $shadowJar { minimize { exclude(dependency('junit:junit:.*')) } diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/RelocationCachingSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/RelocationCachingSpec.groovy index 9a43e7270..1fa573932 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/RelocationCachingSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/RelocationCachingSpec.groovy @@ -32,7 +32,7 @@ class RelocationCachingSpec extends AbstractCachingSpec { changeConfigurationTo """ dependencies { implementation 'junit:junit:3.8.2' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { relocate 'junit.framework', 'foo.junit.framework' } """ diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/ShadowJarCachingSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/ShadowJarCachingSpec.groovy index def98418c..0c3b4efc4 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/ShadowJarCachingSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/ShadowJarCachingSpec.groovy @@ -11,7 +11,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { URL project = this.class.classLoader.getResource('test-project-1.0-SNAPSHOT.jar') buildFile << """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${artifact.path}') from('${project.path}') } @@ -31,7 +31,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { when: changeConfigurationTo """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${artifact.path}') } """ @@ -50,7 +50,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { URL project = this.class.classLoader.getResource('test-project-1.0-SNAPSHOT.jar') buildFile << """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { from('${artifact.path}') from('${project.path}') } @@ -64,7 +64,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { when: changeConfigurationTo """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { archiveBaseName = "foo" from('${artifact.path}') from('${project.path}') @@ -85,7 +85,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { buildFile << """ dependencies { implementation 'junit:junit:3.8.2' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { exclude 'junit/*' } """.stripIndent() @@ -120,7 +120,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { changeConfigurationTo """ dependencies { implementation 'junit:junit:3.8.2' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { include 'server/*' exclude '*/Util.*' } @@ -186,7 +186,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { changeConfigurationTo """ dependencies { implementation 'junit:junit:3.8.2' } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { dependencies { exclude(dependency('junit:junit')) } diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/TransformCachingSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/TransformCachingSpec.groovy index a8507c9af..b937815c1 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/TransformCachingSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/caching/TransformCachingSpec.groovy @@ -46,7 +46,7 @@ class TransformCachingSpec extends AbstractCachingSpec { } } - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { notCompatibleWithConfigurationCache('CustomTransformer is not cacheable') transform(CustomTransformer) } @@ -95,7 +95,7 @@ class TransformCachingSpec extends AbstractCachingSpec { when: // Add a transform changeConfigurationTo """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { transform(${ServiceFileTransformer.name}) { path = 'META-INF/foo' } @@ -121,7 +121,7 @@ class TransformCachingSpec extends AbstractCachingSpec { when: // Change the transform configuration changeConfigurationTo """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { transform(${ServiceFileTransformer.name}) { path = 'META-INF/bar' } @@ -170,7 +170,7 @@ class TransformCachingSpec extends AbstractCachingSpec { when: // Add a transform changeConfigurationTo """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { transform(${AppendingTransformer.name}) { resource = 'foo/bar.properties' } @@ -200,7 +200,7 @@ class TransformCachingSpec extends AbstractCachingSpec { assert file('src/main/resources/foo/bar.properties').delete() file('src/main/resources/foo/baz.properties') << "foo=baz" changeConfigurationTo """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { transform(${AppendingTransformer.name}) { resource = 'foo/baz.properties' } @@ -251,7 +251,7 @@ class TransformCachingSpec extends AbstractCachingSpec { when: // Add a transform changeConfigurationTo """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { transform(${XmlAppendingTransformer.name}) { resource = 'foo/bar.xml' } @@ -281,7 +281,7 @@ class TransformCachingSpec extends AbstractCachingSpec { assert file('src/main/resources/foo/bar.xml').delete() file('src/main/resources/foo/baz.xml') << "baz" changeConfigurationTo """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { transform(${AppendingTransformer.name}) { resource = 'foo/baz.xml' } @@ -331,7 +331,7 @@ class TransformCachingSpec extends AbstractCachingSpec { when: // Add a transform changeConfigurationTo """ - tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) { + $shadowJar { transform(${GroovyExtensionModuleTransformer.name}) } """ From ec22e594859047d16e8f376994b1bcc0446c5f32 Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 26 Dec 2024 16:15:43 +0800 Subject: [PATCH 4/7] Replace issue links --- .../gradle/plugins/shadow/ApplicationSpec.groovy | 4 ++-- .../gradle/plugins/shadow/FilteringSpec.groovy | 8 ++++---- .../gradle/plugins/shadow/RelocationSpec.groovy | 16 +++++++++++----- .../plugins/shadow/ShadowPluginSpec.groovy | 10 +++++----- .../gradle/plugins/shadow/TransformerSpec.groovy | 9 ++++++--- 5 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy index 9d4652cc1..939e3cbb6 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ApplicationSpec.groovy @@ -152,7 +152,7 @@ class ApplicationSpec extends BasePluginSpecification { jar?.close() } - @Issue('SHADOW-89') + @Issue('https://github.com/GradleUp/shadow/issues/89') def 'shadow application distributions should use shadow jar'() { given: repo.module('shadow', 'a', '1.0') @@ -204,7 +204,7 @@ class ApplicationSpec extends BasePluginSpecification { zipFile?.close() } - @Issue('SHADOW-90') + @Issue('https://github.com/GradleUp/shadow/issues/90') def 'installShadow does not execute dependent shadow task'() { given: repo.module('shadow', 'a', '1.0') diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy index e62faa231..b365e6da2 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/FilteringSpec.groovy @@ -83,7 +83,7 @@ class FilteringSpec extends BasePluginSpecification { doesNotContain(output, ['d.properties']) } - @Issue('SHADOW-83') + @Issue('https://github.com/GradleUp/shadow/issues/83') def "exclude dependency using wildcard syntax"() { given: repo.module('shadow', 'c', '1.0') @@ -116,7 +116,7 @@ class FilteringSpec extends BasePluginSpecification { doesNotContain(output, ['d.properties']) } - @Issue("SHADOW-54") + @Issue("https://github.com/GradleUp/shadow/issues/54") def "dependency exclusions affect UP-TO-DATE check"() { given: repo.module('shadow', 'c', '1.0') @@ -164,7 +164,7 @@ class FilteringSpec extends BasePluginSpecification { doesNotContain(output, ['c.properties']) } - @Issue("SHADOW-62") + @Issue("https://github.com/GradleUp/shadow/issues/62") def "project exclusions affect UP-TO-DATE check"() { given: repo.module('shadow', 'c', '1.0') @@ -377,7 +377,7 @@ class FilteringSpec extends BasePluginSpecification { doesNotContain(output, ['a2.properties']) } - @Issue("SHADOW-69") + @Issue("https://github.com/GradleUp/shadow/issues/69") def "handle exclude with circular dependency"() { given: repo.module('shadow', 'c', '1.0') diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy index ad13dc73b..eee44d197 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy @@ -7,7 +7,7 @@ import java.util.jar.JarFile class RelocationSpec extends BasePluginSpecification { - @Issue('SHADOW-58') + @Issue('https://github.com/GradleUp/shadow/issues/58') def "relocate dependency files"() { given: buildFile << """ @@ -127,7 +127,10 @@ class RelocationSpec extends BasePluginSpecification { ]) } - @Issue(['SHADOW-55', 'SHADOW-53']) + @Issue([ + 'https://github.com/GradleUp/shadow/issues/55', + 'https://github.com/GradleUp/shadow/issues/53', + ]) def "remap class names for relocated files in project source"() { given: buildFile << """ @@ -174,7 +177,7 @@ class RelocationSpec extends BasePluginSpecification { classLoader.loadClass('shadow.ShadowTest') } - @Issue('SHADOW-61') + @Issue('https://github.com/GradleUp/shadow/issues/61') def "relocate does not drop dependency resources"() { given: 'Core project with dependency and resource' file('core/build.gradle') << """ @@ -238,7 +241,10 @@ class RelocationSpec extends BasePluginSpecification { ]) } - @Issue(['SHADOW-93', 'SHADOW-114']) + @Issue([ + 'https://github.com/GradleUp/shadow/issues/93', + 'https://github.com/GradleUp/shadow/issues/114', + ]) def "relocate resource files"() { given: repo.module('shadow', 'dep', '1.0') @@ -279,7 +285,7 @@ class RelocationSpec extends BasePluginSpecification { ]) } - @Issue("SHADOW-294") + @Issue("https://github.com/GradleUp/shadow/issues/294") def "does not error on relocating java9 classes"() { given: buildFile << """ diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy index f49a0338e..139c6d356 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ShadowPluginSpec.groovy @@ -894,7 +894,7 @@ class ShadowPluginSpec extends BasePluginSpecification { assert attributes.getValue('Class-Path') == null } - @Issue('SHADOW-65') + @Issue('https://github.com/GradleUp/shadow/issues/65') def "add shadow configuration to Class-Path in Manifest"() { given: @@ -916,7 +916,7 @@ class ShadowPluginSpec extends BasePluginSpecification { then: assert output.exists() - and: 'SHADOW-65 - combine w/ existing Class-Path' + and: 'https://github.com/GradleUp/shadow/issues/65 - combine w/ existing Class-Path' JarFile jar = new JarFile(output) Attributes attributes = jar.manifest.getMainAttributes() String classpath = attributes.getValue('Class-Path') @@ -924,7 +924,7 @@ class ShadowPluginSpec extends BasePluginSpecification { } - @Issue('SHADOW-92') + @Issue('https://github.com/GradleUp/shadow/issues/92') def "do not include null value in Class-Path when jar file does not contain Class-Path"() { given: @@ -946,7 +946,7 @@ class ShadowPluginSpec extends BasePluginSpecification { } - @Issue('SHADOW-203') + @Issue('https://github.com/GradleUp/shadow/issues/203') def "support ZipCompression.STORED"() { given: @@ -1016,7 +1016,7 @@ class ShadowPluginSpec extends BasePluginSpecification { ]) } - @Issue('SHADOW-143') + @Issue('https://github.com/GradleUp/shadow/issues/143') @Ignore("This spec requires > 15 minutes and > 8GB of disk space to run") def "check large zip files with zip64 enabled"() { given: diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy index b47370ecf..9b8990fac 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy @@ -226,7 +226,10 @@ org.mortbay.log.Factory'''.stripIndent() two # NOTE: No newline terminates this line/file'''.stripIndent() } - @Issue(['SHADOW-70', 'SHADOW-71']) + @Issue([ + 'https://github.com/GradleUp/shadow/issues/70', + 'https://github.com/GradleUp/shadow/issues/-71', + ]) def 'apply transformers to project resources'() { given: def one = buildJar('one.jar').insert('META-INF/services/shadow.Shadow', @@ -461,7 +464,7 @@ two # NOTE: No newline terminates this line/file '''.stripIndent() } - @Issue('SHADOW-82') + @Issue('https://github.com/GradleUp/shadow/issues/82') def 'shadow.manifest leaks to jar.manifest'() { given: File main = file('src/main/java/shadow/Main.java') @@ -521,7 +524,7 @@ two # NOTE: No newline terminates this line/file jis2?.close() } - @Issue('SHADOW-82') + @Issue('https://github.com/GradleUp/shadow/issues/82') def 'shadow manifest leaks to jar manifest'() { given: File main = file('src/main/java/shadow/Main.java') From fd53af6f4b065316186d6a4689a74012f351a548 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 25 Dec 2024 21:52:45 +0800 Subject: [PATCH 5/7] Remove all -s args, it's the default --- .../gradle/plugins/shadow/ConfigurationCacheSpec.groovy | 8 ++++---- .../plugins/shadow/ConfigureShadowRelocationSpec.groovy | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy index 04c45d705..2391e809d 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.groovy @@ -116,9 +116,9 @@ class ConfigurationCacheSpec extends BasePluginSpecification { def output = getFile('server/build/libs/server-all.jar') when: - run('shadowJar', '-s') + run('shadowJar') output.delete() - def result = run('shadowJar', '-s') + def result = run('shadowJar') then: output.exists() @@ -157,8 +157,8 @@ class ConfigurationCacheSpec extends BasePluginSpecification { """.stripIndent() when: - run('shadowJar', '-s') - def result = run('shadowJar', '-s') + run('shadowJar') + def result = run('shadowJar') then: result.output.contains(":lib:shadowJar UP-TO-DATE") diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy index ab24ff0b5..0c2c6dbbf 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy @@ -15,7 +15,7 @@ class ConfigureShadowRelocationSpec extends BasePluginSpecification { """.stripIndent() when: - run('shadowJar', '-s') + run('shadowJar') then: contains(output, [ From a93479a731a6648f03043ea9063fb1ca07cd43ed Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 26 Dec 2024 16:21:49 +0800 Subject: [PATCH 6/7] Enable --warning-mode=fail --- .../gradle/plugins/shadow/BasePluginSpecification.groovy | 2 +- .../jengelman/gradle/plugins/shadow/TransformerSpec.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy index d28d6caab..6b377d860 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/BasePluginSpecification.groovy @@ -80,7 +80,7 @@ abstract class BasePluginSpecification extends Specification { } GradleRunner runner(Collection tasks) { - runner.withArguments(["-Dorg.gradle.warning.mode=all", "--configuration-cache", "--stacktrace"] + tasks.toList()) + runner.withArguments(["--warning-mode=fail", "--configuration-cache", "--stacktrace"] + tasks.toList()) } BuildResult run(String... tasks) { diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy index 9b8990fac..4d5fa772d 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/TransformerSpec.groovy @@ -722,7 +722,7 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( """.stripIndent() when: - run('shadowJar', '--warning-mode=all') + run('shadowJar') then: assert output.exists() From bbdc2d954a49cf5cf396c0a2e3ab3e09f49d9e39 Mon Sep 17 00:00:00 2001 From: Goooler Date: Thu, 26 Dec 2024 16:30:47 +0800 Subject: [PATCH 7/7] Merge ConfigureShadowRelocationSpec into RelocationSpec --- .../ConfigureShadowRelocationSpec.groovy | 40 ------------------- .../plugins/shadow/RelocationSpec.groovy | 36 +++++++++++++++++ 2 files changed, 36 insertions(+), 40 deletions(-) delete mode 100644 src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy deleted file mode 100644 index 0c2c6dbbf..000000000 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/ConfigureShadowRelocationSpec.groovy +++ /dev/null @@ -1,40 +0,0 @@ -package com.github.jengelman.gradle.plugins.shadow - -class ConfigureShadowRelocationSpec extends BasePluginSpecification { - - def "auto relocate plugin dependencies"() { - given: - buildFile << """ - $shadowJar { - enableRelocation = true - } - - dependencies { - implementation 'junit:junit:3.8.2' - } - """.stripIndent() - - when: - run('shadowJar') - - then: - contains(output, [ - 'META-INF/MANIFEST.MF', - 'shadow/junit/textui/ResultPrinter.class', - 'shadow/junit/textui/TestRunner.class', - 'shadow/junit/framework/Assert.class', - 'shadow/junit/framework/AssertionFailedError.class', - 'shadow/junit/framework/ComparisonCompactor.class', - 'shadow/junit/framework/ComparisonFailure.class', - 'shadow/junit/framework/Protectable.class', - 'shadow/junit/framework/Test.class', - 'shadow/junit/framework/TestCase.class', - 'shadow/junit/framework/TestFailure.class', - 'shadow/junit/framework/TestListener.class', - 'shadow/junit/framework/TestResult$1.class', - 'shadow/junit/framework/TestResult.class', - 'shadow/junit/framework/TestSuite$1.class', - 'shadow/junit/framework/TestSuite.class' - ]) - } -} diff --git a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy index eee44d197..8eb8c4d35 100644 --- a/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy +++ b/src/funcTest/groovy/com/github/jengelman/gradle/plugins/shadow/RelocationSpec.groovy @@ -7,6 +7,42 @@ import java.util.jar.JarFile class RelocationSpec extends BasePluginSpecification { + def "auto relocate plugin dependencies"() { + given: + buildFile << """ + $shadowJar { + enableRelocation = true + } + + dependencies { + implementation 'junit:junit:3.8.2' + } + """.stripIndent() + + when: + run('shadowJar') + + then: + contains(output, [ + 'META-INF/MANIFEST.MF', + 'shadow/junit/textui/ResultPrinter.class', + 'shadow/junit/textui/TestRunner.class', + 'shadow/junit/framework/Assert.class', + 'shadow/junit/framework/AssertionFailedError.class', + 'shadow/junit/framework/ComparisonCompactor.class', + 'shadow/junit/framework/ComparisonFailure.class', + 'shadow/junit/framework/Protectable.class', + 'shadow/junit/framework/Test.class', + 'shadow/junit/framework/TestCase.class', + 'shadow/junit/framework/TestFailure.class', + 'shadow/junit/framework/TestListener.class', + 'shadow/junit/framework/TestResult$1.class', + 'shadow/junit/framework/TestResult.class', + 'shadow/junit/framework/TestSuite$1.class', + 'shadow/junit/framework/TestSuite.class' + ]) + } + @Issue('https://github.com/GradleUp/shadow/issues/58') def "relocate dependency files"() { given: