Skip to content

Commit

Permalink
Improve 'discover' goal behaviour for multi-module/no projects (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsibilio authored Jun 26, 2022
1 parent eeeef6f commit cbe6aa7
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* {@code ./mvnw rewrite:discover -Ddetail=true -Drecipe=<recipe-name>} to display recipe configuration details. For example:<br>
* {@code ./mvnw rewrite:discover -Ddetail=true -Drecipe=org.openrewrite.java.format.AutoFormat}
*/
@Mojo(name = "discover", threadSafe = true)
@Mojo(name = "discover", threadSafe = true, requiresProject = false, aggregator = true)
@SuppressWarnings("unused")
public class RewriteDiscoverMojo extends AbstractRewriteMojo {

Expand Down
12 changes: 12 additions & 0 deletions src/test/java/org/openrewrite/maven/RewriteDiscoverIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,16 @@ void rewrite_discover_rewrite_yml(MavenExecutionResult result) {
assertThat(result).out().warn().isEmpty();
}

@MavenTest
void rewrite_discover_multi_module(MavenExecutionResult result) {
assertThat(result)
.isSuccessful()
.out()
.info()
.anySatisfy(line -> assertThat(line).matches("^a.*SKIPPED$"))
.anySatisfy(line -> assertThat(line).matches("^b.*SKIPPED$"));

assertThat(result).out().warn().isEmpty();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite_discover_multi_module</artifactId>
<version>1.0</version>
</parent>

<artifactId>a</artifactId>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite_discover_multi_module</artifactId>
<version>1.0</version>
</parent>

<artifactId>b</artifactId>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite_discover_multi_module</artifactId>
<version>1.0</version>
<packaging>pom</packaging>
<name>RewriteDiscoverIT#multi_module</name>

<modules>
<module>a</module>
<module>b</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
<configuration>
<pomCacheDirectory>
${project.build.directory}/maven-it/org/openrewrite/maven/RewriteDiscoverIT/rewrite_discover_multi_module/project/target/pomCache
</pomCacheDirectory>
</configuration>
</plugin>
</plugins>
</build>
</project>

0 comments on commit cbe6aa7

Please sign in to comment.