Skip to content

Commit

Permalink
Added classifier support to DependencyUseStringNotation recipe (#4226)
Browse files Browse the repository at this point in the history
Co-authored-by: Jente Sondervorst <[email protected]>
  • Loading branch information
Jenson3210 and Jente Sondervorst authored Jun 5, 2024
1 parent 5b5d72c commit 85a4cce
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ private J.Literal toLiteral(Space prefix, Markers markers, Map<String, Expressio
String version = coerceToStringNotation(mapNotation.get("version"));
if (version != null) {
stringNotation += ":" + version;
String classifier = coerceToStringNotation(mapNotation.get("classifier"));
if (classifier != null) {
stringNotation += ":" + classifier;
}
}

return new J.Literal(randomId(), prefix, markers, stringNotation, "\"" + stringNotation + "\"", Collections.emptyList(), JavaType.Primitive.String);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ void basicMap() {
);
}

@Test
void withClassifier() {
rewriteRun(
buildGradle(
"""
plugins {
id 'java-library'
}
dependencies {
api(group: 'org.openrewrite', name: 'rewrite-core', version: 'latest.release', classifier: 'sources')
implementation group: 'group', name: 'artifact', version: 'version', classifier: 'sources'
}
""",
"""
plugins {
id 'java-library'
}
dependencies {
api("org.openrewrite:rewrite-core:latest.release:sources")
implementation "group:artifact:version:sources"
}
"""
)
);
}

@Test
void basicMapLiteral() {
rewriteRun(
Expand Down

0 comments on commit 85a4cce

Please sign in to comment.