Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent all referenced properties from updating to latest regardless of recipe #3955

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}")
}
"""
)
);
}
}
Loading