o push out the artifact repository creation when it's requested in the project

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@751159 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2009-03-07 01:05:17 +00:00
parent 0f3af9305d
commit 30e6002f40
5 changed files with 41 additions and 19 deletions

View File

@ -1846,7 +1846,7 @@ public Artifact resolvePluginArtifact( Plugin plugin, MavenProject project, Mave
MavenProject pluginProject = buildPluginProject( plugin, localRepository, project.getRemoteArtifactRepositories() ); MavenProject pluginProject = buildPluginProject( plugin, localRepository, project.getRemoteArtifactRepositories() );
Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion() ); Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin );
checkRequiredMavenVersion( plugin, pluginProject, localRepository, project.getRemoteArtifactRepositories() ); checkRequiredMavenVersion( plugin, pluginProject, localRepository, project.getRemoteArtifactRepositories() );

View File

@ -228,6 +228,8 @@ public MavenProject( Model model, MavenRepositorySystem repositorySystem, MavenP
this.projectBuilderConfiguration = projectBuilderConfiguration; this.projectBuilderConfiguration = projectBuilderConfiguration;
this.repositorySystem = repositorySystem; this.repositorySystem = repositorySystem;
originalModel = model; originalModel = model;
/*
DistributionManagement dm = model.getDistributionManagement(); DistributionManagement dm = model.getDistributionManagement();
if ( dm != null ) if ( dm != null )
@ -235,12 +237,8 @@ public MavenProject( Model model, MavenRepositorySystem repositorySystem, MavenP
ArtifactRepository repo = repositorySystem.buildArtifactRepository( dm.getRepository() ); ArtifactRepository repo = repositorySystem.buildArtifactRepository( dm.getRepository() );
setReleaseArtifactRepository( repo ); setReleaseArtifactRepository( repo );
if ( dm.getSnapshotRepository() != null )
{
repo = repositorySystem.buildArtifactRepository( dm.getSnapshotRepository() );
setSnapshotArtifactRepository( repo );
}
} }
*/
setRemoteArtifactRepositories( projectBuilderConfiguration.getRemoteRepositories() ); setRemoteArtifactRepositories( projectBuilderConfiguration.getRemoteRepositories() );
} }
@ -1098,7 +1096,7 @@ public Set<Artifact> getPluginArtifacts()
version = p.getVersion(); version = p.getVersion();
} }
Artifact artifact = repositorySystem.createPluginArtifact( p.getGroupId(), p.getArtifactId(), version ); Artifact artifact = repositorySystem.createPluginArtifact( p );
if ( artifact == null ) if ( artifact == null )
{ {
@ -1152,7 +1150,11 @@ public Set<Artifact> getReportArtifacts()
version = p.getVersion(); version = p.getVersion();
} }
Artifact artifact = repositorySystem.createPluginArtifact( p.getGroupId(), p.getArtifactId(), version ); Plugin pp = new Plugin();
pp.setGroupId( p.getGroupId() );
pp.setArtifactId( p.getArtifactId() );
pp.setVersion( version );
Artifact artifact = repositorySystem.createPluginArtifact( pp );
if ( artifact != null ) if ( artifact != null )
{ {
@ -1915,11 +1917,33 @@ protected void setScriptSourceRoots( List<String> scriptSourceRoots )
protected ArtifactRepository getReleaseArtifactRepository() protected ArtifactRepository getReleaseArtifactRepository()
{ {
if ( getDistributionManagement().getRepository() != null )
{
try
{
setReleaseArtifactRepository( repositorySystem.buildArtifactRepository( getDistributionManagement().getRepository() ) );
}
catch ( InvalidRepositoryException e )
{
}
}
return releaseArtifactRepository; return releaseArtifactRepository;
} }
protected ArtifactRepository getSnapshotArtifactRepository() protected ArtifactRepository getSnapshotArtifactRepository()
{ {
if ( getDistributionManagement().getSnapshotRepository() != null )
{
try
{
setSnapshotArtifactRepository( repositorySystem.buildArtifactRepository( getDistributionManagement().getSnapshotRepository() ) );
}
catch ( InvalidRepositoryException e )
{
}
}
return snapshotArtifactRepository; return snapshotArtifactRepository;
} }
@ -2041,6 +2065,7 @@ private void deepCopy( MavenProject project )
setManagedVersionMap( new ManagedVersionMap( project.getManagedVersionMap() ) ); setManagedVersionMap( new ManagedVersionMap( project.getManagedVersionMap() ) );
} }
/*
if ( project.getReleaseArtifactRepository() != null ) if ( project.getReleaseArtifactRepository() != null )
{ {
setReleaseArtifactRepository( project.getReleaseArtifactRepository() ); setReleaseArtifactRepository( project.getReleaseArtifactRepository() );
@ -2050,6 +2075,7 @@ private void deepCopy( MavenProject project )
{ {
setSnapshotArtifactRepository( project.getSnapshotArtifactRepository() ); setSnapshotArtifactRepository( project.getSnapshotArtifactRepository() );
} }
*/
} }
private void addArtifactPath( Artifact a, List<String> list ) private void addArtifactPath( Artifact a, List<String> list )

View File

@ -19,10 +19,7 @@
* under the License. * under the License.
*/ */
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.repository.MavenRepositorySystem;
import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
@Component(role=MavenProjectBuilder.class,hint="test") @Component(role=MavenProjectBuilder.class,hint="test")
public class TestProjectBuilder public class TestProjectBuilder

View File

@ -45,6 +45,7 @@
import org.apache.maven.artifact.versioning.VersionRange; import org.apache.maven.artifact.versioning.VersionRange;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.Exclusion; import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy; import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.wagon.authentication.AuthenticationInfo; import org.apache.maven.wagon.authentication.AuthenticationInfo;
@ -153,19 +154,19 @@ public Artifact createParentArtifact( String groupId, String artifactId, String
return artifactFactory.createParentArtifact( groupId, artifactId, version ); return artifactFactory.createParentArtifact( groupId, artifactId, version );
} }
public Artifact createPluginArtifact( String groupId, String artifactId, String version ) public Artifact createPluginArtifact( Plugin plugin )
{ {
VersionRange versionRange; VersionRange versionRange;
try try
{ {
versionRange = VersionRange.createFromVersionSpec( version ); versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() );
} }
catch ( InvalidVersionSpecificationException e ) catch ( InvalidVersionSpecificationException e )
{ {
return null; return null;
} }
return artifactFactory.createPluginArtifact( groupId, artifactId, versionRange ); return artifactFactory.createPluginArtifact( plugin.getGroupId(), plugin.getArtifactId(), versionRange );
} }
/** /**

View File

@ -32,6 +32,7 @@
import org.apache.maven.artifact.resolver.filter.ArtifactFilter; import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.artifact.versioning.ArtifactVersion; import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.wagon.events.TransferListener; import org.apache.maven.wagon.events.TransferListener;
@ -40,15 +41,12 @@
*/ */
public interface MavenRepositorySystem public interface MavenRepositorySystem
{ {
// Artifact creation: This needs to be reduced to fewer, if not one, method.
Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type ); Artifact createArtifact( String groupId, String artifactId, String version, String scope, String type );
Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId ); Artifact createProjectArtifact( String groupId, String artifactId, String metaVersionId );
Artifact createPluginArtifact( String groupId, String artifactId, String version ); Artifact createPluginArtifact( Plugin plugin );
// This is still only used in one place.
Artifact createDependencyArtifact( Dependency dependency ); Artifact createDependencyArtifact( Dependency dependency );
//REMOVE //REMOVE