diff --git a/src/main/java/org/codehaus/mojo/versions/SetMojo.java b/src/main/java/org/codehaus/mojo/versions/SetMojo.java index dd86f6ec84..7defc84836 100644 --- a/src/main/java/org/codehaus/mojo/versions/SetMojo.java +++ b/src/main/java/org/codehaus/mojo/versions/SetMojo.java @@ -180,6 +180,14 @@ public class SetMojo @Parameter( property = "nextSnapshot", defaultValue = "false" ) private boolean nextSnapshot; + /** + * Whether to process all modules whereas they have parent/child or not. + * + * @since 2.5 + */ + @Parameter( property = "processAllModules", defaultValue = "false" ) + private boolean processAllModules; + /** * The changes to module coordinates. Guarded by this. */ @@ -384,13 +392,14 @@ private void applyChange( MavenProject project, SortedMap reactor getLog().debug( "Looking for modules which use " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + " as their parent" ); - for ( Map.Entry stringModelEntry : PomHelper.getChildModels( reactor, sourceGroupId, + for ( Map.Entry stringModelEntry : processAllModules ? reactor.entrySet() : // + PomHelper.getChildModels( reactor, sourceGroupId, sourceArtifactId ).entrySet() ) { final Model targetModel = stringModelEntry.getValue(); final Parent parent = targetModel.getParent(); getLog().debug( "Module: " + stringModelEntry.getKey() ); - if ( sourceVersion.equals( parent.getVersion() ) ) + if ( parent != null && sourceVersion.equals( parent.getVersion() ) ) { getLog().debug( " parent already is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + sourceVersion ); @@ -398,13 +407,13 @@ private void applyChange( MavenProject project, SortedMap reactor else { getLog().debug( " parent is " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) - + ":" + parent.getVersion() ); + + ":" + ( parent == null ? "" : parent.getVersion() )); getLog().debug( " will become " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + sourceVersion ); } final boolean targetExplicit = PomHelper.isExplicitVersion( targetModel ); - if ( ( updateMatchingVersions || !targetExplicit ) - && StringUtils.equals( parent.getVersion(), PomHelper.getVersion( targetModel ) ) ) + if ( ( updateMatchingVersions || !targetExplicit ) // + && ( processAllModules || StringUtils.equals( parent.getVersion(), PomHelper.getVersion( targetModel ) ) ) ) { getLog().debug( " module is " + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ),