mirror of https://github.com/apache/maven.git
fix NPE in dependencies report
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@220050 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
186f48083f
commit
813a3b8040
|
@ -17,6 +17,7 @@ package org.apache.maven.report.projectinfo;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.model.Dependency;
|
import org.apache.maven.model.Dependency;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
|
@ -84,6 +85,13 @@ public class DependenciesReport
|
||||||
*/
|
*/
|
||||||
private MavenProjectBuilder mavenProjectBuilder;
|
private MavenProjectBuilder mavenProjectBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @parameter expression="${localRepository}"
|
||||||
|
* @required
|
||||||
|
* @readonly
|
||||||
|
*/
|
||||||
|
private ArtifactRepository localRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
|
* @see org.apache.maven.reporting.MavenReport#getName(java.util.Locale)
|
||||||
*/
|
*/
|
||||||
|
@ -139,7 +147,7 @@ public class DependenciesReport
|
||||||
throws MavenReportException
|
throws MavenReportException
|
||||||
{
|
{
|
||||||
DependenciesRenderer r = new DependenciesRenderer( getSink(), getProject(), locale, mavenProjectBuilder,
|
DependenciesRenderer r = new DependenciesRenderer( getSink(), getProject(), locale, mavenProjectBuilder,
|
||||||
artifactFactory );
|
artifactFactory, localRepository );
|
||||||
|
|
||||||
r.render();
|
r.render();
|
||||||
}
|
}
|
||||||
|
@ -163,8 +171,11 @@ public class DependenciesReport
|
||||||
|
|
||||||
private MavenProjectBuilder mavenProjectBuilder;
|
private MavenProjectBuilder mavenProjectBuilder;
|
||||||
|
|
||||||
|
private ArtifactRepository localRepository;
|
||||||
|
|
||||||
public DependenciesRenderer( Sink sink, MavenProject project, Locale locale,
|
public DependenciesRenderer( Sink sink, MavenProject project, Locale locale,
|
||||||
MavenProjectBuilder mavenProjectBuilder, ArtifactFactory artifactFactory )
|
MavenProjectBuilder mavenProjectBuilder, ArtifactFactory artifactFactory,
|
||||||
|
ArtifactRepository localRepository )
|
||||||
{
|
{
|
||||||
super( sink );
|
super( sink );
|
||||||
|
|
||||||
|
@ -175,6 +186,8 @@ public class DependenciesReport
|
||||||
this.mavenProjectBuilder = mavenProjectBuilder;
|
this.mavenProjectBuilder = mavenProjectBuilder;
|
||||||
|
|
||||||
this.artifactFactory = artifactFactory;
|
this.artifactFactory = artifactFactory;
|
||||||
|
|
||||||
|
this.localRepository = localRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTitle()
|
public String getTitle()
|
||||||
|
@ -187,7 +200,7 @@ public class DependenciesReport
|
||||||
// Dependencies report
|
// Dependencies report
|
||||||
List dependencies = project.getDependencies();
|
List dependencies = project.getDependencies();
|
||||||
|
|
||||||
if ( ( dependencies == null ) || ( dependencies.isEmpty() ) )
|
if ( dependencies == null || dependencies.isEmpty() )
|
||||||
{
|
{
|
||||||
startSection( getTitle() );
|
startSection( getTitle() );
|
||||||
|
|
||||||
|
@ -224,7 +237,7 @@ public class DependenciesReport
|
||||||
MavenProject artifactProject = null;
|
MavenProject artifactProject = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artifactProject = getMavenProjectFromRepository( artifact );
|
artifactProject = getMavenProjectFromRepository( artifact, localRepository );
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
{
|
{
|
||||||
|
@ -269,7 +282,7 @@ public class DependenciesReport
|
||||||
MavenProject artifactProject = null;
|
MavenProject artifactProject = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
artifactProject = getMavenProjectFromRepository( artifact );
|
artifactProject = getMavenProjectFromRepository( artifact, localRepository );
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
{
|
{
|
||||||
|
@ -277,8 +290,6 @@ public class DependenciesReport
|
||||||
"Can't find a valid Maven project in the repository for the artifact ["
|
"Can't find a valid Maven project in the repository for the artifact ["
|
||||||
+ artifact + "]." );
|
+ artifact + "]." );
|
||||||
}
|
}
|
||||||
System.out.println( "nklj-----------------------------" );
|
|
||||||
System.out.println( artifactProject.getUrl() );
|
|
||||||
tableRow( new String[] {
|
tableRow( new String[] {
|
||||||
artifact.getGroupId(),
|
artifact.getGroupId(),
|
||||||
artifact.getArtifactId(),
|
artifact.getArtifactId(),
|
||||||
|
@ -308,7 +319,7 @@ public class DependenciesReport
|
||||||
List dependencies = project.getDependencies();
|
List dependencies = project.getDependencies();
|
||||||
Set artifacts = project.getArtifacts();
|
Set artifacts = project.getArtifacts();
|
||||||
|
|
||||||
if ( ( dependencies == null ) || ( artifacts == null ) )
|
if ( dependencies == null || artifacts == null )
|
||||||
{
|
{
|
||||||
return transitiveDependencies;
|
return transitiveDependencies;
|
||||||
}
|
}
|
||||||
|
@ -345,14 +356,13 @@ public class DependenciesReport
|
||||||
* @param artifact
|
* @param artifact
|
||||||
* an artifact
|
* an artifact
|
||||||
* @return the Maven project for the given artifact
|
* @return the Maven project for the given artifact
|
||||||
* @throws ProjectBuildingException
|
* @throws org.apache.maven.project.ProjectBuildingException
|
||||||
* if any
|
* if any
|
||||||
*/
|
*/
|
||||||
private MavenProject getMavenProjectFromRepository( Artifact artifact )
|
private MavenProject getMavenProjectFromRepository( Artifact artifact, ArtifactRepository localRepository )
|
||||||
throws ProjectBuildingException
|
throws ProjectBuildingException
|
||||||
{
|
{
|
||||||
return mavenProjectBuilder.buildFromRepository( artifact, project.getRepositories(), artifact
|
return mavenProjectBuilder.buildFromRepository( artifact, project.getRepositories(), localRepository );
|
||||||
.getRepository() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue