Skip to content

Commit

Permalink
implements #198 add an optional processAllModules to process all modu…
Browse files Browse the repository at this point in the history
…les even those without parent/child relation

Signed-off-by: olivier lamy <[email protected]>
  • Loading branch information
olamy committed Aug 16, 2017
1 parent bc0a32d commit 3d8c4ab
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/main/java/org/codehaus/mojo/versions/SetMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -384,27 +392,28 @@ private void applyChange( MavenProject project, SortedMap<String, Model> reactor
getLog().debug( "Looking for modules which use "
+ ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + " as their parent" );

for ( Map.Entry<String, Model> stringModelEntry : PomHelper.getChildModels( reactor, sourceGroupId,
for ( Map.Entry<String, Model> 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 );
}
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 ),
Expand Down

0 comments on commit 3d8c4ab

Please sign in to comment.