@@ -2,11 +2,8 @@ package com.github.jengelman.gradle.plugins.shadow.transformers
22
33import assertk.all
44import assertk.assertThat
5- import assertk.assertions.any
65import assertk.assertions.contains
76import assertk.assertions.containsExactlyInAnyOrder
8- import assertk.assertions.containsSubList
9- import assertk.assertions.endsWith
107import assertk.assertions.isEqualTo
118import assertk.assertions.isNotEqualTo
129import assertk.assertions.isNotNull
@@ -61,72 +58,6 @@ class TransformersTest : BaseTransformerTest() {
6158 ),
6259 )
6360
64- if (excludeAll) {
65- runWithSuccess(shadowJarPath)
66- assertThat(outputShadowedJar).useAll {
67- containsExactlyInAnyOrder(
68- // twice:
69- " multiple-contents" ,
70- " multiple-contents" ,
71- " single-source" ,
72- " same-content-twice" ,
73- // twice:
74- " differing-content-2" ,
75- " differing-content-2" ,
76- " META-INF/" ,
77- " META-INF/MANIFEST.MF" ,
78- )
79- getContents(" multiple-contents" ).containsExactlyInAnyOrder(" content" , " content-is-different" )
80- getContent(" single-source" ).isEqualTo(" content" )
81- getContent(" same-content-twice" ).isEqualTo(" content" )
82- getContents(" differing-content-2" ).containsExactlyInAnyOrder(" content" , " content-is-different" )
83- }
84- } else {
85- val buildResult = runWithFailure(shadowJarPath)
86- assertThat(buildResult.task(" :shadowJar" )!! .outcome).isSameInstanceAs(TaskOutcome .FAILED )
87- val outputLines = buildResult.output.lines()
88- assertThat(outputLines).containsSubList(
89- listOf (
90- // Keep this list approach for Unix/Windows test compatibility.
91- " Execution failed for task ':shadowJar'." ,
92- " > Found 1 path duplicate(s) with different content in the shadow JAR:" ,
93- " * differing-content-2" ,
94- ),
95- )
96- assertThat(outputLines).any {
97- it.endsWith(" differing-content-2 (Hash: -1337566116240053116)" )
98- }
99- assertThat(outputLines).any {
100- it.endsWith(" differing-content-2 (Hash: -6159701213549668473)" )
101- }
102- }
103- }
104-
105- @ParameterizedTest
106- @ValueSource(booleans = [false , true ])
107- fun deduplicatingResourceTransformerEXPERIMENT (excludeAll : Boolean ) {
108- val one = buildJarOne {
109- insert(" multiple-contents" , " content" )
110- insert(" single-source" , " content" )
111- insert(" same-content-twice" , " content" )
112- insert(" differing-content-2" , " content" )
113- }
114- val two = buildJarTwo {
115- insert(" multiple-contents" , " content-is-different" )
116- insert(" same-content-twice" , " content" )
117- insert(" differing-content-2" , " content-is-different" )
118- }
119-
120- projectScript.appendText(
121- transform<DeduplicatingResourceTransformer >(
122- dependenciesBlock = implementationFiles(one, two),
123- transformerBlock = """
124- exclude("multiple-contents")
125- ${if (excludeAll) " exclude(\" differing-content-2\" )" else " " }
126- """ .trimIndent(),
127- ),
128- )
129-
13061 if (excludeAll) {
13162 runWithSuccess(shadowJarPath)
13263 assertThat(outputShadowedJar).useAll {
@@ -151,11 +82,10 @@ class TransformersTest : BaseTransformerTest() {
15182 val buildResult = runWithFailure(shadowJarPath)
15283 assertThat(buildResult.task(" :shadowJar" )!! .outcome).isSameInstanceAs(TaskOutcome .FAILED )
15384 assertThat(buildResult.output).contains(
154- """
155- Execution failed for task ':shadowJar'.
156- > Found 1 path duplicate(s) with different content in the shadow JAR:
157- * differing-content-2
158- """ .trimIndent().replace(" \n " , System .lineSeparator()),
85+ // Keep this list approach for Unix/Windows test compatibility.
86+ " Execution failed for task ':shadowJar'." ,
87+ " > Found 1 path duplicate(s) with different content in the shadow JAR:" ,
88+ " * differing-content-2" ,
15989 " differing-content-2 (Hash: -1337566116240053116)" ,
16090 " differing-content-2 (Hash: -6159701213549668473)" ,
16191 )
0 commit comments