Skip to content

Commit

Permalink
Skip shamrock:dev on projects that do not have the build goal configured
Browse files Browse the repository at this point in the history
This allows Shamrock to work in multi-module project, the dev goal will only
be run for the actual shamrock app, not parent poms or support libraries.
  • Loading branch information
stuartwdouglas committed Jan 17, 2019
1 parent c47abe5 commit caf9a46
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions maven/src/main/java/org/jboss/shamrock/maven/DevMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.util.zip.ZipOutputStream;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.Resource;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoFailureException;
Expand Down Expand Up @@ -107,6 +109,23 @@ public class DevMojo extends AbstractMojo {

@Override
public void execute() throws MojoFailureException {

boolean found = false;
for(Plugin i : project.getBuildPlugins()) {
if(i.getGroupId().equals("org.jboss.shamrock") && i.getArtifactId().equals("shamrock-maven-plugin")) {
for(PluginExecution p : i.getExecutions()) {
if(p.getGoals().contains("build")) {
found = true;
break;
}
}
}
}
if(!found) {
getLog().warn("The shamrock-maven-plugin build goal was not configured for this project, skipping shamrock:dev as this is assumed to be a support library. If you want to run shamrock dev on this project make sure the shamrock-maven-plugin is configured with a build goal.");
return;
}

if (! sourceDir.isDirectory()) {
throw new MojoFailureException("The `src/main/java` directory is required, please create it.");
}
Expand Down

0 comments on commit caf9a46

Please sign in to comment.