mirror of https://github.com/apache/maven.git
o patch from Oleg for metadata processing required by a maven-artifact provider
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@613467 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
863d1fcb8c
commit
291d6a9199
|
@ -52,7 +52,8 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public class PomMetadataSource
|
public class PomMetadataSource
|
||||||
extends AbstractLogEnabled
|
extends AbstractLogEnabled
|
||||||
implements MetadataSource, Contextualizable
|
implements MetadataSource,
|
||||||
|
Contextualizable
|
||||||
{
|
{
|
||||||
public static final String ROLE_HINT = "default";
|
public static final String ROLE_HINT = "default";
|
||||||
|
|
||||||
|
@ -85,17 +86,24 @@ public class PomMetadataSource
|
||||||
|
|
||||||
MavenProject project = null;
|
MavenProject project = null;
|
||||||
|
|
||||||
Artifact pomArtifact = artifactFactory.createProjectArtifact( artifactMetadata.getGroupId(), artifactMetadata.getArtifactId(),
|
Artifact pomArtifact = artifactFactory.createProjectArtifact(
|
||||||
artifactMetadata.getVersion(), artifactMetadata.getScope() );
|
artifactMetadata.getGroupId()
|
||||||
|
, artifactMetadata.getArtifactId()
|
||||||
|
, artifactMetadata.getVersion()
|
||||||
|
);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository );
|
project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository );
|
||||||
|
if ( pomArtifact.getFile() != null )
|
||||||
|
{
|
||||||
|
artifactMetadata.setArtifactUri( pomArtifact.getFile().toURI().toString() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch ( InvalidProjectModelException e )
|
catch ( InvalidProjectModelException e )
|
||||||
{
|
{
|
||||||
// We want to capture this in the graph so that we can display the error to the user
|
// We want to capture this in the graph so that we can display the error to the user
|
||||||
artifactMetadata.setError( e.getMessage() );
|
artifactMetadata.setError( e.getMessage() );
|
||||||
}
|
}
|
||||||
catch ( ProjectBuildingException e )
|
catch ( ProjectBuildingException e )
|
||||||
{
|
{
|
||||||
|
@ -112,7 +120,9 @@ public class PomMetadataSource
|
||||||
for ( Iterator i = project.getDependencies().iterator(); i.hasNext(); )
|
for ( Iterator i = project.getDependencies().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
Dependency d = (Dependency) i.next();
|
Dependency d = (Dependency) i.next();
|
||||||
artifacts.add( new ArtifactMetadata( d.getGroupId(), d.getArtifactId(), d.getVersion() ) );
|
|
||||||
|
artifacts.add( new ArtifactMetadata( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getType(),
|
||||||
|
d.getScope(), d.getClassifier(), null, null, false, null ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// The remote repositories is intentially null here while working in the graph in the least invasive way
|
// The remote repositories is intentially null here while working in the graph in the least invasive way
|
||||||
|
@ -120,6 +130,7 @@ public class PomMetadataSource
|
||||||
// repositories lingering around or being aggregated after they are used. jvz
|
// repositories lingering around or being aggregated after they are used. jvz
|
||||||
|
|
||||||
artifactMetadata.setDependencies( artifacts );
|
artifactMetadata.setDependencies( artifacts );
|
||||||
|
|
||||||
return new MetadataResolution( artifactMetadata );
|
return new MetadataResolution( artifactMetadata );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue