Skip to content

Commit

Permalink
fix: prevent all referenced properties from updating to latest regard…
Browse files Browse the repository at this point in the history
…less of recipe
  • Loading branch information
ajohnsonz committed Jan 29, 2024
1 parent 719e812 commit b453412
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ public boolean isAcceptable(SourceFile sourceFile, ExecutionContext ctx) {
public org.openrewrite.properties.tree.Properties visitEntry(Properties.Entry entry, ExecutionContext ctx) {
if (acc.buildDependencies.containsKey(entry.getKey()) && acc.gradleProject != null) {
GroupArtifact groupArtifact = acc.buildDependencies.get(entry.getKey());
if(groupArtifact == null || !dependencyMatcher.matches(groupArtifact.getGroupId(), groupArtifact.getArtifactId())) {
return entry;
}
if (!StringUtils.isBlank(newVersion)) {
String resolvedVersion;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,4 +666,38 @@ void mapNotationGStringVariableInPropertiesFile() {
)
);
}

@Test
void globVersionsInPropertiesFileWithMultipleVersionsOnlyUpdatesCorrectProperty() {
rewriteRun(
spec -> spec.recipe(new UpgradeDependencyVersion("org.springframework.security", "*", "5.4.x", null)),
properties(
"""
springBootVersion=3.0.0
springSecurityVersion=5.4.0
""",
"""
springBootVersion=3.0.0
springSecurityVersion=5.4.11
""",
spec -> spec.path("gradle.properties")
),
buildGradle(
"""
plugins {
id 'java'
}
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}")
implementation("org.springframework.security:spring-security-oauth2-core:${springSecurityVersion}")
}
"""
)
);
}
}

0 comments on commit b453412

Please sign in to comment.