Skip to content

Commit

Permalink
DependencyInsight also search maven files
Browse files Browse the repository at this point in the history
  • Loading branch information
sambsnyd committed Nov 9, 2023
1 parent bc35536 commit b079b23
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
SourceFile s = (SourceFile) tree;
if(gdi.isAcceptable(s, ctx)) {
s = (SourceFile) gdi.visitNonNull(s, ctx);
} else if(mdi.isAcceptable(s, ctx)) {
}
if(mdi.isAcceptable(s, ctx)) {
s = (SourceFile) mdi.visitNonNull(s, ctx);
}
return s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public String getDescription() {
return "Recipes which manipulate dependencies must be able to successfully access the artifact repositories " +
"and resolve dependencies from them. This recipe produces two data tables used to understand the state " +
"of dependency resolution. \n\n" +
"The Repository accessibility report lists all the artifact repositories known to the project and whether" +
"they respond to network access. The network access is attempted while the recipe is run and so is " +
"The Repository accessibility report lists all the artifact repositories known to the project and whether " +
"respond to network access. The network access is attempted while the recipe is run and so is " +
"representative of current conditions. \n\n" +
"The Gradle dependency configuration errors lists all the dependency configurations that failed to " +
"resolve one or more dependencies when the project was parsed. This is representative of conditions at " +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.openrewrite.java.dependencies;

import org.junit.jupiter.api.Test;
import org.openrewrite.maven.Assertions;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.maven.Assertions.pomXml;

public class DependencyInsightTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new DependencyInsight("org.springframework*", "*"));
}

@Test
void maven() {
rewriteRun(
//language=xml
pomXml("""
<project>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.6.RELEASE</version>
</dependency>
</dependencies>
</project>
""",
"""
<project>
<groupId></groupId>
<artifactId></artifactId>
<version></version>
<dependencies>
<!--~~>--><dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>5.2.6.RELEASE</version>
</dependency>
</dependencies>
</project>
""")
);
}
}

0 comments on commit b079b23

Please sign in to comment.