Skip to content

Commit

Permalink
Missing type tag in AddDependencyVisitor (openrewrite#3885)
Browse files Browse the repository at this point in the history
* Missing type tag in AddDependencyVisitor

* Minimize indentation on text blocks

---------

Co-authored-by: Knut Wannheden <[email protected]>
  • Loading branch information
leveretconey and timtebeek authored Jan 5, 2024
1 parent 791748d commit 1a62a33
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ public Xml visitTag(Xml.Tag tag, ExecutionContext ctx) {
"<version>" + versionToUse + "</version>\n") +
(classifier == null ? "" :
"<classifier>" + classifier + "</classifier>\n") +
(type == null || "jar".equals(type) ? "" :
"<type>" + type + "</type>\n") +
(scope == null || "compile".equals(scope) ? "" :
"<scope>" + scope + "</scope>\n") +
(Boolean.TRUE.equals(optional) ? "<optional>true</optional>\n" : "") +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,43 @@ void systemScope() {
);
}

@Test
void pomType() {
rewriteRun(
spec -> spec
.recipe(new AddDependency("com.google.guava", "guava", "29.0-jre", null, null, null, null, "pom", null, null, null, null)),
mavenProject("project",
srcMainJava(
java(usingGuavaIntMath)
),
pomXml(
"""
<project>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
</project>
""",
"""
<project>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
<type>pom</type>
</dependency>
</dependencies>
</project>
"""
)
)
);
}

@ParameterizedTest
@ValueSource(strings = {"com.google.common.math.*", "com.google.common.math.IntMath"})
void onlyIfUsingTestScope(String onlyIfUsing) {
Expand Down

0 comments on commit 1a62a33

Please sign in to comment.