-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/test/groovy/org/gradlex/jvm/dependency/conflict/test/JarOverlapTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package org.gradlex.jvm.dependency.conflict.test | ||
|
||
import org.gradle.api.artifacts.Configuration | ||
import org.gradle.testfixtures.ProjectBuilder | ||
import org.gradlex.jvm.dependency.conflict.detection.rules.CapabilityDefinition | ||
import spock.lang.Specification | ||
|
||
import java.util.zip.ZipFile | ||
|
||
class JarOverlapTest extends Specification { | ||
|
||
def "it works"(CapabilityDefinition definition) { | ||
given: | ||
def project = ProjectBuilder.builder().build() | ||
def dependencies = project.getDependencies() | ||
project.getPlugins().apply("jvm-ecosystem") | ||
project.getRepositories().mavenCentral() | ||
|
||
def modules = definition.modules.collect { dependencies.create("$it:latest.release") } | ||
Configuration conf = project.getConfigurations().detachedConfiguration(*modules) | ||
conf.transitive = false | ||
|
||
when: | ||
Map<String, Set<String>> jarClassFiles = conf.files.collectEntries { jar -> | ||
def jarName = jar.name | ||
[(jarName): new ZipFile(jar).withCloseable { | ||
it.entries().collect { entry -> entry.name }.findAll { it.endsWith(".class") } as Set | ||
}] | ||
} | ||
|
||
then: | ||
Collection<Set<String>> jarEntries = jarClassFiles.values() | ||
[jarEntries, jarEntries].combinations().each { Set a, Set b -> | ||
assert !a.intersect(b).isEmpty() | ||
} | ||
|
||
where: | ||
definition << CapabilityDefinition.values() | ||
} | ||
} |