@@ -7,6 +7,7 @@ import assertk.assertions.containsMatch
7
7
import assertk.assertions.isEqualTo
8
8
import assertk.assertions.isGreaterThan
9
9
import assertk.assertions.isNotEmpty
10
+ import assertk.assertions.isNotEqualTo
10
11
import assertk.assertions.isNotNull
11
12
import assertk.assertions.isNull
12
13
import assertk.assertions.isTrue
@@ -696,4 +697,45 @@ class JavaPluginTest : BasePluginTest() {
696
697
doesNotContainEntries(mainClass)
697
698
}
698
699
}
700
+
701
+ @Issue(
702
+ " https://github.com/GradleUp/shadow/issues/520" ,
703
+ )
704
+ @Test
705
+ fun onlyKeepFilesFromProjectWhenDuplicatesStrategyIsExclude () {
706
+ val fooJar = buildJar(" foo.jar" ) {
707
+ insert(" module-info.class" , " module myModuleName {}" )
708
+ }
709
+ val mainClass = writeClass()
710
+ writeClass(className = " module-info" ) {
711
+ " module myModuleName {}"
712
+ }
713
+ projectScriptPath.appendText(
714
+ """
715
+ dependencies {
716
+ ${implementationFiles(fooJar)}
717
+ }
718
+ $shadowJar {
719
+ duplicatesStrategy = DuplicatesStrategy.EXCLUDE
720
+ excludes.remove(
721
+ 'module-info.class'
722
+ )
723
+ }
724
+ """ .trimIndent(),
725
+ )
726
+
727
+ run (shadowJarTask)
728
+
729
+ assertThat(outputShadowJar).useAll {
730
+ containsEntries(
731
+ mainClass,
732
+ " module-info.class" ,
733
+ )
734
+ getContent(" module-info.class" ).all {
735
+ isNotEmpty()
736
+ // It's the compiled class instead of the original content.
737
+ isNotEqualTo(" module myModuleName {}" )
738
+ }
739
+ }
740
+ }
699
741
}
0 commit comments