### Eclipse Workspace Patch 1.0 #P versions-maven-plugin Index: src/main/java/org/codehaus/mojo/versions/SetMojo.java =================================================================== --- src/main/java/org/codehaus/mojo/versions/SetMojo.java (revision 16129) +++ src/main/java/org/codehaus/mojo/versions/SetMojo.java (working copy) @@ -215,8 +215,12 @@ // now fake out the triggering change final Model current = PomHelper.getModel( reactor, getProject().getGroupId(), getProject().getArtifactId() ); + String currentVersion = PomHelper.getVersion(current); current.setVersion( newVersion ); - + final String groupId = PomHelper.getGroupId( current ); + final String artifactId = PomHelper.getArtifactId( current ); + final String version = PomHelper.getVersion( current ); + processChildren(reactor, groupId, artifactId, currentVersion, version); final Set files = new LinkedHashSet(); files.add( getProject().getFile() ); @@ -268,60 +272,6 @@ } files.add( moduleProjectFile ); - - getLog().debug( - "Looking for modules which use " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) - + " as their parent" ); - - final Iterator j = - PomHelper.getChildModels( reactor, sourceGroupId, sourceArtifactId ).entrySet().iterator(); - - while ( j.hasNext() ) - { - final Map.Entry target = (Map.Entry) j.next(); - final String targetPath = (String) target.getKey(); - final Model targetModel = (Model) target.getValue(); - final Parent parent = targetModel.getParent(); - getLog().debug( "Module: " + targetPath ); - if ( 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() ); - getLog().debug( - " will become " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" - + sourceVersion ); - } - final boolean targetExplicit = PomHelper.isExplicitVersion( targetModel ); - if ( ( updateMatchingVersions.booleanValue() || !targetExplicit ) && StringUtils.equals( - parent.getVersion(), PomHelper.getVersion( targetModel ) ) ) - { - getLog().debug( " module is " - + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) + ":" - + PomHelper.getVersion( targetModel ) ); - getLog().debug( " will become " - + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) + ":" - + sourceVersion ); - addChange( PomHelper.getGroupId( targetModel ), PomHelper.getArtifactId( targetModel ), - PomHelper.getVersion( targetModel ), sourceVersion ); - targetModel.setVersion( sourceVersion ); - } - else - { - getLog().debug( " module is " - + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), - PomHelper.getArtifactId( targetModel ) ) + ":" - + PomHelper.getVersion( targetModel ) ); - } - } } // now process all the updates @@ -337,6 +287,60 @@ throw new MojoExecutionException( e.getMessage(), e ); } } + + protected void processChildren(Map reactor, String sourceGroupId, String sourceArtifactId, String originalVersion, String sourceVersion) { + + final Iterator j = reactor.entrySet().iterator(); + while ( j.hasNext() ) + { + final Map.Entry target = (Map.Entry) j.next(); + final String targetPath = (String) target.getKey(); + final Model targetModel = (Model) target.getValue(); + final Parent parent = targetModel.getParent(); + getLog().debug( "Module: " + targetPath ); + if ( sourceGroupId.equals( parent.getGroupId() ) && + sourceArtifactId.equals( parent.getArtifactId()) ) { + if (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() ); + getLog().debug( + " will become " + ArtifactUtils.versionlessKey( sourceGroupId, sourceArtifactId ) + ":" + + sourceVersion ); + } + } + final boolean targetExplicit = PomHelper.isExplicitVersion( targetModel ); + if ( ( updateMatchingVersions.booleanValue() || !targetExplicit ) && StringUtils.equals( + originalVersion, PomHelper.getVersion( targetModel ) ) ) + { + getLog().debug( " module is " + + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), + PomHelper.getArtifactId( targetModel ) ) + ":" + + PomHelper.getVersion( targetModel ) ); + getLog().debug( " will become " + + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), + PomHelper.getArtifactId( targetModel ) ) + ":" + + sourceVersion ); + addChange( PomHelper.getGroupId( targetModel ), PomHelper.getArtifactId( targetModel ), + PomHelper.getVersion( targetModel ), sourceVersion ); + targetModel.setVersion( sourceVersion ); + } + else + { + getLog().debug( " module is " + + ArtifactUtils.versionlessKey( PomHelper.getGroupId( targetModel ), + PomHelper.getArtifactId( targetModel ) ) + ":" + + PomHelper.getVersion( targetModel ) ); + } + } + } /** * Updates the pom file.