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 6b377d860..8ac09974d 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 @@ -3,6 +3,7 @@ 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.apache.commons.lang3.StringUtils import org.codehaus.plexus.util.IOUtil import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.GradleRunner @@ -18,25 +19,25 @@ import java.util.jar.JarFile abstract class BasePluginSpecification extends Specification { @TempDir - Path dir + Path root AppendableMavenFileRepository repo def setup() { repo = repo() - repo.module('junit', 'junit', '3.8.2').use(testJar).publish() + repo.module('junit', 'junit', '3.8.2') + .use(Paths.get(this.class.classLoader.getResource('junit-3.8.2.jar').toURI())) + .publish() - buildFile << getDefaultBuildScript('java', true, true) - buildFile << System.lineSeparator() - settingsFile << settingsBuildScript - settingsFile << System.lineSeparator() + projectScriptFile << getDefaultProjectBuildScript('java', true, true) + settingsScriptFile << getDefaultSettingsBuildScript() } def cleanup() { - println buildFile.text + println projectScriptFile.text } - String getDefaultBuildScript( + String getDefaultProjectBuildScript( String javaPlugin = 'java', boolean withGroup = false, boolean withVersion = false @@ -52,10 +53,10 @@ abstract class BasePluginSpecification extends Specification { $groupInfo $versionInfo - """.stripIndent().trim() + """.stripIndent().trim() + System.lineSeparator() } - String getSettingsBuildScript(boolean withRootProject = true) { + String getDefaultSettingsBuildScript(boolean withRootProject = true) { def rootProjectInfo = withRootProject ? "rootProject.name = 'shadow'" : "" return """ dependencyResolutionManagement { @@ -66,14 +67,14 @@ abstract class BasePluginSpecification extends Specification { } $rootProjectInfo - """.stripIndent().trim() + """.stripIndent().trim() + System.lineSeparator() } static def shadowJar = "tasks.named('shadowJar', ${ShadowJar.class.name})".trim() GradleRunner getRunner() { GradleRunner.create() - .withProjectDir(dir.toFile()) + .withProjectDir(root.toFile()) .forwardOutput() .withPluginClasspath() .withTestKitDir(testKitDir) @@ -93,37 +94,40 @@ abstract class BasePluginSpecification 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) return result } - static void assertNoDeprecationWarnings(BuildResult result) { + private static void assertNoDeprecationWarnings(BuildResult result) { result.output.eachLine { assert !containsDeprecationWarning(it) } } - static boolean containsDeprecationWarning(String output) { + private 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") } - File getBuildFile() { + File getProjectScriptFile() { file('build.gradle') } - File getSettingsFile() { + File getSettingsScriptFile() { file('settings.gradle') } File file(String path) { - File f = dir.resolve(path).toFile() + File f = root.resolve(path).toFile() + String extension = StringUtils.substringAfterLast(path, '.') + + // Binary files should be asserted to exist, text files should be created. + if (extension == "jar" || extension == "zip") { + return f + } + if (!f.exists()) { f.parentFile.mkdirs() if (!f.createNewFile()) { @@ -133,16 +137,8 @@ abstract class BasePluginSpecification extends Specification { return f } - File getFile(String path) { - return dir.resolve(path).toFile() - } - AppendableMavenFileRepository repo(String path = 'maven-repo') { - new AppendableMavenFileRepository(dir.resolve(path)) - } - - void assertJarFileContentsEqual(File f, String path, String contents) { - assert getJarFileContents(f, path) == contents + new AppendableMavenFileRepository(root.resolve(path)) } String getJarFileContents(File f, String path) { @@ -155,7 +151,7 @@ abstract class BasePluginSpecification extends Specification { return sw.toString() } - void contains(File f, List paths) { + void assertContains(File f, List paths) { JarFile jar = new JarFile(f) paths.each { path -> assert jar.getJarEntry(path), "${f.path} does not contain [$path]" @@ -163,7 +159,7 @@ abstract class BasePluginSpecification extends Specification { jar.close() } - void doesNotContain(File f, List paths) { + void assertDoesNotContain(File f, List paths) { JarFile jar = new JarFile(f) paths.each { path -> assert !jar.getJarEntry(path), "${f.path} contains [$path]" @@ -184,19 +180,11 @@ abstract class BasePluginSpecification extends Specification { return new AppendableJar(file(path).toPath()) } - protected File getOutput() { - getFile('build/libs/shadow-1.0-all.jar') - } - - protected File output(String name) { - getFile("build/libs/${name}") - } - - protected Path getTestJar(String name = 'junit-3.8.2.jar') { - return Paths.get(this.class.classLoader.getResource(name).toURI()) + File getOutputShadowJar() { + file('build/libs/shadow-1.0-all.jar') } - protected static File getTestKitDir() { + static File getTestKitDir() { def gradleUserHome = System.getenv("GRADLE_USER_HOME") if (!gradleUserHome) { gradleUserHome = new File(System.getProperty("user.home"), ".gradle").absolutePath @@ -204,7 +192,7 @@ abstract class BasePluginSpecification extends Specification { return new File(gradleUserHome, "testkit") } - protected static String escapedPath(Path path) { + static String escapedPath(Path path) { return path.toString().replaceAll('\\\\', '\\\\\\\\') } } 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 9b95a42f0..08e9b8170 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 @@ -26,8 +26,8 @@ class PublishingSpec extends BasePluginSpecification { .insertFile('b.properties', 'b') .publish() - settingsFile << "rootProject.name = 'maven'" - buildFile << """ + settingsScriptFile << "rootProject.name = 'maven'" + projectScriptFile << """ apply plugin: 'maven-publish' dependencies { @@ -63,7 +63,7 @@ class PublishingSpec extends BasePluginSpecification { assert publishedFile.exists() and: - contains(publishedFile, ['a.properties', 'a2.properties']) + assertContains(publishedFile, ['a.properties', 'a2.properties']) and: File pom = publishingRepo.rootDir.resolve('shadow/maven-all/1.0/maven-all-1.0.pom').toFile().canonicalFile @@ -93,8 +93,8 @@ class PublishingSpec extends BasePluginSpecification { .insertFile('b.properties', 'b') .publish() - settingsFile << "rootProject.name = 'maven'" - buildFile << """ + settingsScriptFile << "rootProject.name = 'maven'" + projectScriptFile << """ apply plugin: 'maven-publish' dependencies { @@ -134,14 +134,14 @@ class PublishingSpec extends BasePluginSpecification { def "publish multiproject shadow jar with maven-publish plugin"() { given: - settingsFile << """ + settingsScriptFile << """ rootProject.name = 'maven' include 'a' include 'b' include 'c' """.stripMargin() - buildFile.text = """ + projectScriptFile.text = """ subprojects { apply plugin: 'java' apply plugin: 'maven-publish' @@ -211,7 +211,7 @@ class PublishingSpec extends BasePluginSpecification { assert publishedFile.exists() and: - contains(publishedFile, ['a.properties', 'a2.properties']) + assertContains(publishedFile, ['a.properties', 'a2.properties']) and: File pom = publishingRepo.rootDir.resolve('shadow/maven-all/1.0/maven-all-1.0.pom').toFile().canonicalFile @@ -237,10 +237,10 @@ class PublishingSpec extends BasePluginSpecification { .insertFile('b.properties', 'b') .publish() - settingsFile << """ + settingsScriptFile << """ rootProject.name = 'maven' """ - buildFile << """ + projectScriptFile << """ apply plugin: 'maven-publish' dependencies { implementation 'shadow:a:1.0' @@ -277,7 +277,7 @@ class PublishingSpec extends BasePluginSpecification { assert shadowJar.exists() and: - contains(shadowJar, ['a.properties', 'a2.properties']) + assertContains(shadowJar, ['a.properties', 'a2.properties']) and: "publishes both a POM file and a Gradle metadata file" File pom = publishingRepo.rootDir.resolve('com/acme/maven/1.0/maven-1.0.pom').toFile().canonicalFile @@ -328,7 +328,7 @@ class PublishingSpec extends BasePluginSpecification { assertions { shadowJar = publishingRepo.rootDir.resolve('com/acme/maven-all/1.0/maven-all-1.0-all.jar').toFile().canonicalFile assert shadowJar.exists() - contains(shadowJar, ['a.properties', 'a2.properties']) + assertContains(shadowJar, ['a.properties', 'a2.properties']) } assertions { 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 139c6d356..5117778e4 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 @@ -71,7 +71,7 @@ class ShadowPluginSpec extends BasePluginSpecification { repo.module('shadow', 'two', '1.0').insertFile('META-INF/services/shadow.Shadow', 'two # NOTE: No newline terminates this line/file').publish() - buildFile << """ + projectScriptFile << """ dependencies { implementation 'junit:junit:3.8.2' implementation files('${escapedPath(one)}') @@ -88,7 +88,7 @@ class ShadowPluginSpec extends BasePluginSpecification { } then: - assert output.exists() + assert outputShadowJar.exists() where: version << ['8.3'] @@ -96,7 +96,7 @@ class ShadowPluginSpec extends BasePluginSpecification { def 'Error in Gradle versions < 8.3'() { given: - buildFile << """ + projectScriptFile << """ dependencies { implementation 'junit:junit:3.8.2' } @@ -117,7 +117,7 @@ class ShadowPluginSpec extends BasePluginSpecification { URL artifact = this.class.classLoader.getResource('test-artifact-1.0-SNAPSHOT.jar') URL project = this.class.classLoader.getResource('test-project-1.0-SNAPSHOT.jar') - buildFile << """ + projectScriptFile << """ $shadowJar { from('${artifact.path}') from('${project.path}') @@ -128,7 +128,7 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() } def 'include project sources'() { @@ -138,7 +138,7 @@ class ShadowPluginSpec extends BasePluginSpecification { public class Passed {} '''.stripIndent() - buildFile << """ + projectScriptFile << """ dependencies { implementation 'junit:junit:3.8.2' } $shadowJar { @@ -153,10 +153,10 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - contains(output("shadow.jar"), ['shadow/Passed.class', 'junit/framework/Test.class']) + assertContains(file("build/libs/shadow.jar"), ['shadow/Passed.class', 'junit/framework/Test.class']) and: - doesNotContain(output("shadow.jar"), ['/']) + assertDoesNotContain(file("build/libs/shadow.jar"), ['/']) } def 'include project dependencies'() { @@ -185,20 +185,20 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - $defaultBuildScript + $defaultProjectBuildScript dependencies { implementation project(':client') } """.stripIndent() - File serverOutput = getFile('server/build/libs/server-all.jar') + File serverOutput = file('server/build/libs/server-all.jar') when: run(':server:shadowJar') then: serverOutput.exists() - contains(serverOutput, [ + assertContains(serverOutput, [ 'client/Client.class', 'server/Server.class', 'junit/framework/Test.class' @@ -237,7 +237,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - $defaultBuildScript + $defaultProjectBuildScript $shadowJar { minimize() @@ -246,18 +246,18 @@ class ShadowPluginSpec extends BasePluginSpecification { dependencies { implementation project(':client') } """.stripIndent() - File serverOutput = getFile('server/build/libs/server-all.jar') + File serverOutput = file('server/build/libs/server-all.jar') when: - runWithDebug(':server:shadowJar') + run(':server:shadowJar') then: serverOutput.exists() - contains(serverOutput, [ + assertContains(serverOutput, [ 'client/Client.class', 'server/Server.class' ]) - doesNotContain(serverOutput, ['junit/framework/Test.class']) + assertDoesNotContain(serverOutput, ['junit/framework/Test.class']) } /** @@ -288,7 +288,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - $defaultBuildScript + $defaultProjectBuildScript $shadowJar { minimize { @@ -299,18 +299,18 @@ class ShadowPluginSpec extends BasePluginSpecification { dependencies { implementation project(':client') } """.stripIndent() - File serverOutput = getFile('server/build/libs/server-all.jar') + File serverOutput = file('server/build/libs/server-all.jar') when: - runWithDebug(':server:shadowJar') + run(':server:shadowJar') then: serverOutput.exists() - contains(serverOutput, [ + assertContains(serverOutput, [ 'server/Server.class', 'junit/framework/Test.class' ]) - doesNotContain(serverOutput, ['client/Client.class']) + assertDoesNotContain(serverOutput, ['client/Client.class']) } /** @@ -339,7 +339,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - $defaultBuildScript + $defaultProjectBuildScript $shadowJar { minimize { @@ -353,10 +353,10 @@ class ShadowPluginSpec extends BasePluginSpecification { File serverOutput = file('server/build/libs/server-all.jar') when: - runWithDebug(':server:shadowJar') + run(':server:shadowJar') then: - contains(serverOutput, [ + assertContains(serverOutput, [ 'client/Client.class', 'server/Server.class' ]) @@ -392,7 +392,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - $defaultBuildScript + $defaultProjectBuildScript $shadowJar { minimize { @@ -406,10 +406,10 @@ class ShadowPluginSpec extends BasePluginSpecification { File serverOutput = file('server/build/libs/server-all.jar') when: - runWithDebug(':server:shadowJar') + run(':server:shadowJar') then: - contains(serverOutput, [ + assertContains(serverOutput, [ 'client/Client.class', 'server/Server.class', 'junit/framework/TestCase.class' @@ -443,7 +443,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - $defaultBuildScript + $defaultProjectBuildScript $shadowJar { minimize { @@ -457,10 +457,10 @@ class ShadowPluginSpec extends BasePluginSpecification { File serverOutput = file('server/build/libs/server-all.jar') when: - runWithDebug(':server:shadowJar') + run(':server:shadowJar') then: - contains(serverOutput, [ + assertContains(serverOutput, [ 'client/Client.class', 'server/Server.class', 'junit/framework/TestCase.class' @@ -521,7 +521,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('impl/build.gradle') << """ - ${getDefaultBuildScript('java-library')} + ${getDefaultProjectBuildScript('java-library')} $shadowJar { minimize() @@ -530,20 +530,20 @@ class ShadowPluginSpec extends BasePluginSpecification { dependencies { api project(':api') } """.stripIndent() - File serverOutput = getFile('impl/build/libs/impl-all.jar') + File serverOutput = file('impl/build/libs/impl-all.jar') when: - runWithDebug(':impl:shadowJar') + run(':impl:shadowJar') then: serverOutput.exists() - contains(serverOutput, [ + assertContains(serverOutput, [ 'impl/SimpleEntity.class', 'api/Entity.class', 'api/UnusedEntity.class', 'lib/LibEntity.class', ]) - doesNotContain(serverOutput, ['junit/framework/Test.class', 'lib/UnusedLibEntity.class']) + assertDoesNotContain(serverOutput, ['junit/framework/Test.class', 'lib/UnusedLibEntity.class']) } /** @@ -595,7 +595,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('impl/build.gradle') << """ - ${getDefaultBuildScript('java-library')} + ${getDefaultProjectBuildScript('java-library')} $shadowJar { minimize() @@ -604,14 +604,14 @@ class ShadowPluginSpec extends BasePluginSpecification { dependencies { api project(':api') } """.stripIndent() - File serverOutput = getFile('impl/build/libs/impl-all.jar') + File serverOutput = file('impl/build/libs/impl-all.jar') when: - runWithDebug(':impl:shadowJar') + run(':impl:shadowJar') then: serverOutput.exists() - contains(serverOutput, [ + assertContains(serverOutput, [ 'impl/SimpleEntity.class', 'api/Entity.class', 'api/UnusedEntity.class', @@ -632,7 +632,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('client/build.gradle') << """ - $defaultBuildScript + $defaultProjectBuildScript dependencies { implementation 'junit:junit:3.8.2' } @@ -656,19 +656,19 @@ class ShadowPluginSpec extends BasePluginSpecification { dependencies { implementation project(path: ':client', configuration: 'shadow') } """.stripIndent() - File serverOutput = getFile('server/build/libs/server.jar') + File serverOutput = file('server/build/libs/server.jar') when: run(':server:jar') then: serverOutput.exists() - contains(serverOutput, [ + assertContains(serverOutput, [ 'server/Server.class' ]) and: - doesNotContain(serverOutput, [ + assertDoesNotContain(serverOutput, [ 'client/Client.class', 'junit/framework/Test.class', 'client/junit/framework/Test.class' @@ -687,7 +687,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('client/build.gradle') << """ - $defaultBuildScript + $defaultProjectBuildScript dependencies { implementation 'junit:junit:3.8.2' } @@ -706,26 +706,26 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('server/build.gradle') << """ - $defaultBuildScript + $defaultProjectBuildScript dependencies { implementation project(path: ':client', configuration: 'shadow') } """.stripIndent() - File serverOutput = getFile('server/build/libs/server-all.jar') + File serverOutput = file('server/build/libs/server-all.jar') when: run(':server:shadowJar') then: serverOutput.exists() - contains(serverOutput, [ + assertContains(serverOutput, [ 'client/Client.class', 'client/junit/framework/Test.class', 'server/Server.class', ]) and: - doesNotContain(serverOutput, [ + assertDoesNotContain(serverOutput, [ 'junit/framework/Test.class' ]) } @@ -746,7 +746,7 @@ class ShadowPluginSpec extends BasePluginSpecification { public class Passed {} '''.stripIndent() - buildFile << """ + projectScriptFile << """ dependencies { implementation 'shadow:a:1.0' } """.stripIndent() @@ -754,10 +754,10 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - contains(output, ['a.properties', 'META-INF/a.properties']) + assertContains(outputShadowJar, ['a.properties', 'META-INF/a.properties']) and: - doesNotContain(output, ['META-INF/INDEX.LIST', 'META-INF/a.SF', 'META-INF/a.DSA', 'META-INF/a.RSA']) + assertDoesNotContain(outputShadowJar, ['META-INF/INDEX.LIST', 'META-INF/a.SF', 'META-INF/a.DSA', 'META-INF/a.RSA']) } def "include runtime configuration by default"() { @@ -770,7 +770,7 @@ class ShadowPluginSpec extends BasePluginSpecification { .insertFile('b.properties', 'b') .publish() - buildFile << """ + projectScriptFile << """ dependencies { runtimeOnly 'shadow:a:1.0' shadow 'shadow:b:1.0' @@ -781,10 +781,10 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - contains(output, ['a.properties']) + assertContains(outputShadowJar, ['a.properties']) and: - doesNotContain(output, ['b.properties']) + assertDoesNotContain(outputShadowJar, ['b.properties']) } def "include java-library configurations by default"() { @@ -806,8 +806,8 @@ class ShadowPluginSpec extends BasePluginSpecification { .insertFile('runtimeOnly.properties', 'runtimeOnly') .publish() - buildFile.text = getDefaultBuildScript('java-library', true, true) - buildFile << """ + projectScriptFile.text = getDefaultProjectBuildScript('java-library', true, true) + projectScriptFile << """ dependencies { api 'shadow:api:1.0' implementation 'shadow:implementation:1.0' @@ -816,11 +816,11 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() when: - runWithDebug('shadowJar') + run('shadowJar') then: - contains(output, ['api.properties', 'implementation.properties', - 'runtimeOnly.properties', 'implementation-dep.properties']) + assertContains(outputShadowJar, ['api.properties', 'implementation.properties', + 'runtimeOnly.properties', 'implementation-dep.properties']) } def "doesn't include compileOnly configuration by default"() { @@ -833,7 +833,7 @@ class ShadowPluginSpec extends BasePluginSpecification { .insertFile('b.properties', 'b') .publish() - buildFile << """ + projectScriptFile << """ dependencies { runtimeOnly 'shadow:a:1.0' compileOnly 'shadow:b:1.0' @@ -844,10 +844,10 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - contains(output, ['a.properties']) + assertContains(outputShadowJar, ['a.properties']) and: - doesNotContain(output, ['b.properties']) + assertDoesNotContain(outputShadowJar, ['b.properties']) } def "default copying strategy"() { @@ -860,7 +860,7 @@ class ShadowPluginSpec extends BasePluginSpecification { .insertFile('META-INF/MANIFEST.MF', 'MANIFEST B') .publish() - buildFile << """ + projectScriptFile << """ dependencies { runtimeOnly 'shadow:a:1.0' runtimeOnly 'shadow:b:1.0' @@ -871,14 +871,14 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - JarFile jar = new JarFile(output) + JarFile jar = new JarFile(outputShadowJar) assert jar.entries().collect().size() == 2 } def "Class-Path in Manifest not added if empty"() { given: - buildFile << """ + projectScriptFile << """ dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -886,10 +886,10 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - JarFile jar = new JarFile(output) + JarFile jar = new JarFile(outputShadowJar) Attributes attributes = jar.manifest.getMainAttributes() assert attributes.getValue('Class-Path') == null } @@ -898,7 +898,7 @@ class ShadowPluginSpec extends BasePluginSpecification { def "add shadow configuration to Class-Path in Manifest"() { given: - buildFile << """ + projectScriptFile << """ dependencies { shadow 'junit:junit:3.8.2' } @@ -914,10 +914,10 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: 'https://github.com/GradleUp/shadow/issues/65 - combine w/ existing Class-Path' - JarFile jar = new JarFile(output) + JarFile jar = new JarFile(outputShadowJar) Attributes attributes = jar.manifest.getMainAttributes() String classpath = attributes.getValue('Class-Path') assert classpath == '/libs/a.jar junit-3.8.2.jar' @@ -928,7 +928,7 @@ class ShadowPluginSpec extends BasePluginSpecification { def "do not include null value in Class-Path when jar file does not contain Class-Path"() { given: - buildFile << """ + projectScriptFile << """ dependencies { shadow 'junit:junit:3.8.2' } """.stripIndent() @@ -936,10 +936,10 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - JarFile jar = new JarFile(output) + JarFile jar = new JarFile(outputShadowJar) Attributes attributes = jar.manifest.getMainAttributes() String classpath = attributes.getValue('Class-Path') assert classpath == 'junit-3.8.2.jar' @@ -950,7 +950,7 @@ class ShadowPluginSpec extends BasePluginSpecification { def "support ZipCompression.STORED"() { given: - buildFile << """ + projectScriptFile << """ dependencies { shadow 'junit:junit:3.8.2' } $shadowJar { @@ -963,7 +963,7 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() } @@ -995,7 +995,7 @@ class ShadowPluginSpec extends BasePluginSpecification { """.stripIndent() file('impl/build.gradle') << """ - ${getDefaultBuildScript('java-library')} + ${getDefaultProjectBuildScript('java-library')} version = '1.0' @@ -1004,14 +1004,14 @@ class ShadowPluginSpec extends BasePluginSpecification { shadowJar.minimize() """.stripIndent() - File serverOutput = getFile('impl/build/libs/impl-1.0-all.jar') + File serverOutput = file('impl/build/libs/impl-1.0-all.jar') when: - runWithDebug(':impl:shadowJar') + run(':impl:shadowJar') then: serverOutput.exists() - contains(serverOutput, [ + assertContains(serverOutput, [ 'api/UnusedEntity.class', ]) } @@ -1034,7 +1034,7 @@ class ShadowPluginSpec extends BasePluginSpecification { } """.stripIndent() - buildFile << """ + projectScriptFile << """ apply plugin: 'application' application { @@ -1078,7 +1078,7 @@ class ShadowPluginSpec extends BasePluginSpecification { } """.stripIndent() - settingsFile << "rootProject.name = 'myapp'" + settingsScriptFile << "rootProject.name = 'myapp'" when: BuildResult result = run('runShadow') @@ -1092,9 +1092,9 @@ class ShadowPluginSpec extends BasePluginSpecification { @Issue("https://github.com/GradleUp/shadow/issues/609") def "doesn't error when using application mainClass property"() { given: - buildFile.text = defaultBuildScript + projectScriptFile.text = getDefaultProjectBuildScript() - buildFile << """ + projectScriptFile << """ project.ext { aspectjVersion = '1.8.12' } @@ -1130,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', true, true) + projectScriptFile.text = getDefaultProjectBuildScript('java-gradle-plugin', true, true) file('src/main/java/my/plugin/MyPlugin.java') << """ package my.plugin; @@ -1150,16 +1150,16 @@ class ShadowPluginSpec extends BasePluginSpecification { run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - JarFile jar = new JarFile(output) + JarFile jar = new JarFile(outputShadowJar) assert jar.entries().collect().findAll { it.name.endsWith('.class') }.size() == 1 } @Issue("https://github.com/GradleUp/shadow/issues/1070") def 'can register a custom shadow jar task'() { - buildFile << """ + projectScriptFile << """ dependencies { testImplementation 'junit:junit:3.8.2' } @@ -1181,7 +1181,7 @@ class ShadowPluginSpec extends BasePluginSpecification { assert result.task(":testShadowJar").outcome == TaskOutcome.SUCCESS and: - def jarFile = new JarFile(output("shadow-1.0-tests.jar")) + def jarFile = new JarFile(file("build/libs/shadow-1.0-tests.jar")) assert jarFile.getEntry('junit') != null } } 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 4d5fa772d..f9c5d3cd8 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 @@ -26,7 +26,7 @@ class TransformerSpec extends BasePluginSpecification { .insert('META-INF/services/com.acme.Foo', 'two') .write() - buildFile << """ + projectScriptFile << """ import ${ServiceFileTransformer.name} $shadowJar { from('${escapedPath(one)}') @@ -41,17 +41,17 @@ class TransformerSpec extends BasePluginSpecification { run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - String text1 = getJarFileContents(output, 'META-INF/services/org.apache.maven.Shade') + String text1 = getJarFileContents(outputShadowJar, 'META-INF/services/org.apache.maven.Shade') assert text1.split("\\r?\\n").size() == 2 assert text1 == '''one # NOTE: No newline terminates this line/file two # NOTE: No newline terminates this line/file'''.stripIndent() and: - String text2 = getJarFileContents(output, 'META-INF/services/com.acme.Foo') + String text2 = getJarFileContents(outputShadowJar, 'META-INF/services/com.acme.Foo') assert text2.split("\\r?\\n").size() == 1 assert text2 == 'one' } @@ -64,7 +64,7 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() def two = buildJar('two.jar').insert('META-INF/foo/org.apache.maven.Shade', 'two # NOTE: No newline terminates this line/file').write() - buildFile << """ + projectScriptFile << """ import ${ServiceFileTransformer.name} $shadowJar { from('${escapedPath(one)}') @@ -79,10 +79,10 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - String text = getJarFileContents(output, 'META-INF/foo/org.apache.maven.Shade') + String text = getJarFileContents(outputShadowJar, 'META-INF/foo/org.apache.maven.Shade') assert text.split("\\r?\\n").size() == 2 assert text == '''one # NOTE: No newline terminates this line/file @@ -103,7 +103,7 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() .insert('META-INF/services/com.acme.Foo', 'two') .write() - buildFile << """ + projectScriptFile << """ $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') @@ -117,17 +117,17 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - String text1 = getJarFileContents(output, 'META-INF/services/org.apache.maven.Shade') + String text1 = getJarFileContents(outputShadowJar, 'META-INF/services/org.apache.maven.Shade') assert text1.split("\\r?\\n").size() == 2 assert text1 == '''one # NOTE: No newline terminates this line/file two # NOTE: No newline terminates this line/file'''.stripIndent() and: - String text2 = getJarFileContents(output, 'META-INF/services/com.acme.Foo') + String text2 = getJarFileContents(outputShadowJar, 'META-INF/services/com.acme.Foo') assert text2.split("\\r?\\n").size() == 1 assert text2 == 'one' } @@ -154,7 +154,7 @@ com.mysql.jdbc.Driver'''.stripIndent()) 'org.mortbay.log.Factory') .write() - buildFile << """ + projectScriptFile << """ $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') @@ -170,10 +170,10 @@ com.mysql.jdbc.Driver'''.stripIndent()) run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - String text1 = getJarFileContents(output, 'META-INF/services/java.sql.Driver') + String text1 = getJarFileContents(outputShadowJar, 'META-INF/services/java.sql.Driver') assert text1.split("\\r?\\n").size() == 4 assert text1 == '''oracle.jdbc.OracleDriver @@ -182,14 +182,14 @@ myapache.derby.jdbc.AutoloadedDriver com.mysql.jdbc.Driver'''.stripIndent() and: - String text2 = getJarFileContents(output, 'META-INF/services/myapache.axis.components.compiler.Compiler') + String text2 = getJarFileContents(outputShadowJar, 'META-INF/services/myapache.axis.components.compiler.Compiler') assert text2.split("\\r?\\n").size() == 2 assert text2 == '''myapache.axis.components.compiler.Javac org.apache.axis.components.compiler.Jikes'''.stripIndent() and: - String text3 = getJarFileContents(output, 'META-INF/services/org.apache.commons.logging.LogFactory') + String text3 = getJarFileContents(outputShadowJar, 'META-INF/services/org.apache.commons.logging.LogFactory') assert text3.split("\\r?\\n").size() == 2 assert text3 == '''myapache.commons.logging.impl.LogFactoryImpl @@ -204,7 +204,7 @@ org.mortbay.log.Factory'''.stripIndent() def two = buildJar('two.jar').insert('META-INF/foo/org.apache.maven.Shade', 'two # NOTE: No newline terminates this line/file').write() - buildFile << """ + projectScriptFile << """ $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') @@ -216,10 +216,10 @@ org.mortbay.log.Factory'''.stripIndent() run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - String text = getJarFileContents(output, 'META-INF/foo/org.apache.maven.Shade') + String text = getJarFileContents(outputShadowJar, 'META-INF/foo/org.apache.maven.Shade') assert text.split("\\r?\\n").size() == 2 assert text == '''one # NOTE: No newline terminates this line/file @@ -238,7 +238,7 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() repo.module('shadow', 'two', '1.0').insertFile('META-INF/services/shadow.Shadow', 'two # NOTE: No newline terminates this line/file').publish() - buildFile << """ + projectScriptFile << """ dependencies { implementation 'shadow:two:1.0' implementation files('${escapedPath(one)}') @@ -256,10 +256,10 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - String text = getJarFileContents(output, 'META-INF/services/shadow.Shadow') + String text = getJarFileContents(outputShadowJar, 'META-INF/services/shadow.Shadow') assert text.split("\\r?\\n").size() == 3 assert text == '''three # NOTE: No newline terminates this line/file @@ -275,7 +275,7 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() def two = buildJar('two.jar').insert('test.properties', 'two # NOTE: No newline terminates this line/file').write() - buildFile << """ + projectScriptFile << """ import ${AppendingTransformer.name} $shadowJar { from('${escapedPath(one)}') @@ -290,10 +290,10 @@ two # NOTE: No newline terminates this line/file'''.stripIndent() run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - String text = getJarFileContents(output, 'test.properties') + String text = getJarFileContents(outputShadowJar, 'test.properties') assert text.split("\\r?\\n").size() == 2 assert text == '''one # NOTE: No newline terminates this line/file @@ -309,7 +309,7 @@ two # NOTE: No newline terminates this line/file def two = buildJar('two.jar').insert('test.properties', 'two # NOTE: No newline terminates this line/file').write() - buildFile << """ + projectScriptFile << """ $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') @@ -321,10 +321,10 @@ two # NOTE: No newline terminates this line/file run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - String text = getJarFileContents(output, 'test.properties') + String text = getJarFileContents(outputShadowJar, 'test.properties') assert text.split("\\r?\\n").size() == 2 assert text == '''one # NOTE: No newline terminates this line/file @@ -344,7 +344,7 @@ two # NOTE: No newline terminates this line/file } '''.stripIndent() - buildFile << """ + projectScriptFile << """ jar { manifest { attributes 'Main-Class': 'shadow.Main' @@ -357,10 +357,10 @@ two # NOTE: No newline terminates this line/file run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - JarInputStream jis = new JarInputStream(output.newInputStream()) + JarInputStream jis = new JarInputStream(outputShadowJar.newInputStream()) Manifest mf = jis.manifest jis.close() @@ -381,7 +381,7 @@ two # NOTE: No newline terminates this line/file } '''.stripIndent() - buildFile << """ + projectScriptFile << """ jar { manifest { attributes 'Main-Class': 'shadow.Main' @@ -401,10 +401,10 @@ two # NOTE: No newline terminates this line/file run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - JarInputStream jis = new JarInputStream(output.newInputStream()) + JarInputStream jis = new JarInputStream(outputShadowJar.newInputStream()) Manifest mf = jis.manifest jis.close() @@ -434,7 +434,7 @@ two # NOTE: No newline terminates this line/file '''.stripIndent() ).write() - buildFile << """ + projectScriptFile << """ import ${XmlAppendingTransformer.name} $shadowJar { @@ -450,10 +450,10 @@ two # NOTE: No newline terminates this line/file run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - String text = getJarFileContents(output, 'properties.xml') + String text = getJarFileContents(outputShadowJar, 'properties.xml') assert text.replaceAll('\r\n', '\n') == ''' @@ -477,7 +477,7 @@ two # NOTE: No newline terminates this line/file } '''.stripIndent() - buildFile << """ + projectScriptFile << """ jar { manifest { attributes 'Main-Class': 'shadow.Main' @@ -497,12 +497,12 @@ two # NOTE: No newline terminates this line/file run('jar', 'shadowJar') then: - File jar = getFile('build/libs/shadow-1.0.jar') + File jar = file('build/libs/shadow-1.0.jar') assert jar.exists() - assert output.exists() + assert outputShadowJar.exists() then: 'Check contents of Shadow jar manifest' - JarInputStream jis = new JarInputStream(output.newInputStream()) + JarInputStream jis = new JarInputStream(outputShadowJar.newInputStream()) Manifest mf = jis.manifest assert mf @@ -537,7 +537,7 @@ two # NOTE: No newline terminates this line/file } '''.stripIndent() - buildFile << """ + projectScriptFile << """ jar { manifest { attributes 'Main-Class': 'shadow.Main' @@ -557,12 +557,12 @@ two # NOTE: No newline terminates this line/file run('jar', 'shadowJar') then: - File jar = getFile('build/libs/shadow-1.0.jar') + File jar = file('build/libs/shadow-1.0.jar') assert jar.exists() - assert output.exists() + assert outputShadowJar.exists() then: 'Check contents of Shadow jar manifest' - JarInputStream jis = new JarInputStream(output.newInputStream()) + JarInputStream jis = new JarInputStream(outputShadowJar.newInputStream()) Manifest mf = jis.manifest assert mf @@ -600,7 +600,7 @@ moduleVersion=2.3.5 extensionClasses=com.acme.bar.SomeExtension,com.acme.bar.AnotherExtension staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write() - buildFile << """ + projectScriptFile << """ import ${GroovyExtensionModuleTransformer.name} $shadowJar { from('${escapedPath(one)}') @@ -613,10 +613,10 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - def text = getJarFileContents(output, 'META-INF/services/org.codehaus.groovy.runtime.ExtensionModule') + def text = getJarFileContents(outputShadowJar, 'META-INF/services/org.codehaus.groovy.runtime.ExtensionModule') def props = new Properties() props.load(new StringReader(text)) assert props.getProperty('moduleName') == 'MergedByShadowJar' @@ -641,7 +641,7 @@ moduleVersion=2.3.5 extensionClasses=com.acme.bar.SomeExtension,com.acme.bar.AnotherExtension staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write() - buildFile << """ + projectScriptFile << """ import ${GroovyExtensionModuleTransformer.name} $shadowJar { from('${escapedPath(one)}') @@ -654,17 +654,17 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( run('shadowJar') then: - output.exists() + outputShadowJar.exists() and: - def text = getJarFileContents(output, 'META-INF/groovy/org.codehaus.groovy.runtime.ExtensionModule') + def text = getJarFileContents(outputShadowJar, 'META-INF/groovy/org.codehaus.groovy.runtime.ExtensionModule') def props = new Properties() props.load(new StringReader(text)) props.getProperty('moduleName') == 'MergedByShadowJar' props.getProperty('moduleVersion') == '1.0.0' props.getProperty('extensionClasses') == 'com.acme.foo.FooExtension,com.acme.foo.BarExtension,com.acme.bar.SomeExtension,com.acme.bar.AnotherExtension' props.getProperty('staticExtensionClasses') == 'com.acme.foo.FooStaticExtension,com.acme.bar.SomeStaticExtension' - doesNotContain(output, ['META-INF/services/org.codehaus.groovy.runtime.ExtensionModule']) + assertDoesNotContain(outputShadowJar, ['META-INF/services/org.codehaus.groovy.runtime.ExtensionModule']) } def 'Groovy extension module transformer short syntax'() { @@ -683,7 +683,7 @@ moduleVersion=2.3.5 extensionClasses=com.acme.bar.SomeExtension,com.acme.bar.AnotherExtension staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write() - buildFile << """ + projectScriptFile << """ $shadowJar { from('${escapedPath(one)}') from('${escapedPath(two)}') @@ -695,10 +695,10 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() and: - def text = getJarFileContents(output, 'META-INF/services/org.codehaus.groovy.runtime.ExtensionModule') + def text = getJarFileContents(outputShadowJar, 'META-INF/services/org.codehaus.groovy.runtime.ExtensionModule') def props = new Properties() props.load(new StringReader(text)) assert props.getProperty('moduleName') == 'MergedByShadowJar' @@ -713,7 +713,7 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( if (configuration.contains('test/some.file')) { file('test/some.file') << 'some content' } - buildFile << """ + projectScriptFile << """ import com.github.jengelman.gradle.plugins.shadow.transformers.${transformer} $shadowJar { @@ -725,7 +725,7 @@ staticExtensionClasses=com.acme.bar.SomeStaticExtension'''.stripIndent()).write( run('shadowJar') then: - assert output.exists() + assert outputShadowJar.exists() where: transformer | configuration 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 da4afc8fc..d227f8e79 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 @@ -19,7 +19,7 @@ abstract class AbstractCachingSpec extends BasePluginSpecification { def setup() { // Use a test-specific build cache directory. This ensures that we'll only use cached outputs generated during this // test and we won't accidentally use cached outputs from a different test or a different build. - settingsFile << """ + settingsScriptFile << """ buildCache { local { directory = new File(rootDir, 'build-cache') @@ -29,8 +29,8 @@ abstract class AbstractCachingSpec extends BasePluginSpecification { } void changeConfigurationTo(String content) { - buildFile.text = getDefaultBuildScript('java', true, true) - buildFile << content + projectScriptFile.text = getDefaultProjectBuildScript('java', true, true) + projectScriptFile << content } BuildResult runWithCacheEnabled(String... arguments) { @@ -59,7 +59,7 @@ abstract class AbstractCachingSpec extends BasePluginSpecification { void copyToAlternateDir() { FileUtils.deleteDirectory(alternateDir.toFile()) FileUtils.forceMkdir(alternateDir.toFile()) - FileUtils.copyDirectory(dir.toFile(), alternateDir.toFile()) + FileUtils.copyDirectory(root.toFile(), alternateDir.toFile()) } void assertShadowJarIsCachedAndRelocatable() { @@ -78,8 +78,8 @@ abstract class AbstractCachingSpec extends BasePluginSpecification { } void deleteOutputs() { - if (output.exists()) { - assert output.delete() + if (outputShadowJar.exists()) { + assert outputShadowJar.delete() } } 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 69bb06c88..5c55d58a8 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 @@ -1,13 +1,17 @@ package com.github.jengelman.gradle.plugins.shadow.caching class MinimizationCachingSpec extends AbstractCachingSpec { - File output @Override String getShadowJarTask() { return ":server:shadowJar" } + @Override + File getOutputShadowJar() { + return file('server/build/libs/server-all.jar') + } + /** * Ensure that we get a cache miss when minimization is added and that caching works with minimization */ @@ -34,19 +38,17 @@ class MinimizationCachingSpec extends AbstractCachingSpec { """.stripIndent() file('server/build.gradle') << """ - $defaultBuildScript + $defaultProjectBuildScript dependencies { implementation project(':client') } """.stripIndent() - output = getFile('server/build/libs/server-all.jar') - when: assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'junit/framework/Test.class', 'client/Client.class' @@ -65,22 +67,22 @@ class MinimizationCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'junit/framework/Test.class' ]) - doesNotContain(output, ['client/Client.class']) + assertDoesNotContain(outputShadowJar, ['client/Client.class']) when: assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'junit/framework/Test.class' ]) - doesNotContain(output, ['client/Client.class']) + assertDoesNotContain(outputShadowJar, ['client/Client.class']) } } 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 1fa573932..8fbc18a15 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 @@ -6,7 +6,7 @@ class RelocationCachingSpec extends AbstractCachingSpec { */ def 'shadowJar is cached correctly when relocation is added'() { given: - buildFile << """ + projectScriptFile << """ dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -22,8 +22,8 @@ class RelocationCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'junit/framework/Test.class' ]) @@ -39,14 +39,14 @@ class RelocationCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'foo/junit/framework/Test.class' ]) and: - doesNotContain(output, [ + assertDoesNotContain(outputShadowJar, [ 'junit/framework/Test.class' ]) @@ -54,14 +54,14 @@ class RelocationCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'foo/junit/framework/Test.class' ]) and: - doesNotContain(output, [ + assertDoesNotContain(outputShadowJar, [ 'junit/framework/Test.class' ]) } 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 0c3b4efc4..4c786054c 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 @@ -10,7 +10,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { URL artifact = this.class.classLoader.getResource('test-artifact-1.0-SNAPSHOT.jar') URL project = this.class.classLoader.getResource('test-project-1.0-SNAPSHOT.jar') - buildFile << """ + projectScriptFile << """ $shadowJar { from('${artifact.path}') from('${project.path}') @@ -21,13 +21,13 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - assert output.exists() + assert outputShadowJar.exists() when: assertShadowJarIsCachedAndRelocatable() then: - assert output.exists() + assert outputShadowJar.exists() when: changeConfigurationTo """ @@ -38,7 +38,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - assert output.exists() + assert outputShadowJar.exists() } /** @@ -49,7 +49,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { URL artifact = this.class.classLoader.getResource('test-artifact-1.0-SNAPSHOT.jar') URL project = this.class.classLoader.getResource('test-project-1.0-SNAPSHOT.jar') - buildFile << """ + projectScriptFile << """ $shadowJar { from('${artifact.path}') from('${project.path}') @@ -60,7 +60,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - assert output.exists() + assert outputShadowJar.exists() when: changeConfigurationTo """ @@ -73,8 +73,8 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - assert !output.exists() - assert getFile("build/libs/foo-1.0-all.jar").exists() + assert !outputShadowJar.exists() + assert file("build/libs/foo-1.0-all.jar").exists() } /** @@ -82,7 +82,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { */ def 'shadowJar is cached correctly when using includes/excludes'() { given: - buildFile << """ + projectScriptFile << """ dependencies { implementation 'junit:junit:3.8.2' } $shadowJar { @@ -110,8 +110,8 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'server/Util.class' ]) @@ -128,13 +128,13 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) and: - doesNotContain(output, [ + assertDoesNotContain(outputShadowJar, [ 'server/Util.class', 'junit/framework/Test.class' ]) @@ -143,13 +143,13 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) and: - doesNotContain(output, [ + assertDoesNotContain(outputShadowJar, [ 'server/Util.class', 'junit/framework/Test.class' ]) @@ -160,7 +160,7 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { */ def 'shadowJar is cached correctly when using dependency includes/excludes'() { given: - buildFile << """ + projectScriptFile << """ dependencies { implementation 'junit:junit:3.8.2' } """.stripIndent() @@ -176,8 +176,8 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'junit/framework/Test.class' ]) @@ -195,13 +195,13 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) and: - doesNotContain(output, [ + assertDoesNotContain(outputShadowJar, [ 'junit/framework/Test.class' ]) @@ -209,13 +209,13 @@ class ShadowJarCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) and: - doesNotContain(output, [ + assertDoesNotContain(outputShadowJar, [ 'junit/framework/Test.class' ]) } 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 b937815c1..e48996e52 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 @@ -18,7 +18,7 @@ class TransformCachingSpec extends AbstractCachingSpec { public class Server {} """.stripIndent() - buildFile << """ + projectScriptFile << """ import com.github.jengelman.gradle.plugins.shadow.transformers.Transformer import com.github.jengelman.gradle.plugins.shadow.transformers.TransformerContext import org.apache.tools.zip.ZipOutputStream @@ -56,8 +56,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) @@ -65,8 +65,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) } @@ -87,8 +87,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) @@ -104,8 +104,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) @@ -113,8 +113,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) @@ -130,8 +130,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) @@ -139,8 +139,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) } @@ -162,8 +162,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) @@ -179,8 +179,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'foo/bar.properties' ]) @@ -189,8 +189,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'foo/bar.properties' ]) @@ -209,8 +209,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'foo/baz.properties' ]) @@ -219,8 +219,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'foo/baz.properties' ]) @@ -243,8 +243,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) @@ -260,8 +260,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'foo/bar.xml' ]) @@ -270,8 +270,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'foo/bar.xml' ]) @@ -290,8 +290,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'foo/baz.xml' ]) @@ -300,8 +300,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class', 'foo/baz.xml' ]) @@ -323,8 +323,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) @@ -338,8 +338,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarExecutes() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) @@ -347,8 +347,8 @@ class TransformCachingSpec extends AbstractCachingSpec { assertShadowJarIsCachedAndRelocatable() then: - output.exists() - contains(output, [ + outputShadowJar.exists() + assertContains(outputShadowJar, [ 'server/Server.class' ]) } diff --git a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ApplicationTest.kt b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ApplicationTest.kt index 5160d4a04..6fe3f2464 100644 --- a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ApplicationTest.kt +++ b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ApplicationTest.kt @@ -103,7 +103,7 @@ class ApplicationTest : BasePluginTest() { } """.trimIndent(), ) - buildScript.appendText( + projectScriptPath.appendText( """ apply plugin: 'application' $projectBlock @@ -119,8 +119,8 @@ class ApplicationTest : BasePluginTest() { } """.trimIndent(), ) - settingsScript.writeText( - getSettingsBuildScript( + settingsScriptPath.writeText( + getDefaultSettingsBuildScript( startBlock = settingsBlock, endBlock = "rootProject.name = 'myapp'", ), diff --git a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/BasePluginTest.kt b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/BasePluginTest.kt index ff828078a..7f047228b 100644 --- a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/BasePluginTest.kt +++ b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/BasePluginTest.kt @@ -16,6 +16,7 @@ import kotlin.io.path.createFile import kotlin.io.path.createTempDirectory import kotlin.io.path.deleteRecursively import kotlin.io.path.exists +import kotlin.io.path.extension import kotlin.io.path.readText import kotlin.io.path.toPath import kotlin.io.path.writeText @@ -39,13 +40,8 @@ abstract class BasePluginTest { .use(testJar) .publish() - buildScript.writeText( - getProjectBuildScript( - groupInfo = "group = 'shadow'", - versionInfo = "version = '1.0'", - ), - ) - settingsScript.writeText(getSettingsBuildScript()) + projectScriptPath.writeText(getDefaultProjectBuildScript(withGroup = true, withVersion = true)) + settingsScriptPath.writeText(getDefaultSettingsBuildScript()) } @ExperimentalPathApi @@ -56,14 +52,16 @@ abstract class BasePluginTest { root.deleteRecursively() } - println(buildScript.readText()) + println(projectScriptPath.readText()) } - fun getProjectBuildScript( + fun getDefaultProjectBuildScript( javaPlugin: String = "java", - groupInfo: String = "", - versionInfo: String = "", + withGroup: Boolean = false, + withVersion: Boolean = false, ): String { + val groupInfo = if (withGroup) "group = 'shadow'" else "" + val versionInfo = if (withVersion) "version = '1.0'" else "" return """ plugins { id('$javaPlugin') @@ -74,7 +72,7 @@ abstract class BasePluginTest { """.trimIndent() + System.lineSeparator() } - fun getSettingsBuildScript( + fun getDefaultSettingsBuildScript( startBlock: String = "", endBlock: String = "rootProject.name = 'shadow'", ): String { @@ -117,10 +115,10 @@ abstract class BasePluginTest { open val shadowJarTask = SHADOW_JAR_TASK_NAME open val runShadowTask = SHADOW_RUN_TASK_NAME - val buildScript: Path + val projectScriptPath: Path get() = path("build.gradle") - val settingsScript: Path + val settingsScriptPath: Path get() = path("settings.gradle") val outputShadowJar: Path @@ -128,10 +126,12 @@ abstract class BasePluginTest { fun path(path: String): Path { return root.resolve(path).also { - if (!it.exists()) { - it.parent.createDirectories() - it.createFile() - } + val extension = it.extension + // Binary files should not be created, text files should be created. + if (it.exists() || extension == "jar" || extension == "zip") return@also + + it.parent.createDirectories() + it.createFile() } } @@ -189,12 +189,12 @@ abstract class BasePluginTest { fun writeClientAndServerModules( serverShadowBlock: String = "", ) { - settingsScript.appendText( + settingsScriptPath.appendText( """ include 'client', 'server' """.trimIndent(), ) - buildScript.writeText("") + projectScriptPath.writeText("") path("client/src/main/java/client/Client.java").writeText( """ @@ -204,7 +204,7 @@ abstract class BasePluginTest { ) path("client/build.gradle").writeText( """ - ${getProjectBuildScript("java", versionInfo = "version = '1.0'")} + ${getDefaultProjectBuildScript("java", withVersion = true)} dependencies { implementation 'junit:junit:3.8.2' } """.trimIndent(), ) @@ -218,7 +218,7 @@ abstract class BasePluginTest { ) path("server/build.gradle").writeText( """ - ${getProjectBuildScript("java", versionInfo = "version = '1.0'")} + ${getDefaultProjectBuildScript("java", withVersion = true)} dependencies { implementation project(':client') } diff --git a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.kt b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.kt index 851994739..33fbcc040 100644 --- a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.kt +++ b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/ConfigurationCacheSpec.kt @@ -20,7 +20,7 @@ class ConfigurationCacheSpec : BasePluginTest() { super.setup() publishArtifactA() publishArtifactB() - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'shadow:a:1.0' @@ -43,7 +43,7 @@ class ConfigurationCacheSpec : BasePluginTest() { """.trimIndent(), ) - buildScript.appendText( + projectScriptPath.appendText( """ apply plugin: 'application' @@ -64,7 +64,7 @@ class ConfigurationCacheSpec : BasePluginTest() { @Test fun configurationCachingSupportsExcludes() { - buildScript.appendText( + projectScriptPath.appendText( """ $shadowJar { exclude 'a2.properties' @@ -96,9 +96,9 @@ class ConfigurationCacheSpec : BasePluginTest() { } """.trimIndent(), ) - val output = path("server/build/libs/server-1.0-all.jar") run(shadowJarTask) + val output = path("server/build/libs/server-1.0-all.jar") output.deleteExisting() val result = run(shadowJarTask) @@ -116,7 +116,7 @@ class ConfigurationCacheSpec : BasePluginTest() { @Test fun configurationCachingOfConfigurationsIsUpToDate() { - settingsScript.appendText( + settingsScriptPath.appendText( """ include 'lib' """.trimIndent(), @@ -130,7 +130,7 @@ class ConfigurationCacheSpec : BasePluginTest() { ) path("lib/build.gradle").writeText( """ - ${getProjectBuildScript()} + ${getDefaultProjectBuildScript()} dependencies { implementation 'junit:junit:3.8.2' } diff --git a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/FilteringTest.kt b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/FilteringTest.kt index a639f7b11..1eead9284 100644 --- a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/FilteringTest.kt +++ b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/FilteringTest.kt @@ -19,7 +19,7 @@ class FilteringTest : BasePluginTest() { publishArtifactA() publishArtifactB() - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'shadow:a:1.0' @@ -40,7 +40,7 @@ class FilteringTest : BasePluginTest() { @Test fun excludeFiles() { - buildScript.appendText( + projectScriptPath.appendText( """ $shadowJar { exclude 'a2.properties' @@ -73,7 +73,7 @@ class FilteringTest : BasePluginTest() { @Test fun excludeDependencyUsingWildcardSyntax() { publishArtifactCD() - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'shadow:d:1.0' @@ -100,9 +100,9 @@ class FilteringTest : BasePluginTest() { commonAssertions() - val replaced = buildScript.readText() + val replaced = projectScriptPath.readText() .replace("exclude(dependency('shadow:d:1.0'))", "exclude(dependency('shadow:c:1.0'))") - buildScript.writeText(replaced) + projectScriptPath.writeText(replaced) val result = run(shadowJarTask) assertThat(result.task(":shadowJar")).isNotNull() @@ -126,9 +126,9 @@ class FilteringTest : BasePluginTest() { commonAssertions() - val replaced = buildScript.readText() + val replaced = projectScriptPath.readText() .replace("exclude(dependency('shadow:d:1.0'))", "exclude 'a.properties'") - buildScript.writeText(replaced) + projectScriptPath.writeText(replaced) val result = run(shadowJarTask) @@ -147,7 +147,7 @@ class FilteringTest : BasePluginTest() { @Test fun includeDependencyAndExcludeOthers() { publishArtifactCD() - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'shadow:d:1.0' @@ -188,8 +188,8 @@ class FilteringTest : BasePluginTest() { """.trimIndent(), ) - val serverOutput = path("server/build/libs/server-1.0-all.jar") run(":server:$shadowJarTask") + val serverOutput = path("server/build/libs/server-1.0-all.jar") assertThat(serverOutput).exists() assertDoesNotContain( @@ -212,8 +212,8 @@ class FilteringTest : BasePluginTest() { """.trimIndent(), ) - val serverOutput = path("server/build/libs/server-1.0-all.jar") run(":server:$shadowJarTask") + val serverOutput = path("server/build/libs/server-1.0-all.jar") assertThat(serverOutput).exists() assertDoesNotContain( @@ -228,7 +228,7 @@ class FilteringTest : BasePluginTest() { @Test fun verifyExcludePrecedenceOverInclude() { - buildScript.appendText( + projectScriptPath.appendText( """ $shadowJar { include '*.jar' @@ -261,7 +261,7 @@ class FilteringTest : BasePluginTest() { } private fun dependOnAndExcludeArtifactD() { - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'shadow:d:1.0' diff --git a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt index e502abfe4..a80671375 100644 --- a/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt +++ b/src/intiTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt @@ -15,7 +15,7 @@ class RelocationTest : BasePluginTest() { @Test fun defaultEnableRelocation() { - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'junit:junit:3.8.2' @@ -55,7 +55,7 @@ class RelocationTest : BasePluginTest() { */ @Test fun relocateDependencyFiles() { - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'junit:junit:3.8.2' @@ -121,7 +121,7 @@ class RelocationTest : BasePluginTest() { @Test fun relocateDependencyFilesWithFiltering() { - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'junit:junit:3.8.2' @@ -185,7 +185,7 @@ class RelocationTest : BasePluginTest() { */ @Test fun remapClassNamesForRelocatedFilesInProjectSource() { - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'junit:junit:3.8.2' @@ -268,7 +268,7 @@ class RelocationTest : BasePluginTest() { path("app/build.gradle").writeText( """ - ${getProjectBuildScript()} + ${getDefaultProjectBuildScript()} dependencies { implementation project(':core') } @@ -290,7 +290,7 @@ class RelocationTest : BasePluginTest() { """.trimIndent(), ) - settingsScript.appendText( + settingsScriptPath.appendText( """ include 'core', 'app' """.trimIndent(), @@ -332,7 +332,7 @@ class RelocationTest : BasePluginTest() { ) path("src/main/resources/foo/foo.properties").writeText("name=foo") - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'shadow:dep:1.0' @@ -368,7 +368,7 @@ class RelocationTest : BasePluginTest() { */ @Test fun doesNotErrorOnRelocatingJava9Classes() { - buildScript.appendText( + projectScriptPath.appendText( """ dependencies { implementation 'org.slf4j:slf4j-api:1.7.21'