Hi, We have a requirement whereby we do not want the rpm build to fail if a source.location does not exist. We were doing the same previously by using the antrun plugin to, for example, safely create empty directories under certain profile combinations so that the rpm build doesn't fail, but it's ugly.
I've now created a patch which adds a failIfNotExists option to Source. Then, in FileHelper, if the location does not exist and you've set the option to false then the build will just log a warning, and continue. The default behaviour is to fail as before. Could this be considered for merge? I've attached the diff here. I was going to create an issue in JIRA as per the contributions guidance but I don't have an account and I'm not sure who to contact. Thanks, Dave Maughan
Index: src/main/java/org/codehaus/mojo/rpm/FileHelper.java =================================================================== --- src/main/java/org/codehaus/mojo/rpm/FileHelper.java (revision 20225) +++ src/main/java/org/codehaus/mojo/rpm/FileHelper.java (working copy) @@ -469,6 +469,11 @@ map.addCopiedFileNameRelativeToDestination( destination ); } } + else if (!src.getFailIfNotExists()) + { + mojo.getLog().warn( + "Source location " + macroEvaluatedLocation + " does not exist, but failIfNotExist was set to false"); + } else { throw new MojoExecutionException( "Source location " + macroEvaluatedLocation + " does not exist" ); Index: src/main/java/org/codehaus/mojo/rpm/Source.java =================================================================== --- src/main/java/org/codehaus/mojo/rpm/Source.java (revision 20225) +++ src/main/java/org/codehaus/mojo/rpm/Source.java (working copy) @@ -97,6 +97,11 @@ private String macroEvaluatedLocation; /** + * Fail if the {@link #location} does not exist. + */ + private boolean failIfNotExists = true; + + /** * Retrieve the location holding the file(s) to install. * * @return The location holding the file(s) to install. @@ -308,6 +313,22 @@ this.macroEvaluatedLocation = macroEvaluatedLocation; } + /** + * @return Returns the {@link #failIfNotExists}. + */ + public boolean getFailIfNotExists() + { + return failIfNotExists; + } + + /** + * @param failIfNotExists The {@link #failIfNotExists} to set. + */ + public void setFailIfNotExists(boolean failIfNotExists) + { + this.failIfNotExists = failIfNotExists; + } + /** {@inheritDoc} */ public String toString() { @@ -322,6 +343,7 @@ { sb.append( "\"" + location + "\"" ); } + sb.append(" failIfNotExists:" + failIfNotExists); if ( includes != null ) {
--------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email