Skip to content

Commit

Permalink
Add skip parameter and logging to module info compiler plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
jduo committed Nov 28, 2023
1 parent 2c69ca2 commit 9510c30
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,19 @@ public class ModuleInfoCompilerPlugin extends AbstractMojo {
required = true)
private final List<String> compileSourceRoots = new ArrayList<>();

@Parameter(defaultValue = "false", property = "skip", required = false)
private boolean skip = false;

@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;

@Override
public void execute() throws MojoExecutionException {
if (skip) {
getLog().info("Skipping module-info-compiler-maven-plugin");
return;
}

Optional<File> moduleInfoFile = findFirstModuleInfo(compileSourceRoots);
if (moduleInfoFile.isPresent()) {
// The compiled module-info.class file goes into target/classes/module-info/main
Expand All @@ -69,9 +77,12 @@ public void execute() throws MojoExecutionException {
StandardCharsets.UTF_8);
OutputStream output = Files.newOutputStream(targetPath)) {
compiler.compile(reader, output);
getLog().info("Successfully wrote module-info.class file.");
} catch (IOException ex) {
throw new MojoExecutionException("Error compiling module-info.java", ex);
}
} else {
getLog().info("No module-info.java file found. module-info.class file was not generated.");
}
}

Expand Down

0 comments on commit 9510c30

Please sign in to comment.