diff --git a/src/main/java/org/codehaus/mojo/flatten/FlattenDescriptor.java b/src/main/java/org/codehaus/mojo/flatten/FlattenDescriptor.java index ecadddae..034cfb07 100644 --- a/src/main/java/org/codehaus/mojo/flatten/FlattenDescriptor.java +++ b/src/main/java/org/codehaus/mojo/flatten/FlattenDescriptor.java @@ -35,6 +35,7 @@ public class FlattenDescriptor { private final Map name2handlingMap; + private ElementHandling defaultOperation = ElementHandling.flatten; /** * The constructor. @@ -59,6 +60,14 @@ public FlattenDescriptor(Xpp3Dom descriptor) { } } + public ElementHandling getDefaultOperation() { + return defaultOperation; + } + + public void setDefaultOperation(ElementHandling defaultOperation) { + this.defaultOperation = defaultOperation; + } + /** * Generic method to get a {@link ElementHandling}. * @@ -68,7 +77,7 @@ public FlattenDescriptor(Xpp3Dom descriptor) { public ElementHandling getHandling(PomProperty property) { ElementHandling handling = this.name2handlingMap.get(property.getName()); if (handling == null) { - handling = ElementHandling.flatten; + handling = defaultOperation; } return handling; } diff --git a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java index 5d1f4f21..dab60c26 100644 --- a/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java +++ b/src/main/java/org/codehaus/mojo/flatten/FlattenMojo.java @@ -357,6 +357,14 @@ public class FlattenMojo extends AbstractFlattenMojo { @Parameter(property = "flatten.dependency.keepComments", required = false, defaultValue = "false") private boolean keepCommentsInPom; + /** + * The default operation to use when no element handling is given. Defaults to flatten. + * + * @since 1.5.1 + */ + @Parameter(property = "flatten.dependency.defaultOperation", required = false, defaultValue = "flatten") + private ElementHandling defaultOperation; + @Inject private DirectDependenciesInheritanceAssembler inheritanceAssembler; @@ -767,10 +775,12 @@ private FlattenDescriptor getFlattenDescriptor() throws MojoFailureException { Xpp3Dom rawDescriptor = this.mojoExecution.getConfiguration().getChild("pomElements"); descriptor = new FlattenDescriptor(rawDescriptor); } + if (this.flattenMode != null) { descriptor = descriptor.merge(this.flattenMode.getDescriptor()); } } + descriptor.setDefaultOperation(defaultOperation); return descriptor; }