Skip to content

Commit 1836853

Browse files
committed
Add tests for different variant metadata formats
1 parent 11e0453 commit 1836853

File tree

1 file changed

+38
-3
lines changed

1 file changed

+38
-3
lines changed

src/test/groovy/org/gradlex/jvm/dependency/conflict/test/patch/ModifyDependenciesTest.groovy

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ compileClasspath - Compile classpath for source set 'main'.
4141
'''
4242
}
4343

44-
def "can reduce dependency scope to runtime only"() {
44+
def "can reduce dependency scope to runtime only for pom-only metadata attributes"() {
4545
given:
4646
buildFile << """
4747
jvmDependencyConflicts {
@@ -70,7 +70,42 @@ runtimeClasspath - Runtime classpath of source set 'main'.
7070
'''
7171
}
7272

73-
def "can reduce dependency scope to compile only for standard variants"() {
73+
def "can remove runtime only dependency for Gradle metadata attributes"() {
74+
given:
75+
buildFile << """
76+
jvmDependencyConflicts {
77+
patch {
78+
module("com.google.guava:guava") {
79+
reduceToRuntimeOnlyDependency("com.google.errorprone:error_prone_annotations")
80+
reduceToRuntimeOnlyDependency("org.jspecify:jspecify")
81+
reduceToRuntimeOnlyDependency("com.google.j2objc:j2objc-annotations")
82+
}
83+
}
84+
}
85+
dependencies {
86+
implementation("com.google.guava:guava:33.4.8-jre")
87+
}
88+
"""
89+
90+
expect: 'Dependencies are removed from compile classpath'
91+
dependenciesCompile().output.contains '''
92+
compileClasspath - Compile classpath for source set 'main'.
93+
\\--- com.google.guava:guava:33.4.8-jre
94+
\\--- com.google.guava:failureaccess:1.0.3
95+
'''
96+
97+
and: 'Annotation libraries are present on the runtime classpath'
98+
dependenciesRuntime().output.contains '''
99+
runtimeClasspath - Runtime classpath of source set 'main'.
100+
\\--- com.google.guava:guava:33.4.8-jre
101+
+--- com.google.guava:failureaccess:1.0.3
102+
+--- org.jspecify:jspecify:1.0.0
103+
+--- com.google.errorprone:error_prone_annotations:2.36.0
104+
\\--- com.google.j2objc:j2objc-annotations:3.0.0
105+
'''
106+
}
107+
108+
def "can reduce dependency scope to compile only for pom-only metadata variants"() {
74109
given:
75110
buildFile << """
76111
jvmDependencyConflicts {
@@ -99,7 +134,7 @@ runtimeClasspath - Runtime classpath of source set 'main'.
99134
'''
100135
}
101136

102-
def "can reduce dependency scope to compile only for non-standard variants"() {
137+
def "can reduce dependency scope to compile only for Gradle metadata variants"() {
103138
given:
104139
buildFile << """
105140
jvmDependencyConflicts {

0 commit comments

Comments
 (0)