mirror of https://github.com/apache/maven.git
refactoring of the resolveTransitiveDependencies call.
simplified by removing a bunch of duplicated code in addArtifacts - no need to merge, you have the full list. separated the original artifacts (dependency artifacts) from the resolved artifacts (getArtifacts) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191667 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ce86c9b87
commit
6cd2e31078
|
@ -92,8 +92,12 @@ public class DependenciesTask
|
||||||
ArtifactResolutionResult result;
|
ArtifactResolutionResult result;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Artifact pomArtifact = artifactFactory.createArtifact( pom.getGroupId(), pom.getArtifactId(),
|
||||||
|
pom.getVersion(), null, pom.getPackaging() );
|
||||||
|
|
||||||
List remoteArtifactRepositories = createRemoteArtifactRepositories( getRemoteRepositories() );
|
List remoteArtifactRepositories = createRemoteArtifactRepositories( getRemoteRepositories() );
|
||||||
result = resolver.resolveTransitively( artifacts, remoteArtifactRepositories, localRepo, metadataSource );
|
result = resolver.resolveTransitively( artifacts, pomArtifact, remoteArtifactRepositories, localRepo,
|
||||||
|
metadataSource );
|
||||||
}
|
}
|
||||||
catch ( ArtifactResolutionException e )
|
catch ( ArtifactResolutionException e )
|
||||||
{
|
{
|
||||||
|
|
|
@ -130,19 +130,32 @@ public class DefaultArtifactResolver
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
public ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories,
|
||||||
// Transitive modes
|
|
||||||
// ----------------------------------------------------------------------
|
|
||||||
|
|
||||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
|
|
||||||
ArtifactRepository localRepository,
|
ArtifactRepository localRepository,
|
||||||
|
ArtifactMetadataSource source )
|
||||||
|
throws ArtifactResolutionException
|
||||||
|
{
|
||||||
|
return resolveTransitively( artifact, remoteRepositories, localRepository, source, null );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories,
|
||||||
|
ArtifactRepository localRepository,
|
||||||
|
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||||
|
throws ArtifactResolutionException
|
||||||
|
{
|
||||||
|
return resolveTransitively( Collections.singleton( artifact ), null, remoteRepositories, localRepository,
|
||||||
|
source, filter );
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||||
|
List remoteRepositories, ArtifactRepository localRepository,
|
||||||
ArtifactMetadataSource source, ArtifactFilter filter )
|
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
ArtifactResolutionResult artifactResolutionResult;
|
ArtifactResolutionResult artifactResolutionResult;
|
||||||
|
|
||||||
artifactResolutionResult = artifactCollector.collect( artifacts, localRepository, remoteRepositories, source,
|
artifactResolutionResult = artifactCollector.collect( artifacts, originatingArtifact, localRepository,
|
||||||
filter, artifactFactory );
|
remoteRepositories, source, filter, artifactFactory );
|
||||||
|
|
||||||
for ( Iterator i = artifactResolutionResult.getArtifacts().values().iterator(); i.hasNext(); )
|
for ( Iterator i = artifactResolutionResult.getArtifacts().values().iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
|
@ -153,19 +166,12 @@ public class DefaultArtifactResolver
|
||||||
return artifactResolutionResult;
|
return artifactResolutionResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
|
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||||
ArtifactRepository localRepository,
|
List remoteRepositories, ArtifactRepository localRepository,
|
||||||
ArtifactMetadataSource source )
|
ArtifactMetadataSource source )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
return resolveTransitively( artifacts, remoteRepositories, localRepository, source, null );
|
return resolveTransitively( artifacts, originatingArtifact, remoteRepositories, localRepository, source, null );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories,
|
|
||||||
ArtifactRepository localRepository,
|
|
||||||
ArtifactMetadataSource source )
|
|
||||||
throws ArtifactResolutionException
|
|
||||||
{
|
|
||||||
return resolveTransitively( Collections.singleton( artifact ), remoteRepositories, localRepository, source );
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -22,6 +22,7 @@ import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -41,12 +42,16 @@ public class ArtifactResolverTest
|
||||||
{
|
{
|
||||||
private ArtifactResolver artifactResolver;
|
private ArtifactResolver artifactResolver;
|
||||||
|
|
||||||
|
private Artifact projectArtifact;
|
||||||
|
|
||||||
protected void setUp()
|
protected void setUp()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
artifactResolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
|
artifactResolver = (ArtifactResolver) lookup( ArtifactResolver.ROLE );
|
||||||
|
|
||||||
|
projectArtifact = createLocalArtifact( "project", "3.0" );
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String component()
|
protected String component()
|
||||||
|
@ -103,7 +108,8 @@ public class ArtifactResolverTest
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( g, remoteRepositories(),
|
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( g ),
|
||||||
|
projectArtifact, remoteRepositories(),
|
||||||
localRepository(), mds );
|
localRepository(), mds );
|
||||||
|
|
||||||
assertEquals( 2, result.getArtifacts().size() );
|
assertEquals( 2, result.getArtifacts().size() );
|
||||||
|
@ -141,7 +147,8 @@ public class ArtifactResolverTest
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( i, remoteRepositories(),
|
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections.singleton( i ),
|
||||||
|
projectArtifact, remoteRepositories(),
|
||||||
localRepository(), mds );
|
localRepository(), mds );
|
||||||
|
|
||||||
assertEquals( 2, result.getArtifacts().size() );
|
assertEquals( 2, result.getArtifacts().size() );
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
package org.apache.maven.artifact.resolver;/*
|
package org.apache.maven.artifact.resolver;
|
||||||
* Copyright 2001-2005 The Apache Software Foundation.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||||
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
@ -23,15 +26,16 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: describe
|
* Artifact collector - takes a set of original artifacts and resolves all of the best versions to use
|
||||||
|
* along with their metadata. No artifacts are downloaded.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public interface ArtifactCollector
|
public interface ArtifactCollector
|
||||||
{
|
{
|
||||||
ArtifactResolutionResult collect( Set artifacts, ArtifactRepository localRepository, List remoteRepositories,
|
ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact, ArtifactRepository localRepository,
|
||||||
ArtifactMetadataSource source, ArtifactFilter filter,
|
List remoteRepositories, ArtifactMetadataSource source, ArtifactFilter filter,
|
||||||
ArtifactFactory artifactFactory )
|
ArtifactFactory artifactFactory )
|
||||||
throws ArtifactResolutionException;
|
throws ArtifactResolutionException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,16 @@ public interface ArtifactResolver
|
||||||
ArtifactRepository localRepository, ArtifactMetadataSource source )
|
ArtifactRepository localRepository, ArtifactMetadataSource source )
|
||||||
throws ArtifactResolutionException;
|
throws ArtifactResolutionException;
|
||||||
|
|
||||||
ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
|
ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories,
|
||||||
|
ArtifactRepository localRepository, ArtifactMetadataSource source,
|
||||||
|
ArtifactFilter filter )
|
||||||
|
throws ArtifactResolutionException;
|
||||||
|
|
||||||
|
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories,
|
||||||
ArtifactRepository localRepository, ArtifactMetadataSource source )
|
ArtifactRepository localRepository, ArtifactMetadataSource source )
|
||||||
throws ArtifactResolutionException;
|
throws ArtifactResolutionException;
|
||||||
|
|
||||||
ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
|
ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact, List remoteRepositories,
|
||||||
ArtifactRepository localRepository, ArtifactMetadataSource source,
|
ArtifactRepository localRepository, ArtifactMetadataSource source,
|
||||||
ArtifactFilter filter )
|
ArtifactFilter filter )
|
||||||
throws ArtifactResolutionException;
|
throws ArtifactResolutionException;
|
||||||
|
|
|
@ -31,7 +31,7 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: describe
|
* Default implementation of the artifact collector.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
|
@ -39,7 +39,8 @@ import java.util.Set;
|
||||||
public class DefaultArtifactCollector
|
public class DefaultArtifactCollector
|
||||||
implements ArtifactCollector
|
implements ArtifactCollector
|
||||||
{
|
{
|
||||||
public ArtifactResolutionResult collect( Set artifacts, ArtifactRepository localRepository, List remoteRepositories,
|
public ArtifactResolutionResult collect( Set artifacts, Artifact originatingArtifact,
|
||||||
|
ArtifactRepository localRepository, List remoteRepositories,
|
||||||
ArtifactMetadataSource source, ArtifactFilter filter,
|
ArtifactMetadataSource source, ArtifactFilter filter,
|
||||||
ArtifactFactory artifactFactory )
|
ArtifactFactory artifactFactory )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
|
@ -91,12 +92,10 @@ public class DefaultArtifactCollector
|
||||||
|
|
||||||
if ( updateScope )
|
if ( updateScope )
|
||||||
{
|
{
|
||||||
// TODO: Artifact factory?
|
Artifact artifact = artifactFactory.createArtifact( knownArtifact.getGroupId(),
|
||||||
// TODO: [jc] Is this a better way to centralize artifact construction here?
|
knownArtifact.getArtifactId(), knownVersion,
|
||||||
|
newArtifact.getScope(),
|
||||||
Artifact artifact = artifactFactory.createArtifact(
|
knownArtifact.getType() );
|
||||||
knownArtifact.getGroupId(), knownArtifact.getArtifactId(), knownVersion,
|
|
||||||
newArtifact.getScope(), knownArtifact.getType() );
|
|
||||||
resolvedArtifacts.put( artifact.getDependencyConflictId(), artifact );
|
resolvedArtifacts.put( artifact.getDependencyConflictId(), artifact );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package org.apache.maven.artifact.resolver;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright 2001-2005 The Apache Software Foundation.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test the default artifact collector.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DefaultArtifactCollectorTest
|
||||||
|
extends TestCase
|
||||||
|
{
|
||||||
|
private ArtifactCollector artifactCollector;
|
||||||
|
|
||||||
|
protected void setUp()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
super.setUp();
|
||||||
|
this.artifactCollector = new DefaultArtifactCollector();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCircularDependencyNotIncludingCurrentProject()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testCircularDependencyIncludingCurrentProject()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -90,11 +90,6 @@ public class MavenSession
|
||||||
return localRepository;
|
return localRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getRemoteRepositories()
|
|
||||||
{
|
|
||||||
return project.getRemoteArtifactRepositories();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List getGoals()
|
public List getGoals()
|
||||||
{
|
{
|
||||||
return goals;
|
return goals;
|
||||||
|
|
|
@ -173,7 +173,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenProject project,
|
public PluginDescriptor verifyPlugin( String groupId, String artifactId, String version, MavenProject project,
|
||||||
Settings settings, ArtifactRepository localRepository )
|
Settings settings, ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException
|
throws ArtifactResolutionException, PluginManagerException, PluginVersionResolutionException
|
||||||
{
|
{
|
||||||
String pluginKey = groupId + ":" + artifactId;
|
String pluginKey = groupId + ":" + artifactId;
|
||||||
|
@ -222,14 +222,15 @@ public class DefaultPluginManager
|
||||||
catch ( PlexusContainerException e )
|
catch ( PlexusContainerException e )
|
||||||
{
|
{
|
||||||
throw new PluginManagerException(
|
throw new PluginManagerException(
|
||||||
"Error occurred in the artifact container attempting to download plugin "
|
"Error occurred in the artifact container attempting to download plugin " + groupId + ":" +
|
||||||
+ groupId + ":" + artifactId, e );
|
artifactId, e );
|
||||||
}
|
}
|
||||||
catch ( ArtifactResolutionException e )
|
catch ( ArtifactResolutionException e )
|
||||||
{
|
{
|
||||||
if ( ( groupId == null || artifactId == null || version == null || ( groupId.equals( e.getGroupId() )
|
if (
|
||||||
&& artifactId.equals( e.getArtifactId() ) && version.equals( e.getVersion() ) ) )
|
( groupId == null || artifactId == null || version == null ||
|
||||||
&& "maven-plugin".equals( e.getType() ) )
|
( groupId.equals( e.getGroupId() ) && artifactId.equals( e.getArtifactId() ) &&
|
||||||
|
version.equals( e.getVersion() ) ) ) && "maven-plugin".equals( e.getType() ) )
|
||||||
{
|
{
|
||||||
throw new PluginNotFoundException( e );
|
throw new PluginNotFoundException( e );
|
||||||
}
|
}
|
||||||
|
@ -240,8 +241,8 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
catch ( ComponentLookupException e )
|
catch ( ComponentLookupException e )
|
||||||
{
|
{
|
||||||
throw new PluginManagerException( "Internal configuration error while retrieving " + groupId + ":"
|
throw new PluginManagerException(
|
||||||
+ artifactId, e );
|
"Internal configuration error while retrieving " + groupId + ":" + artifactId, e );
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -256,7 +257,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addPlugin( String pluginKey, Artifact pluginArtifact, MavenProject project,
|
protected void addPlugin( String pluginKey, Artifact pluginArtifact, MavenProject project,
|
||||||
ArtifactRepository localRepository )
|
ArtifactRepository localRepository )
|
||||||
throws ArtifactResolutionException, ComponentLookupException, PlexusContainerException
|
throws ArtifactResolutionException, ComponentLookupException, PlexusContainerException
|
||||||
{
|
{
|
||||||
ArtifactResolver artifactResolver = null;
|
ArtifactResolver artifactResolver = null;
|
||||||
|
@ -277,7 +278,7 @@ public class DefaultPluginManager
|
||||||
addedPlugin.setClassRealm( child.getContainerRealm() );
|
addedPlugin.setClassRealm( child.getContainerRealm() );
|
||||||
|
|
||||||
// we're only setting the plugin's artifact itself as the artifact list, to allow it to be retrieved
|
// we're only setting the plugin's artifact itself as the artifact list, to allow it to be retrieved
|
||||||
// later when the plugin is first invoked. Retrieving this artifact will in turn allow us to
|
// later when the plugin is first invoked. Retrieving this artifact will in turn allow us to
|
||||||
// transitively resolve its dependencies, and add them to the plugin container...
|
// transitively resolve its dependencies, and add them to the plugin container...
|
||||||
addedPlugin.setArtifacts( Collections.singletonList( pluginArtifact ) );
|
addedPlugin.setArtifacts( Collections.singletonList( pluginArtifact ) );
|
||||||
}
|
}
|
||||||
|
@ -425,7 +426,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getReports( String groupId, String artifactId, String version, ReportSet reportSet,
|
public List getReports( String groupId, String artifactId, String version, ReportSet reportSet,
|
||||||
MavenSession session, MavenProject project )
|
MavenSession session, MavenProject project )
|
||||||
throws PluginManagerException, PluginVersionResolutionException, PluginConfigurationException
|
throws PluginManagerException, PluginVersionResolutionException, PluginConfigurationException
|
||||||
{
|
{
|
||||||
PluginDescriptor pluginDescriptor = getPluginDescriptor( groupId, artifactId, version );
|
PluginDescriptor pluginDescriptor = getPluginDescriptor( groupId, artifactId, version );
|
||||||
|
@ -478,14 +479,14 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
private Mojo getConfiguredMojo( MojoDescriptor mojoDescriptor, MavenSession session, Xpp3Dom dom,
|
private Mojo getConfiguredMojo( MojoDescriptor mojoDescriptor, MavenSession session, Xpp3Dom dom,
|
||||||
MavenProject project )
|
MavenProject project )
|
||||||
throws ComponentLookupException, PluginConfigurationException, PluginManagerException
|
throws ComponentLookupException, PluginConfigurationException, PluginManagerException
|
||||||
{
|
{
|
||||||
PlexusContainer pluginContainer = getPluginContainer( mojoDescriptor.getPluginDescriptor() );
|
PlexusContainer pluginContainer = getPluginContainer( mojoDescriptor.getPluginDescriptor() );
|
||||||
|
|
||||||
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
||||||
|
|
||||||
// if this is the first time this plugin has been used, the plugin's container will only
|
// if this is the first time this plugin has been used, the plugin's container will only
|
||||||
// contain the plugin's artifact in isolation; we need to finish resolving the plugin's
|
// contain the plugin's artifact in isolation; we need to finish resolving the plugin's
|
||||||
// dependencies, and add them to the container.
|
// dependencies, and add them to the container.
|
||||||
ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session );
|
ensurePluginContainerIsComplete( pluginDescriptor, pluginContainer, project, session );
|
||||||
|
@ -519,11 +520,13 @@ public class DefaultPluginManager
|
||||||
pathTranslator, getLogger(),
|
pathTranslator, getLogger(),
|
||||||
project );
|
project );
|
||||||
|
|
||||||
PlexusConfiguration extractedMojoConfiguration = extractMojoConfiguration( mergedConfiguration, mojoDescriptor );
|
PlexusConfiguration extractedMojoConfiguration = extractMojoConfiguration( mergedConfiguration,
|
||||||
|
mojoDescriptor );
|
||||||
|
|
||||||
checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator, plugin );
|
checkRequiredParameters( mojoDescriptor, extractedMojoConfiguration, expressionEvaluator, plugin );
|
||||||
|
|
||||||
populatePluginFields( plugin, mojoDescriptor, extractedMojoConfiguration, pluginContainer, expressionEvaluator );
|
populatePluginFields( plugin, mojoDescriptor, extractedMojoConfiguration, pluginContainer,
|
||||||
|
expressionEvaluator );
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,10 +554,12 @@ public class DefaultPluginManager
|
||||||
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
|
MavenMetadataSource metadataSource = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
|
||||||
artifactFactory );
|
artifactFactory );
|
||||||
|
|
||||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( Collections
|
List remoteArtifactRepositories = project.getRemoteArtifactRepositories();
|
||||||
.singleton( pluginArtifact ), project.getRemoteArtifactRepositories(),
|
ArtifactResolutionResult result = artifactResolver.resolveTransitively( pluginArtifact,
|
||||||
|
remoteArtifactRepositories,
|
||||||
session.getLocalRepository(),
|
session.getLocalRepository(),
|
||||||
metadataSource, artifactFilter );
|
metadataSource,
|
||||||
|
artifactFilter );
|
||||||
|
|
||||||
Map resolved = result.getArtifacts();
|
Map resolved = result.getArtifacts();
|
||||||
|
|
||||||
|
@ -577,9 +582,8 @@ public class DefaultPluginManager
|
||||||
ArtifactFilter distroProvidedFilter = new InversionArtifactFilter( artifactFilter );
|
ArtifactFilter distroProvidedFilter = new InversionArtifactFilter( artifactFilter );
|
||||||
|
|
||||||
ArtifactResolutionResult distroProvidedResult = artifactResolver
|
ArtifactResolutionResult distroProvidedResult = artifactResolver
|
||||||
.resolveTransitively( Collections.singleton( pluginArtifact ), project
|
.resolveTransitively( pluginArtifact, remoteArtifactRepositories, session.getLocalRepository(),
|
||||||
.getRemoteArtifactRepositories(), session.getLocalRepository(), metadataSource,
|
metadataSource, distroProvidedFilter );
|
||||||
distroProvidedFilter );
|
|
||||||
|
|
||||||
Map distroProvided = distroProvidedResult.getArtifacts();
|
Map distroProvided = distroProvidedResult.getArtifacts();
|
||||||
|
|
||||||
|
@ -617,7 +621,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlexusConfiguration extractMojoConfiguration( PlexusConfiguration mergedConfiguration,
|
private PlexusConfiguration extractMojoConfiguration( PlexusConfiguration mergedConfiguration,
|
||||||
MojoDescriptor mojoDescriptor )
|
MojoDescriptor mojoDescriptor )
|
||||||
{
|
{
|
||||||
Map parameterMap = mojoDescriptor.getParameterMap();
|
Map parameterMap = mojoDescriptor.getParameterMap();
|
||||||
|
|
||||||
|
@ -638,8 +642,8 @@ public class DefaultPluginManager
|
||||||
// TODO: I defy anyone to find these messages in the '-X' output! Do we need a new log level?
|
// TODO: I defy anyone to find these messages in the '-X' output! Do we need a new log level?
|
||||||
// ideally, this would be elevated above the true debug output, but below the default INFO level...
|
// ideally, this would be elevated above the true debug output, but below the default INFO level...
|
||||||
getLogger().debug(
|
getLogger().debug(
|
||||||
"*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'"
|
"*** WARNING: Configuration \'" + child.getName() + "\' is not used in goal \'" +
|
||||||
+ mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***" );
|
mojoDescriptor.getFullGoalName() + "; this may indicate a typo... ***" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -647,7 +651,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkRequiredParameters( MojoDescriptor goal, PlexusConfiguration configuration,
|
private void checkRequiredParameters( MojoDescriptor goal, PlexusConfiguration configuration,
|
||||||
ExpressionEvaluator expressionEvaluator, Mojo plugin )
|
ExpressionEvaluator expressionEvaluator, Mojo plugin )
|
||||||
throws PluginConfigurationException
|
throws PluginConfigurationException
|
||||||
{
|
{
|
||||||
// TODO: this should be built in to the configurator, as we presently double process the expressions
|
// TODO: this should be built in to the configurator, as we presently double process the expressions
|
||||||
|
@ -720,8 +724,8 @@ public class DefaultPluginManager
|
||||||
if ( fieldValue != null )
|
if ( fieldValue != null )
|
||||||
{
|
{
|
||||||
getLogger().warn(
|
getLogger().warn(
|
||||||
"DEPRECATED: using default-value to set the default value of field '"
|
"DEPRECATED: using default-value to set the default value of field '" +
|
||||||
+ parameter.getName() + "'" );
|
parameter.getName() + "'" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch ( NoSuchFieldException e )
|
catch ( NoSuchFieldException e )
|
||||||
|
@ -837,7 +841,7 @@ public class DefaultPluginManager
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
private void populatePluginFields( Mojo plugin, MojoDescriptor mojoDescriptor, PlexusConfiguration configuration,
|
private void populatePluginFields( Mojo plugin, MojoDescriptor mojoDescriptor, PlexusConfiguration configuration,
|
||||||
PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator )
|
PlexusContainer pluginContainer, ExpressionEvaluator expressionEvaluator )
|
||||||
throws PluginConfigurationException
|
throws PluginConfigurationException
|
||||||
{
|
{
|
||||||
ComponentConfigurator configurator = null;
|
ComponentConfigurator configurator = null;
|
||||||
|
@ -869,8 +873,7 @@ public class DefaultPluginManager
|
||||||
catch ( ComponentLookupException e )
|
catch ( ComponentLookupException e )
|
||||||
{
|
{
|
||||||
throw new PluginConfigurationException(
|
throw new PluginConfigurationException(
|
||||||
"Unable to retrieve component configurator for plugin configuration",
|
"Unable to retrieve component configurator for plugin configuration", e );
|
||||||
e );
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
@ -910,7 +913,7 @@ public class DefaultPluginManager
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, Parameter parameter,
|
public static String createPluginParameterRequiredMessage( MojoDescriptor mojo, Parameter parameter,
|
||||||
String expression )
|
String expression )
|
||||||
{
|
{
|
||||||
StringBuffer message = new StringBuffer();
|
StringBuffer message = new StringBuffer();
|
||||||
|
|
||||||
|
@ -966,25 +969,27 @@ public class DefaultPluginManager
|
||||||
public void initialize()
|
public void initialize()
|
||||||
{
|
{
|
||||||
// TODO: configure this from bootstrap or scan lib
|
// TODO: configure this from bootstrap or scan lib
|
||||||
|
Set artifacts = new HashSet();
|
||||||
|
artifacts.add( "classworlds" );
|
||||||
|
artifacts.add( "maven-artifact" );
|
||||||
|
artifacts.add( "maven-artifact-manager" );
|
||||||
|
artifacts.add( "maven-core" );
|
||||||
|
artifacts.add( "maven-model" );
|
||||||
|
artifacts.add( "maven-monitor" );
|
||||||
|
artifacts.add( "maven-plugin-api" );
|
||||||
|
artifacts.add( "maven-plugin-descriptor" );
|
||||||
|
artifacts.add( "maven-project" );
|
||||||
|
artifacts.add( "maven-settings" );
|
||||||
|
artifacts.add( "plexus-container-default" );
|
||||||
|
artifacts.add( "plexus-utils" );
|
||||||
|
artifacts.add( "wagon-provider-api" );
|
||||||
|
artifacts.add( "wagon-ssh" );
|
||||||
|
artifacts.add( "wagon-http-lightweight" );
|
||||||
|
artifacts.add( "wagon-file" );
|
||||||
// TODO: remove doxia
|
// TODO: remove doxia
|
||||||
artifactFilter = new ExclusionSetFilter( new String[] {
|
artifacts.add( "doxia-core" );
|
||||||
"classworlds",
|
artifacts.add( "maven-reporting-api" );
|
||||||
"maven-artifact",
|
artifactFilter = new ExclusionSetFilter( artifacts );
|
||||||
"maven-core",
|
|
||||||
"maven-model",
|
|
||||||
"maven-monitor",
|
|
||||||
"maven-plugin-api",
|
|
||||||
"maven-plugin-descriptor",
|
|
||||||
"maven-project",
|
|
||||||
"maven-settings",
|
|
||||||
"plexus-container-default",
|
|
||||||
"plexus-utils",
|
|
||||||
"wagon-provider-api",
|
|
||||||
"wagon-ssh",
|
|
||||||
"wagon-http-lightweight",
|
|
||||||
"wagon-file",
|
|
||||||
"doxia-core",
|
|
||||||
"maven-reporting-api" } );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -992,8 +997,8 @@ public class DefaultPluginManager
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver,
|
private void resolveTransitiveDependencies( MavenSession context, ArtifactResolver artifactResolver,
|
||||||
MavenProjectBuilder mavenProjectBuilder, String scope,
|
MavenProjectBuilder mavenProjectBuilder, String scope,
|
||||||
ArtifactFactory artifactFactory, MavenProject project )
|
ArtifactFactory artifactFactory, MavenProject project )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
|
MavenMetadataSource sourceReader = new MavenMetadataSource( artifactResolver, mavenProjectBuilder,
|
||||||
|
@ -1003,10 +1008,19 @@ public class DefaultPluginManager
|
||||||
|
|
||||||
boolean systemOnline = !context.getSettings().isOffline();
|
boolean systemOnline = !context.getSettings().isOffline();
|
||||||
|
|
||||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(), context
|
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
||||||
.getRemoteRepositories(), context.getLocalRepository(), sourceReader, filter );
|
Artifact artifact = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(),
|
||||||
|
project.getVersion(), null, project.getPackaging() );
|
||||||
|
|
||||||
project.addArtifacts( result.getArtifacts().values(), artifactFactory );
|
// TODO: we don't need to resolve over and over again, as long as we are sure that the parameters are the same
|
||||||
|
// check this with yourkit as a hot spot.
|
||||||
|
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
|
||||||
|
artifact,
|
||||||
|
project.getRemoteArtifactRepositories(),
|
||||||
|
context.getLocalRepository(),
|
||||||
|
sourceReader, filter );
|
||||||
|
|
||||||
|
project.setArtifacts( new HashSet( result.getArtifacts().values() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -1016,27 +1030,26 @@ public class DefaultPluginManager
|
||||||
private void downloadDependencies( MavenProject project, MavenSession context, ArtifactResolver artifactResolver )
|
private void downloadDependencies( MavenProject project, MavenSession context, ArtifactResolver artifactResolver )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
|
ArtifactRepository localRepository = context.getLocalRepository();
|
||||||
|
List remoteArtifactRepositories = project.getRemoteArtifactRepositories();
|
||||||
|
|
||||||
for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
|
for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
Artifact artifact = (Artifact) it.next();
|
Artifact artifact = (Artifact) it.next();
|
||||||
|
|
||||||
// TODO: should I get the modified artifacts back into the project?
|
artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository );
|
||||||
artifactResolver.resolve( artifact, context.getRemoteRepositories(), context.getLocalRepository() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Set pluginArtifacts = new HashSet();
|
// TODO: is this really necessary?
|
||||||
for ( Iterator it = project.getPluginArtifacts().iterator(); it.hasNext(); )
|
for ( Iterator it = project.getPluginArtifacts().iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
Artifact artifact = (Artifact) it.next();
|
Artifact artifact = (Artifact) it.next();
|
||||||
|
|
||||||
artifactResolver.resolve( artifact, context.getRemoteRepositories(), context.getLocalRepository() );
|
artifactResolver.resolve( artifact, remoteArtifactRepositories, localRepository );
|
||||||
|
|
||||||
pluginArtifacts.add( artifact );
|
|
||||||
}
|
}
|
||||||
project.setPluginArtifacts( pluginArtifacts );
|
|
||||||
|
|
||||||
artifactResolver.resolve( project.getParentArtifact(), context.getRemoteRepositories(), context
|
// TODO: is this really necessary?
|
||||||
.getLocalRepository() );
|
artifactResolver.resolve( project.getParentArtifact(), remoteArtifactRepositories, localRepository );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-artifact</artifactId>
|
<artifactId>maven-artifact</artifactId>
|
||||||
<version>2.0-alpha-2</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>plexus</groupId>
|
<groupId>plexus</groupId>
|
||||||
|
|
|
@ -14,12 +14,17 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-project</artifactId>
|
<artifactId>maven-project</artifactId>
|
||||||
<version>2.0-alpha-2</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-artifact</artifactId>
|
<artifactId>maven-artifact</artifactId>
|
||||||
<version>2.0-alpha-2</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-artifact-manager</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-artifact-test</artifactId>
|
<artifactId>maven-artifact-manager</artifactId>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
|
@ -17,11 +17,14 @@ package org.apache.maven.plugin.eclipse;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.artifact.manager.WagonManager;
|
||||||
|
import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||||
import org.apache.maven.project.MavenProject;
|
import org.apache.maven.project.MavenProject;
|
||||||
import org.apache.maven.project.MavenProjectBuilder;
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
|
import org.apache.maven.project.artifact.MavenMetadataSource;
|
||||||
import org.codehaus.plexus.PlexusTestCase;
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
@ -72,7 +75,7 @@ public class EclipsePluginTest
|
||||||
ArtifactRepository localRepository = new DefaultArtifactRepository( "local", "file://" + repo.getAbsolutePath(),
|
ArtifactRepository localRepository = new DefaultArtifactRepository( "local", "file://" + repo.getAbsolutePath(),
|
||||||
localRepositoryLayout );
|
localRepositoryLayout );
|
||||||
|
|
||||||
MavenProject project = builder.build( new File( basedir, "project.xml" ), localRepository, Collections.EMPTY_LIST );
|
MavenProject project = builder.buildWithDependencies( new File( basedir, "project.xml" ), localRepository, Collections.EMPTY_LIST );
|
||||||
|
|
||||||
for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
|
for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
<classpathentry kind="src" path="src/main/java"/>
|
<classpathentry kind="src" path="src/main/java"/>
|
||||||
<classpathentry kind="output" path="target/classes"/>
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
<classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"/>
|
<classpathentry kind="var" rootpath="JRE_SRCROOT" path="JRE_LIB" sourcepath="JRE_SRC"/>
|
||||||
<classpathentry kind="var" path="M2_REPO/maven/jars/maven-core-2.0-SNAPSHOT.jar"/>
|
<classpathentry kind="var" path="M2_REPO/maven/jars/maven-core-98.0.jar"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
<artifactId>maven-core</artifactId>
|
<artifactId>maven-core</artifactId>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>98.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>maven</groupId>
|
<groupId>maven</groupId>
|
||||||
<artifactId>maven-core</artifactId>
|
<artifactId>maven-core</artifactId>
|
||||||
<version>2.0-SNAPSHOT</version>
|
<version>98.0</version>
|
||||||
</project>
|
</project>
|
|
@ -13,7 +13,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-project</artifactId>
|
<artifactId>maven-project</artifactId>
|
||||||
<version>2.0-alpha-2</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -14,12 +14,17 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-project</artifactId>
|
<artifactId>maven-project</artifactId>
|
||||||
<version>2.0-alpha-2</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-artifact</artifactId>
|
<artifactId>maven-artifact</artifactId>
|
||||||
<version>2.0-alpha-2</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven</groupId>
|
||||||
|
<artifactId>maven-artifact-manager</artifactId>
|
||||||
|
<version>2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-project</artifactId>
|
<artifactId>maven-project</artifactId>
|
||||||
<version>2.0-alpha-2</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.maven</groupId>
|
<groupId>org.apache.maven</groupId>
|
||||||
<artifactId>maven-model</artifactId>
|
<artifactId>maven-model</artifactId>
|
||||||
<version>2.0-alpha-2</version>
|
<version>2.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
|
|
|
@ -33,12 +33,5 @@
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- TODO: would like to remove -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.maven</groupId>
|
|
||||||
<artifactId>maven-artifact</artifactId>
|
|
||||||
<version>2.0-alpha-2</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -124,11 +124,6 @@ public class SurefirePlugin
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
if ( "pom".equals( project.getPackaging() ) )
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Setup the surefire booter
|
// Setup the surefire booter
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
|
@ -114,6 +114,14 @@ public class DefaultMavenProjectBuilder
|
||||||
// MavenProjectBuilder Implementation
|
// MavenProjectBuilder Implementation
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository,
|
||||||
|
List externalProfiles )
|
||||||
|
throws ProjectBuildingException, ArtifactResolutionException
|
||||||
|
{
|
||||||
|
ArtifactMetadataSource source = new MavenMetadataSource( artifactResolver, this, artifactFactory );
|
||||||
|
return buildWithDependencies( projectDescriptor, localRepository, source, externalProfiles );
|
||||||
|
}
|
||||||
|
|
||||||
public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository,
|
public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository,
|
||||||
ArtifactMetadataSource artifactMetadataSource, List externalProfiles )
|
ArtifactMetadataSource artifactMetadataSource, List externalProfiles )
|
||||||
throws ProjectBuildingException, ArtifactResolutionException
|
throws ProjectBuildingException, ArtifactResolutionException
|
||||||
|
@ -132,12 +140,17 @@ public class DefaultMavenProjectBuilder
|
||||||
// this snippet of code here.
|
// this snippet of code here.
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getArtifacts(),
|
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
||||||
|
Artifact artifact = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(),
|
||||||
|
project.getVersion(), null, project.getPackaging() );
|
||||||
|
|
||||||
|
ArtifactResolutionResult result = artifactResolver.resolveTransitively( project.getDependencyArtifacts(),
|
||||||
|
artifact,
|
||||||
project.getRemoteArtifactRepositories(),
|
project.getRemoteArtifactRepositories(),
|
||||||
localRepository,
|
localRepository,
|
||||||
artifactMetadataSource );
|
artifactMetadataSource );
|
||||||
|
|
||||||
project.addArtifacts( result.getArtifacts().values(), artifactFactory );
|
project.setArtifacts( new HashSet( result.getArtifacts().values() ) );
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,10 +261,10 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
MavenProject project = assembleLineage( model, lineage, aggregatedRemoteWagonRepositories, localRepository );
|
MavenProject project = assembleLineage( model, lineage, aggregatedRemoteWagonRepositories, localRepository );
|
||||||
|
|
||||||
// we don't have to force the collision exception for superModel here, it's already been done in getSuperModel()
|
// we don't have to force the collision exception for superModel here, it's already been done in getSuperModel()
|
||||||
Model previous = superModel;
|
Model previous = superModel;
|
||||||
|
|
||||||
for ( Iterator i = lineage.iterator(); i.hasNext(); )
|
for ( Iterator i = lineage.iterator(); i.hasNext(); )
|
||||||
{
|
{
|
||||||
Model current = ( (MavenProject) i.next() ).getModel();
|
Model current = ( (MavenProject) i.next() ).getModel();
|
||||||
|
@ -278,24 +291,24 @@ public class DefaultMavenProjectBuilder
|
||||||
private void forcePluginExecutionIdCollision( Model model )
|
private void forcePluginExecutionIdCollision( Model model )
|
||||||
{
|
{
|
||||||
Build build = model.getBuild();
|
Build build = model.getBuild();
|
||||||
|
|
||||||
if ( build != null )
|
if ( build != null )
|
||||||
{
|
{
|
||||||
List plugins = build.getPlugins();
|
List plugins = build.getPlugins();
|
||||||
|
|
||||||
if ( plugins != null )
|
if ( plugins != null )
|
||||||
{
|
{
|
||||||
for ( Iterator it = plugins.iterator(); it.hasNext(); )
|
for ( Iterator it = plugins.iterator(); it.hasNext(); )
|
||||||
{
|
{
|
||||||
Plugin plugin = (Plugin) it.next();
|
Plugin plugin = (Plugin) it.next();
|
||||||
|
|
||||||
// this will force an IllegalStateException, even if we don't have to do inheritance assembly.
|
// this will force an IllegalStateException, even if we don't have to do inheritance assembly.
|
||||||
plugin.getExecutionsAsMap();
|
plugin.getExecutionsAsMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo can this take in a model instead of a project and still be successful?
|
* @todo can this take in a model instead of a project and still be successful?
|
||||||
|
@ -370,7 +383,7 @@ public class DefaultMavenProjectBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
project.setRemoteArtifactRepositories( remoteRepositories );
|
project.setRemoteArtifactRepositories( remoteRepositories );
|
||||||
project.setArtifacts( createArtifacts( project.getDependencies() ) );
|
project.setDependencyArtifacts( createArtifacts( project.getDependencies() ) );
|
||||||
project.setPluginArtifacts( createPluginArtifacts( project.getBuildPlugins() ) );
|
project.setPluginArtifacts( createPluginArtifacts( project.getBuildPlugins() ) );
|
||||||
|
|
||||||
ModelValidationResult validationResult = validator.validate( model );
|
ModelValidationResult validationResult = validator.validate( model );
|
||||||
|
@ -586,7 +599,7 @@ public class DefaultMavenProjectBuilder
|
||||||
URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" );
|
URL url = DefaultMavenProjectBuilder.class.getResource( "pom-" + MAVEN_MODEL_VERSION + ".xml" );
|
||||||
|
|
||||||
Model superModel = readModel( url );
|
Model superModel = readModel( url );
|
||||||
|
|
||||||
forcePluginExecutionIdCollision( superModel );
|
forcePluginExecutionIdCollision( superModel );
|
||||||
|
|
||||||
return superModel;
|
return superModel;
|
||||||
|
|
|
@ -18,7 +18,6 @@ package org.apache.maven.project;
|
||||||
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
import org.apache.maven.artifact.DependencyResolutionRequiredException;
|
||||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
import org.apache.maven.model.Build;
|
import org.apache.maven.model.Build;
|
||||||
import org.apache.maven.model.CiManagement;
|
import org.apache.maven.model.CiManagement;
|
||||||
|
@ -47,13 +46,9 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -106,6 +101,8 @@ public class MavenProject
|
||||||
|
|
||||||
private List activeProfiles = new ArrayList();
|
private List activeProfiles = new ArrayList();
|
||||||
|
|
||||||
|
private Set dependencyArtifacts;
|
||||||
|
|
||||||
public MavenProject( Model model )
|
public MavenProject( Model model )
|
||||||
{
|
{
|
||||||
this.model = model;
|
this.model = model;
|
||||||
|
@ -119,7 +116,11 @@ public class MavenProject
|
||||||
this.file = project.file;
|
this.file = project.file;
|
||||||
|
|
||||||
// don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be sure!
|
// don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be sure!
|
||||||
this.artifacts = Collections.unmodifiableSet( project.artifacts );
|
this.dependencyArtifacts = Collections.unmodifiableSet( project.dependencyArtifacts );
|
||||||
|
if ( project.artifacts != null )
|
||||||
|
{
|
||||||
|
this.artifacts = Collections.unmodifiableSet( project.artifacts );
|
||||||
|
}
|
||||||
this.pluginArtifacts = Collections.unmodifiableSet( project.pluginArtifacts );
|
this.pluginArtifacts = Collections.unmodifiableSet( project.pluginArtifacts );
|
||||||
this.remoteArtifactRepositories = Collections.unmodifiableList( project.remoteArtifactRepositories );
|
this.remoteArtifactRepositories = Collections.unmodifiableList( project.remoteArtifactRepositories );
|
||||||
this.pluginArtifactRepositories = Collections.unmodifiableList( project.pluginArtifactRepositories );
|
this.pluginArtifactRepositories = Collections.unmodifiableList( project.pluginArtifactRepositories );
|
||||||
|
@ -805,59 +806,6 @@ public class MavenProject
|
||||||
this.collectedProjects = collectedProjects;
|
this.collectedProjects = collectedProjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addArtifacts( Collection newArtifacts, ArtifactFactory artifactFactory )
|
|
||||||
{
|
|
||||||
// project.getArtifacts().addAll( result.getArtifacts().values() );
|
|
||||||
// We need to override the scope if one declared it higher
|
|
||||||
// TODO: could surely be more efficient, and use the scope handler, be part of maven-artifact...
|
|
||||||
Map artifacts = new HashMap();
|
|
||||||
for ( Iterator i = getArtifacts().iterator(); i.hasNext(); )
|
|
||||||
{
|
|
||||||
Artifact a = (Artifact) i.next();
|
|
||||||
artifacts.put( a.getId(), a );
|
|
||||||
}
|
|
||||||
for ( Iterator i = newArtifacts.iterator(); i.hasNext(); )
|
|
||||||
{
|
|
||||||
Artifact a = (Artifact) i.next();
|
|
||||||
String id = a.getId();
|
|
||||||
if ( artifacts.containsKey( id ) )
|
|
||||||
{
|
|
||||||
Artifact existing = (Artifact) artifacts.get( id );
|
|
||||||
boolean updateScope = false;
|
|
||||||
if ( Artifact.SCOPE_RUNTIME.equals( a.getScope() ) &&
|
|
||||||
Artifact.SCOPE_TEST.equals( existing.getScope() ) )
|
|
||||||
{
|
|
||||||
updateScope = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) &&
|
|
||||||
!Artifact.SCOPE_COMPILE.equals( existing.getScope() ) )
|
|
||||||
{
|
|
||||||
updateScope = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( updateScope )
|
|
||||||
{
|
|
||||||
// TODO: Artifact factory?
|
|
||||||
// TODO: [jc] Is this a better way to centralize artifact construction here?
|
|
||||||
Artifact artifact = artifactFactory.createArtifact( existing.getGroupId(), existing.getArtifactId(),
|
|
||||||
existing.getVersion(), a.getScope(), existing
|
|
||||||
.getType() );
|
|
||||||
|
|
||||||
artifact.setFile( existing.getFile() );
|
|
||||||
artifact.setBaseVersion( existing.getBaseVersion() );
|
|
||||||
|
|
||||||
artifacts.put( id, artifact );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
artifacts.put( id, a );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setArtifacts( new HashSet( artifacts.values() ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPluginArtifactRepositories( List pluginArtifactRepositories )
|
public void setPluginArtifactRepositories( List pluginArtifactRepositories )
|
||||||
{
|
{
|
||||||
this.pluginArtifactRepositories = pluginArtifactRepositories;
|
this.pluginArtifactRepositories = pluginArtifactRepositories;
|
||||||
|
@ -1044,4 +992,14 @@ public class MavenProject
|
||||||
|
|
||||||
pomWriter.write( writer, getModel() );
|
pomWriter.write( writer, getModel() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set getDependencyArtifacts()
|
||||||
|
{
|
||||||
|
return dependencyArtifacts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDependencyArtifacts( Set dependencyArtifacts )
|
||||||
|
{
|
||||||
|
this.dependencyArtifacts = dependencyArtifacts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,9 @@ public interface MavenProjectBuilder
|
||||||
ArtifactMetadataSource artifactMetadataSource, List externalProfiles )
|
ArtifactMetadataSource artifactMetadataSource, List externalProfiles )
|
||||||
throws ProjectBuildingException, ArtifactResolutionException;
|
throws ProjectBuildingException, ArtifactResolutionException;
|
||||||
|
|
||||||
|
MavenProject buildWithDependencies( File project, ArtifactRepository localRepository, List externalProfiles )
|
||||||
|
throws ProjectBuildingException, ArtifactResolutionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build the artifact from the local repository, resolving it if necessary.
|
* Build the artifact from the local repository, resolving it if necessary.
|
||||||
*
|
*
|
||||||
|
|
|
@ -106,30 +106,22 @@ public class ProjectClasspathArtifactResolver
|
||||||
artifact.setFile( new File( "dummy" ) );
|
artifact.setFile( new File( "dummy" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
|
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||||
ArtifactRepository localRepository,
|
List remoteRepositories, ArtifactRepository localRepository,
|
||||||
ArtifactMetadataSource source, ArtifactFilter filter )
|
ArtifactMetadataSource source, ArtifactFilter filter )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
return super.resolveTransitively( artifacts, remoteRepositories, localRepository, new Source( artifactFactory ),
|
return super.resolveTransitively( artifacts, originatingArtifact, remoteRepositories, localRepository,
|
||||||
filter );
|
new Source( artifactFactory ), filter );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactResolutionResult resolveTransitively( Set artifacts, List remoteRepositories,
|
public ArtifactResolutionResult resolveTransitively( Set artifacts, Artifact originatingArtifact,
|
||||||
ArtifactRepository localRepository,
|
List remoteRepositories, ArtifactRepository localRepository,
|
||||||
ArtifactMetadataSource source )
|
ArtifactMetadataSource source )
|
||||||
throws ArtifactResolutionException
|
throws ArtifactResolutionException
|
||||||
{
|
{
|
||||||
return super.resolveTransitively( artifacts, remoteRepositories, localRepository,
|
return super.resolveTransitively( artifacts, originatingArtifact, remoteRepositories, localRepository,
|
||||||
new Source( artifactFactory ) );
|
new Source( artifactFactory ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArtifactResolutionResult resolveTransitively( Artifact artifact, List remoteRepositories,
|
|
||||||
ArtifactRepository localRepository,
|
|
||||||
ArtifactMetadataSource source )
|
|
||||||
throws ArtifactResolutionException
|
|
||||||
{
|
|
||||||
return super.resolveTransitively( artifact, remoteRepositories, localRepository,
|
|
||||||
new Source( artifactFactory ) );
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue