diff --git a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt index 99feaacf0..b7f84e2de 100644 --- a/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt +++ b/src/functionalTest/kotlin/com/github/jengelman/gradle/plugins/shadow/RelocationTest.kt @@ -20,6 +20,7 @@ import org.junit.jupiter.api.Test import org.junit.jupiter.params.ParameterizedTest import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.MethodSource +import org.junit.jupiter.params.provider.ValueSource import org.opentest4j.AssertionFailedError class RelocationTest : BasePluginTest() { @@ -467,6 +468,55 @@ class RelocationTest : BasePluginTest() { } } + @ParameterizedTest + @ValueSource(booleans = [false, true]) + fun relocateAllPackagesButCertainOne(exclude: Boolean) { + val relocateConfig = if (exclude) { + """ + exclude 'junit/**' + exclude 'META-INF/MANIFEST.MF' + """.trimIndent() + } else { + "" + } + projectScriptPath.appendText( + """ + dependencies { + implementation 'junit:junit:3.8.2' + } + $shadowJar { + relocate('', 'foo/') { + $relocateConfig + } + } + """.trimIndent(), + ) + + run(shadowJarTask) + + assertThat(outputShadowJar).useAll { + if (exclude) { + containsEntries( + "META-INF/MANIFEST.MF", + *junitEntries, + ) + doesNotContainEntries( + "foo/META-INF/MANIFEST.MF", + *junitEntries.map { "foo/$it" }.toTypedArray(), + ) + } else { + containsEntries( + "foo/META-INF/MANIFEST.MF", + *junitEntries.map { "foo/$it" }.toTypedArray(), + ) + doesNotContainEntries( + "META-INF/MANIFEST.MF", + *junitEntries, + ) + } + } + } + private companion object { @JvmStatic fun prefixProvider() = listOf(