Skip to content

Commit

Permalink
Add a test for relocating all packages but certain one (#1325)
Browse files Browse the repository at this point in the history
* Test `relocateAllPackagesButSomeone`

* Use ParameterizedTest

* Cleanups

* Rename
  • Loading branch information
Goooler authored Mar 10, 2025
1 parent 5e211a9 commit e067276
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit e067276

Please # to comment.