Skip to content

Commit f4d5eca

Browse files
committed
Extend test coverage for using TOML version catalog
See #82
1 parent 8605605 commit f4d5eca

File tree

3 files changed

+41
-32
lines changed

3 files changed

+41
-32
lines changed

samples/versions-in-catalog/gradle/libs.versions.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ com_fasterxml_jackson_databind = "2.12.5"
44
org_slf4j = "1.7.28"
55
org_slf4j_simple = "1.7.28"
66

7-
org_junit_jupiter_api = "5.7.2"
8-
org_junit_jupiter_engine = "5.7.2"
7+
org-junit-jupiter-api = "5.7.2"

src/test/groovy/org/gradlex/javamodule/dependencies/test/CustomizationTest.groovy

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class CustomizationTest extends Specification {
8484
given:
8585
settingsFile << '''
8686
dependencyResolutionManagement.versionCatalogs.create("modules") {
87-
version("org_apache_xmlbeans", "5.0.1")
88-
version("com_fasterxml_jackson_databind", "2.12.5")
87+
version("org.apache.xmlbeans", "5.0.1")
88+
version("com.fasterxml.jackson.databind", "2.12.5")
8989
}
9090
'''
9191
appBuildFile << '''
@@ -136,4 +136,42 @@ class CustomizationTest extends Specification {
136136
then:
137137
result.output.contains('[jakarta.mail-2.0.1.jar, jakarta.servlet-api-6.0.0.jar, jakarta.inject-api-1.0.5.jar, jakarta.activation-2.0.1.jar]')
138138
}
139+
140+
def "can use toml catalog with '_' for '.'"() {
141+
given:
142+
file('gradle/libs.versions.toml') << '''
143+
[versions]
144+
org_apache_xmlbeans = "5.0.1"
145+
'''.stripIndent()
146+
appModuleInfoFile << '''
147+
module org.gradlex.test.app {
148+
requires org.apache.xmlbeans;
149+
}
150+
'''
151+
152+
when:
153+
def result = build()
154+
155+
then:
156+
!result.output.contains('[WARN]')
157+
}
158+
159+
def "can use toml catalog with '-' for '.'"() {
160+
given:
161+
file('gradle/libs.versions.toml') << '''
162+
[versions]
163+
org-apache-xmlbeans = "5.0.1"
164+
'''.stripIndent()
165+
appModuleInfoFile << '''
166+
module org.gradlex.test.app {
167+
requires org.apache.xmlbeans;
168+
}
169+
'''
170+
171+
when:
172+
def result = build()
173+
174+
then:
175+
!result.output.contains('[WARN]')
176+
}
139177
}

src/test/groovy/org/gradlex/javamodule/dependencies/test/WarningsTest.groovy

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,6 @@ class WarningsTest extends Specification {
88
@Delegate
99
GradleBuild build = new GradleBuild()
1010

11-
def "warning for version missing in catalog can be disabled"() {
12-
given:
13-
file('gradle/libs.versions.toml') << '''
14-
[versions]
15-
org_apache_xmlbeans = "5.0.1"
16-
'''.stripIndent()
17-
appBuildFile << '''
18-
javaModuleDependencies.warnForMissingVersions.set(false)
19-
dependencies.constraints {
20-
javaModuleDependencies {
21-
implementation(gav("com.fasterxml.jackson.databind", "2.12.5"))
22-
}
23-
}
24-
'''
25-
appModuleInfoFile << '''
26-
module org.gradlex.test.app {
27-
requires com.fasterxml.jackson.databind;
28-
requires org.apache.xmlbeans;
29-
}
30-
'''
31-
32-
when:
33-
def result = build()
34-
35-
then:
36-
!result.output.contains('[WARN]')
37-
}
38-
3911
def "prints warning for missing mapping"() {
4012
given:
4113
appModuleInfoFile << '''

0 commit comments

Comments
 (0)