Skip to content

Commit ee44ffd

Browse files
britterjjohannes
authored andcommitted
Use samples all list to implement JarOverlapTest
1 parent 9f7ceeb commit ee44ffd

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

samples/sample-all/build.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,10 @@ dependencies {
255255
implementation("velocity:velocity:1.4")
256256
implementation("woodstox:wstx-asl:2.9.3")
257257

258-
implementation("com.google.collections:google-collections:1.0") // moved down: https://github.com/gradle/gradle/issues/22326
258+
// moved down: https://github.com/gradle/gradle/issues/22326
259+
implementation("com.google.collections:google-collections:1.0")
259260

260-
// implementation("woodstox:wstx-lgpl:3.2.7") - has no POM file
261+
implementation("woodstox:wstx-lgpl:3.2.7")
261262
}
262263

263264
jvmDependencyConflicts {

src/test/groovy/org/gradlex/jvm/dependency/conflict/test/JarOverlapTest.groovy

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,34 @@ import org.gradle.testfixtures.ProjectBuilder
55
import org.gradlex.jvm.dependency.conflict.detection.rules.CapabilityDefinition
66
import spock.lang.Specification
77

8+
import java.util.stream.Collectors
89
import java.util.zip.ZipFile
910

1011
class JarOverlapTest extends Specification {
1112

13+
def allSupportedDependencies = []
14+
15+
void setup() {
16+
allSupportedDependencies = new File("samples/sample-all/build.gradle.kts")
17+
.readLines()
18+
.findAll { it.contains("implementation(") }
19+
.collect { it.trim() }
20+
.collect { it.replace("implementation(\"", "") }
21+
.collect { it.replace("\")", "") }
22+
}
23+
1224
def "it works"(CapabilityDefinition definition) {
1325
given:
1426
def project = ProjectBuilder.builder().build()
1527
def dependencies = project.getDependencies()
1628
project.getPlugins().apply("jvm-ecosystem")
1729
project.getRepositories().mavenCentral()
1830

19-
def modules = definition.modules.collect { dependencies.create("$it:latest.release") }
31+
def modules = definition.modules.collect { dependencies.create(it) }
32+
def constraints = allSupportedDependencies.collect { dependencies.constraints.create(it) }
33+
2034
Configuration conf = project.getConfigurations().detachedConfiguration(*modules)
35+
conf.dependencyConstraints.addAll(constraints)
2136
conf.transitive = false
2237

2338
when:
@@ -37,4 +52,6 @@ class JarOverlapTest extends Specification {
3752
where:
3853
definition << CapabilityDefinition.values()
3954
}
55+
56+
4057
}

0 commit comments

Comments
 (0)