Skip to content

Commit

Permalink
Add skip parameter to execute mojo (groovy#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Oct 14, 2021
1 parent 2e1c240 commit acd86c6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ public class ExecuteMojo
@Parameter
private Map<String, String> defaults;


/**
* Skip the execution of this mojo.
*
* @since 2.2.0
*/
@Parameter(property = "gmaven.execute.skip", defaultValue = "false")
private boolean skip;

@Override
protected void run() throws Exception {
final ClassSource classSource = classSourceFactory.create(source);
Expand All @@ -101,4 +110,10 @@ protected void customizeProperties(final PropertiesBuilder builder) {
builder.setProperties(properties)
.setDefaults(defaults);
}

@Override
protected boolean isSkipped() {
return skip;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ protected MojoSupport() {
}

public void execute() throws MojoExecutionException, MojoFailureException {
if (isSkipped()) {
getLog().info("Skipping as requested by the user");
return;
}
try {
try {
log.trace("Prepare");
Expand Down Expand Up @@ -67,4 +71,8 @@ protected void prepare() throws Exception {
protected void cleanup() throws Exception {
// empty
}

protected boolean isSkipped() {
return false;
}
}

0 comments on commit acd86c6

Please sign in to comment.