Skip to content

Commit 86486b4

Browse files
committed
Add initial test (wip)
1 parent 10cef9b commit 86486b4

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.gradlex.jvm.dependency.conflict.test
2+
3+
import org.gradle.api.artifacts.Configuration
4+
import org.gradle.testfixtures.ProjectBuilder
5+
import org.gradlex.jvm.dependency.conflict.detection.rules.CapabilityDefinition
6+
import spock.lang.Specification
7+
8+
import java.util.zip.ZipFile
9+
10+
class JarOverlapTest extends Specification {
11+
12+
def "it works"(CapabilityDefinition definition) {
13+
given:
14+
def project = ProjectBuilder.builder().build()
15+
def dependencies = project.getDependencies()
16+
project.getPlugins().apply("jvm-ecosystem")
17+
project.getRepositories().mavenCentral()
18+
19+
def modules = definition.modules.collect { dependencies.create("$it:latest.release") }
20+
Configuration conf = project.getConfigurations().detachedConfiguration(*modules)
21+
conf.transitive = false
22+
23+
when:
24+
Map<String, Set<String>> jarClassFiles = conf.files.collectEntries { jar ->
25+
def jarName = jar.name
26+
[(jarName): new ZipFile(jar).withCloseable {
27+
it.entries().collect { entry -> entry.name }.findAll { it.endsWith(".class") } as Set
28+
}]
29+
}
30+
31+
then:
32+
Collection<Set<String>> jarEntries = jarClassFiles.values()
33+
[jarEntries, jarEntries].combinations().each { Set a, Set b ->
34+
assert !a.intersect(b).isEmpty()
35+
}
36+
37+
where:
38+
definition << CapabilityDefinition.values()
39+
}
40+
}

0 commit comments

Comments
 (0)