@@ -39,58 +39,12 @@ class PropertiesFileTransformerTest : BaseTransformerTest() {
3939 val result = runWithFailure(shadowJarPath)
4040
4141 assertThat(result).taskOutcomeEquals(shadowJarPath, FAILED )
42- assertThat(result.output).contains(
43- " Execution failed for task ':shadowJar'." ,
44- " > The following properties files have conflicting property values and cannot be merged:" ,
45- " * META-INF/test.properties" ,
46- " * Property key2 is duplicated 2 times with different values" ,
47- )
48- } else {
49- runWithSuccess(shadowJarPath)
50-
51- val expected = when (strategy) {
52- MergeStrategy .First -> arrayOf(" key1=one" , " key2=one" , " key3=two" )
53- MergeStrategy .Latest -> arrayOf(" key1=one" , " key2=two" , " key3=two" )
54- MergeStrategy .Append -> arrayOf(" key1=one" , " key2=one;two" , " key3=two" )
55- else -> fail(" Unexpected strategy: $strategy " )
56- }
57- val content = outputShadowedJar.use { it.getContent(" META-INF/test.properties" ) }
58- assertThat(content).contains(* expected)
59- }
60- }
61-
62- @ParameterizedTest
63- @EnumSource(MergeStrategy ::class )
64- fun mergePropertiesWithDifferentStrategiesEXPERIMENT (strategy : MergeStrategy ) {
65- val one = buildJarOne {
66- insert(" META-INF/test.properties" , " key1=one\n key2=one" )
67- }
68- val two = buildJarTwo {
69- insert(" META-INF/test.properties" , " key2=two\n key3=two" )
70- }
71- projectScript.appendText(
72- transform<PropertiesFileTransformer >(
73- dependenciesBlock = implementationFiles(one, two),
74- transformerBlock = """
75- mergeStrategy = $mergeStrategyClassName .$strategy
76- mergeSeparator = ";"
77- paths = ["META-INF/test.properties"]
78- """ .trimIndent(),
79- ),
80- )
81-
82- if (strategy == MergeStrategy .Fail ) {
83- val result = runWithFailure(shadowJarPath)
84-
85- assertThat(result).taskOutcomeEquals(shadowJarPath, FAILED )
86- assertThat(result.output).contains(
87- // TODO EXPERIMENT
42+ assertThat(result.output.replace(lineSeparator, " \n " )).contains(
8843 """
89- Execution failed for task ':shadowJar'.
90- > The following properties files have conflicting property values and cannot be merged:
91- * META-INF/test.properties
92- * Property key2 is duplicated 2 times with different values
93- """ .trimIndent().replace(" \n " , System .lineSeparator()),
44+ Caused by: java.lang.IllegalStateException: The following properties files have conflicting property values and cannot be merged:
45+ * META-INF/test.properties
46+ * Property key2 is duplicated 2 times with different values
47+ """ .trimIndent(),
9448 )
9549 } else {
9650 runWithSuccess(shadowJarPath)
0 commit comments