Skip to content

Commit

Permalink
Fix mojohaus#202 - use-reactor update parents
Browse files Browse the repository at this point in the history
  • Loading branch information
amuniz committed Sep 5, 2017
1 parent be04640 commit e9efb66
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/main/java/org/codehaus/mojo/versions/UseReactorMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ protected void update( ModifiedPomXMLEventReader pom )
{
try
{
if ( isProcessingParent() && getProject().hasParent() ) {
useReactor( pom, getProject().getParent() );
}
if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() )
{
useReactor( pom, getProject().getDependencyManagement().getDependencies() );
Expand Down Expand Up @@ -104,4 +107,23 @@ private void useReactor( ModifiedPomXMLEventReader pom, Collection<Dependency> d
}
}

private void useReactor( ModifiedPomXMLEventReader pom, MavenProject parent )
throws XMLStreamException, MojoExecutionException, ArtifactMetadataRetrievalException
{
for ( Object reactorProject : reactorProjects )
{
MavenProject project = (MavenProject) reactorProject;
if ( StringUtils.equals( project.getGroupId(), parent.getGroupId() )
&& StringUtils.equals( project.getArtifactId(), parent.getArtifactId() )
&& !StringUtils.equals( project.getVersion(), parent.getVersion() ) )
{
if ( PomHelper.setProjectParentVersion( pom, project.getVersion() ) )
{
getLog().info( "Updated parent " + toString( parent ) + " to version " + project.getVersion() );
}
}

}
}

}

0 comments on commit e9efb66

Please sign in to comment.