Skip to content

Commit

Permalink
Change propertynames for skipIfMissing
Browse files Browse the repository at this point in the history
Align with other plugins, use buildhelper prefix and plugin name.
  • Loading branch information
hgschmie authored and slawekjaranowski committed Nov 20, 2023
1 parent c0b039e commit 0bef954
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@ public abstract class AbstractAddResourceMojo extends AbstractMojo {
@Parameter(readonly = true, defaultValue = "${project}")
private MavenProject project;

/**
* If a resource directory does not exist, do not add it as a root.
*
* @since 3.4.1
*/
@Parameter(property = "skipIfMissing", defaultValue = "false")
private boolean skipIfMissing;

/**
* Main plugin execution
*/
Expand All @@ -75,7 +67,7 @@ public void execute() {
resource.setDirectory(resourceDir.getAbsolutePath());
}

if (skipIfMissing && !resourceDir.exists()) {
if (isSkipIfMissing() && !resourceDir.exists()) {
if (getLog().isDebugEnabled()) {
getLog().debug("Skipping directory: " + resourceDir + ", because it does not exist.");
}
Expand All @@ -85,6 +77,8 @@ public void execute() {
}
}

protected abstract boolean isSkipIfMissing();

protected abstract boolean isSkip();

/**
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/codehaus/mojo/buildhelper/AddResourceMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,25 @@ public class AddResourceMojo extends AbstractAddResourceMojo {
@Parameter(property = "buildhelper.addresource.skip", defaultValue = "false")
private boolean skipAddResource;

/**
* If a resource directory does not exist, do not add it as a root.
*
* @since 3.5.0
*/
@Parameter(property = "buildhelper.addresource.skipIfMissing", defaultValue = "false")
private boolean skipIfMissing;

public void addResource(Resource resource) {
getProject().addResource(resource);
if (getLog().isDebugEnabled()) {
getLog().debug("Added resource: " + resource.getDirectory());
}
}

protected boolean isSkipIfMissing() {
return skipIfMissing;
}

protected boolean isSkip() {
return skipAddResource;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public class AddSourceMojo extends AbstractMojo {
/**
* If a directory does not exist, do not add it as a source root.
*
* @since 3.4.1
* @since 3.5.0
*/
@Parameter(property = "skipIfMissing", defaultValue = "false")
@Parameter(property = "buildhelper.addsource.skipIfMissing", defaultValue = "false")
private boolean skipIfMissing;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public class AddTestResourceMojo extends AbstractAddResourceMojo {
@Parameter(property = "buildhelper.addtestresource.skip", defaultValue = "false")
private boolean skipAddTestResource;

/**
* If a test resource directory does not exist, do not add it as a root.
*
* @since 3.5.0
*/
@Parameter(property = "buildhelper.addtestresource.skipIfMissing", defaultValue = "false")
private boolean skipIfMissing;

/**
* Add the resource to the project.
*
Expand All @@ -62,4 +70,8 @@ public void addResource(Resource resource) {
protected boolean isSkip() {
return skipAddTestResource;
}

protected boolean isSkipIfMissing() {
return skipIfMissing;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public class AddTestSourceMojo extends AbstractMojo {
/**
* If a directory does not exist, do not add it as a test source root.
*
* @since 3.4.1
* @since 3.5.0
*/
@Parameter(property = "skipIfMissing", defaultValue = "false")
@Parameter(property = "buildhelper.addtestsource.skipIfMissing", defaultValue = "false")
private boolean skipIfMissing;

/**
Expand Down

0 comments on commit 0bef954

Please sign in to comment.