Skip to content

Commit

Permalink
fix #25 use raw model for dependencyManagement
Browse files Browse the repository at this point in the history
  • Loading branch information
tavin committed Jun 12, 2016
1 parent ddf38a1 commit 54ba815
Showing 1 changed file with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@
import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.Model;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.mojo.versions.api.ArtifactVersions;
import org.codehaus.mojo.versions.api.PomHelper;
import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;

import javax.xml.stream.XMLStreamException;
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;

Expand Down Expand Up @@ -85,7 +88,11 @@ protected void update( ModifiedPomXMLEventReader pom )
{
if ( getProject().getDependencyManagement() != null && isProcessingDependencyManagement() )
{
useLatestVersions( pom, getProject().getDependencyManagement().getDependencies() );
DependencyManagement dependencyManagement = PomHelper.getRawModel( getProject() ).getDependencyManagement();
if ( dependencyManagement != null )
{
useLatestVersions( pom, dependencyManagement.getDependencies() );
}
}
if ( isProcessingDependencies() )
{
Expand All @@ -96,6 +103,9 @@ protected void update( ModifiedPomXMLEventReader pom )
{
throw new MojoExecutionException( e.getMessage(), e );
}
catch ( IOException e ) {
throw new MojoExecutionException( e.getMessage(), e );
}
}

private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection dependencies )
Expand Down Expand Up @@ -136,4 +146,4 @@ private void useLatestVersions( ModifiedPomXMLEventReader pom, Collection depend
}
}

}
}

0 comments on commit 54ba815

Please sign in to comment.