Skip to content

Commit 64d4dd3

Browse files
committed
Use gradle.properties for version in GString/StringTemplate tests
Move version variables from inline definitions to gradle.properties in worksWithGString and kotlinDslStringInterpolation tests, making them closer to real-world usage patterns. The properties file remains unchanged, confirming the GString/StringTemplate structure is preserved.
1 parent e042a67 commit 64d4dd3

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

rewrite-gradle/src/test/java/org/openrewrite/gradle/ChangeDependencyTest.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import static org.openrewrite.gradle.Assertions.buildGradle;
2525
import static org.openrewrite.gradle.Assertions.buildGradleKts;
2626
import static org.openrewrite.gradle.toolingapi.Assertions.withToolingApi;
27+
import static org.openrewrite.properties.Assertions.properties;
2728

2829
class ChangeDependencyTest implements RewriteTest {
2930
@Override
@@ -238,6 +239,12 @@ implementation platform("org.apache.commons:commons-lang3:3.11")
238239
void worksWithGString() {
239240
rewriteRun(
240241
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null, true)),
242+
properties(
243+
"""
244+
commonsLangVersion=2.6
245+
""",
246+
spec -> spec.path("gradle.properties")
247+
),
241248
buildGradle(
242249
"""
243250
plugins {
@@ -248,9 +255,8 @@ void worksWithGString() {
248255
mavenCentral()
249256
}
250257
251-
def version = '2.6'
252258
dependencies {
253-
implementation platform("commons-lang:commons-lang:${version}")
259+
implementation platform("commons-lang:commons-lang:${commonsLangVersion}")
254260
}
255261
""",
256262
"""
@@ -262,9 +268,8 @@ implementation platform("commons-lang:commons-lang:${version}")
262268
mavenCentral()
263269
}
264270
265-
def version = '2.6'
266271
dependencies {
267-
implementation platform("org.apache.commons:commons-lang3:${version}")
272+
implementation platform("org.apache.commons:commons-lang3:${commonsLangVersion}")
268273
}
269274
"""
270275
)
@@ -548,6 +553,12 @@ void kotlinDsl() {
548553
void kotlinDslStringInterpolation() {
549554
rewriteRun(
550555
spec -> spec.recipe(new ChangeDependency("commons-lang", "commons-lang", "org.apache.commons", "commons-lang3", "3.11.x", null, null, true)),
556+
properties(
557+
"""
558+
commonsLangVersion=2.6
559+
""",
560+
spec -> spec.path("gradle.properties")
561+
),
551562
buildGradleKts(
552563
"""
553564
plugins {
@@ -558,8 +569,8 @@ void kotlinDslStringInterpolation() {
558569
mavenCentral()
559570
}
560571
572+
val commonsLangVersion: String by project
561573
dependencies {
562-
val commonsLangVersion = "2.6"
563574
implementation("commons-lang:commons-lang:${commonsLangVersion}")
564575
}
565576
""",
@@ -572,8 +583,8 @@ void kotlinDslStringInterpolation() {
572583
mavenCentral()
573584
}
574585
586+
val commonsLangVersion: String by project
575587
dependencies {
576-
val commonsLangVersion = "2.6"
577588
implementation("org.apache.commons:commons-lang3:${commonsLangVersion}")
578589
}
579590
"""

0 commit comments

Comments
 (0)