@@ -13,6 +13,7 @@ import static org.gradlex.jvm.dependency.conflict.detection.rules.CapabilityDefi
1313 */
1414class JarOverlapTest extends Specification {
1515 private static final String SAMPLE_ALL_BUILD_FILE = " samples/sample-all/build.gradle.kts"
16+ private static final String SAMPLE_ALL_DEACTIVATED_BUILD_FILE = " samples/sample-all-deactivated/build.gradle.kts"
1617
1718 // Some Jars do not have overlapping classes, but contain conflicting implementations of the same service.
1819 static def expectedToOverlap = values() - [
@@ -26,10 +27,11 @@ class JarOverlapTest extends Specification {
2627 SLF4J_VS_LOG4J2_FOR_JUL // register conflicting handler implementations
2728 ]
2829
29- def latestVersions = []
30+ def allSample = parse(SAMPLE_ALL_BUILD_FILE )
31+ def allDeactivatedSample = parse(SAMPLE_ALL_DEACTIVATED_BUILD_FILE )
3032
31- void setup ( ) {
32- latestVersions = new File (SAMPLE_ALL_BUILD_FILE )
33+ private static List< String > parse ( String buildFilr ) {
34+ new File (buildFilr )
3335 .readLines()
3436 .findAll { it. contains(" implementation(" ) }
3537 .collect { it. trim() }
@@ -52,19 +54,36 @@ class JarOverlapTest extends Specification {
5254 it. metadataSources. ignoreGradleMetadataRedirection()
5355 }
5456
57+ def missingInAll = []
58+ def missingInAllDeactivated = []
59+
5560 def modules = definition. modules. collect { module ->
5661 def specific = specificVersions. find { it. startsWith(module + " :" ) }
62+ def moduleInAllSample = allSample. find { it. startsWith(module + " :" ) }
63+ def moduleInAllDeactivatedSample = allDeactivatedSample. find { it. startsWith(module + " :" ) }
64+ if (! moduleInAllSample) {
65+ missingInAll. add(module)
66+ }
67+ if (! moduleInAllDeactivatedSample) {
68+ missingInAllDeactivated. add(module)
69+ }
70+
5771 if (specific) {
5872 dependencies. create(specific)
73+ } else if (moduleInAllSample != null ) {
74+ dependencies. create(moduleInAllSample)
5975 } else {
60- def moduleForSample = latestVersions. find { it. startsWith(module + " :" ) }
61- if (! moduleForSample) {
62- throw new RuntimeException (" Missing entry for " + module + " in " + SAMPLE_ALL_BUILD_FILE )
63- }
64- dependencies. create(moduleForSample)
76+ null
6577 }
6678 }
6779
80+ if (! missingInAll. isEmpty() || ! missingInAllDeactivated. isEmpty()) {
81+ throw new RuntimeException (
82+ " Missing in $SAMPLE_ALL_BUILD_FILE :\n " + missingInAll. collect { " implementation(\" $it :+\" )\n " }. join(" " ) +
83+ " Missing in $SAMPLE_ALL_DEACTIVATED_BUILD_FILE :\n " + missingInAllDeactivated. collect { " implementation(\" $it :+\" )\n " }. join(" " )
84+ )
85+ }
86+
6887 def conf = project. getConfigurations(). detachedConfiguration(* modules)
6988 conf. transitive = false
7089
0 commit comments