You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2007/10/13 02:11:02 UTC
svn commit: r584343 [3/3] - in /maven/components/trunk: ./
maven-core/src/main/java/org/apache/maven/
maven-core/src/main/java/org/apache/maven/execution/
maven-core/src/main/java/org/apache/maven/lifecycle/
maven-core/src/main/java/org/apache/maven/pl...
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/DefaultMavenTools.java Fri Oct 12 17:10:29 2007
@@ -19,21 +19,13 @@
* under the License.
*/
-import org.apache.maven.artifact.InvalidRepositoryException;
+import org.apache.maven.artifact.UnknownRepositoryLayoutException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.Repository;
-import org.apache.maven.model.RepositoryBase;
import org.apache.maven.model.RepositoryPolicy;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.ContextException;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import java.util.ArrayList;
import java.util.Iterator;
@@ -41,21 +33,17 @@
/** @author Jason van Zyl */
public class DefaultMavenTools
- implements MavenTools, Contextualizable
+ implements MavenTools
{
- private ArtifactRepositoryLayout repositoryLayout;
-
private ArtifactRepositoryFactory artifactRepositoryFactory;
- private PlexusContainer container;
-
// ----------------------------------------------------------------------------
// Code snagged from ProjectUtils: this will have to be moved somewhere else
// but just trying to collect it all in one place right now.
// ----------------------------------------------------------------------------
public List buildArtifactRepositories( List repositories )
- throws InvalidRepositoryException
+ throws UnknownRepositoryLayoutException
{
List repos = new ArrayList();
@@ -74,17 +62,14 @@
}
public ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo )
- throws InvalidRepositoryException
+ throws UnknownRepositoryLayoutException
{
if ( repo != null )
{
String id = repo.getId();
String url = repo.getUrl();
- // TODO: make this a map inside the factory instead, so no lookup needed
- ArtifactRepositoryLayout layout = getRepositoryLayout( repo );
-
- return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout,
+ return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, repo.getLayout(),
repo.isUniqueVersion() );
}
else
@@ -94,21 +79,18 @@
}
public ArtifactRepository buildArtifactRepository( Repository repo )
- throws InvalidRepositoryException
+ throws UnknownRepositoryLayoutException
{
if ( repo != null )
{
String id = repo.getId();
String url = repo.getUrl();
- // TODO: make this a map inside the factory instead, so no lookup needed
- ArtifactRepositoryLayout layout = getRepositoryLayout( repo );
-
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() );
ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() );
- return artifactRepositoryFactory.createArtifactRepository( id, url, layout, snapshots, releases );
+ return artifactRepositoryFactory.createArtifactRepository( id, url, repo.getLayout(), snapshots, releases );
}
else
{
@@ -139,33 +121,5 @@
}
return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy );
- }
-
- private ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mavenRepo )
- throws InvalidRepositoryException
- {
- String layout = mavenRepo.getLayout();
-
- ArtifactRepositoryLayout repositoryLayout;
- try
- {
- repositoryLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, layout );
- }
- catch ( ComponentLookupException e )
- {
- throw new InvalidRepositoryException( "Cannot find layout implementation corresponding to: \'" + layout +
- "\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e );
- }
- return repositoryLayout;
- }
-
- // ----------------------------------------------------------------------------
- // Lifecycle
- // ----------------------------------------------------------------------------
-
- public void contextualize( Context context )
- throws ContextException
- {
- container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/MavenTools.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/MavenTools.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/MavenTools.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/MavenTools.java Fri Oct 12 17:10:29 2007
@@ -19,7 +19,7 @@
* under the License.
*/
-import org.apache.maven.artifact.InvalidRepositoryException;
+import org.apache.maven.artifact.UnknownRepositoryLayoutException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.Repository;
@@ -38,11 +38,11 @@
// ----------------------------------------------------------------------------
List buildArtifactRepositories( List repositories )
- throws InvalidRepositoryException;
+ throws UnknownRepositoryLayoutException;
ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo )
- throws InvalidRepositoryException;
+ throws UnknownRepositoryLayoutException;
ArtifactRepository buildArtifactRepository( Repository repo )
- throws InvalidRepositoryException;
+ throws UnknownRepositoryLayoutException;
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/DefaultProfileAdvisor.java Fri Oct 12 17:10:29 2007
@@ -62,12 +62,12 @@
private PlexusContainer container;
- public List applyActivatedProfiles( Model model, File projectDir, List explicitlyActiveIds, List explicitlyInactiveIds )
+ public List applyActivatedProfiles( Model model, File pomFile, List explicitlyActiveIds, List explicitlyInactiveIds )
throws ProjectBuildingException
{
- ProfileManager profileManager = buildProfileManager( model, projectDir, explicitlyActiveIds, explicitlyInactiveIds );
+ ProfileManager profileManager = buildProfileManager( model, pomFile, explicitlyActiveIds, explicitlyInactiveIds );
- return applyActivatedProfiles( model, projectDir, profileManager );
+ return applyActivatedProfiles( model, pomFile, profileManager );
}
public List applyActivatedExternalProfiles( Model model, File projectDir, ProfileManager externalProfileManager )
@@ -76,7 +76,7 @@
return applyActivatedProfiles( model, projectDir, externalProfileManager );
}
- private List applyActivatedProfiles( Model model, File projectDir, ProfileManager profileManager )
+ private List applyActivatedProfiles( Model model, File pomFile, ProfileManager profileManager )
throws ProjectBuildingException
{
List activeProfiles;
@@ -103,7 +103,7 @@
String projectId = ArtifactUtils.versionlessKey( groupId, artifactId );
- throw new ProjectBuildingException( projectId, e.getMessage(), e );
+ throw new ProjectBuildingException( projectId, e.getMessage(), pomFile.getAbsolutePath(), e );
}
for ( Iterator it = activeProfiles.iterator(); it.hasNext(); )
@@ -121,7 +121,7 @@
return activeProfiles;
}
- private ProfileManager buildProfileManager( Model model, File projectDir, List explicitlyActiveIds, List explicitlyInactiveIds )
+ private ProfileManager buildProfileManager( Model model, File pomFile, List explicitlyActiveIds, List explicitlyInactiveIds )
throws ProjectBuildingException
{
ProfileManager profileManager = new DefaultProfileManager( container );
@@ -132,15 +132,20 @@
profileManager.addProfiles( model.getProfiles() );
- if ( projectDir != null )
+ if ( pomFile != null )
{
- loadExternalProjectProfiles( profileManager, model, projectDir );
+ File projectDir = pomFile.getParentFile();
+ if ( projectDir != null )
+ {
+ loadExternalProjectProfiles( profileManager, model, projectDir );
+ }
}
return profileManager;
}
public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( ProfileManager profileManager,
+ File pomFile,
String modelId )
throws ProjectBuildingException
{
@@ -159,7 +164,7 @@
catch ( ProfileActivationException e )
{
throw new ProjectBuildingException( modelId,
- "Failed to compute active profiles for repository aggregation.", e );
+ "Failed to compute active profiles for repository aggregation.", pomFile.getAbsolutePath(), e );
}
LinkedHashSet remoteRepositories = new LinkedHashSet();
@@ -190,20 +195,21 @@
}
}
- public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File projectDir,
+ public LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File pomFile,
List explicitlyActiveIds, List explicitlyInactiveIds )
throws ProjectBuildingException
{
- ProfileManager profileManager = buildProfileManager( model, projectDir, explicitlyActiveIds, explicitlyInactiveIds );
+ ProfileManager profileManager = buildProfileManager( model, pomFile, explicitlyActiveIds, explicitlyInactiveIds );
- return getArtifactRepositoriesFromActiveProfiles( profileManager, model.getId() );
+ return getArtifactRepositoriesFromActiveProfiles( profileManager, pomFile, model.getId() );
}
- private void loadExternalProjectProfiles( ProfileManager profileManager, Model model, File projectDir )
+ private void loadExternalProjectProfiles( ProfileManager profileManager, Model model, File pomFile )
throws ProjectBuildingException
{
- if ( projectDir != null )
+ if ( pomFile != null )
{
+ File projectDir = pomFile.getParentFile();
try
{
ProfilesRoot root = profilesBuilder.buildProfiles( projectDir );
@@ -230,13 +236,13 @@
catch ( IOException e )
{
throw new ProjectBuildingException( model.getId(), "Cannot read profiles.xml resource from directory: "
- + projectDir, e );
+ + projectDir, pomFile.getAbsolutePath(), e );
}
catch ( XmlPullParserException e )
{
throw new ProjectBuildingException( model.getId(),
"Cannot parse profiles.xml resource from directory: " + projectDir,
- e );
+ pomFile.getAbsolutePath(), e );
}
}
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/ProfileAdvisor.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/ProfileAdvisor.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/ProfileAdvisor.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/profiles/build/ProfileAdvisor.java Fri Oct 12 17:10:29 2007
@@ -37,16 +37,16 @@
String ROLE = ProfileAdvisor.class.getName();
- LinkedHashSet getArtifactRepositoriesFromActiveProfiles( ProfileManager profileManager, String modelId )
+ LinkedHashSet getArtifactRepositoriesFromActiveProfiles( ProfileManager profileManager, File pomFile, String modelId )
throws ProjectBuildingException;
- LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File projectDir, List explicitlyActiveIds, List explicitlyInactiveIds )
+ LinkedHashSet getArtifactRepositoriesFromActiveProfiles( Model model, File pomFile, List explicitlyActiveIds, List explicitlyInactiveIds )
throws ProjectBuildingException;
- List applyActivatedProfiles( Model model, File projectDir, List explicitlyActiveIds, List explicitlyInactiveIds )
+ List applyActivatedProfiles( Model model, File pomFile, List explicitlyActiveIds, List explicitlyInactiveIds )
throws ProjectBuildingException;
- List applyActivatedExternalProfiles( Model model, File projectDir, ProfileManager externalProfileManager )
+ List applyActivatedExternalProfiles( Model model, File pomFile, ProfileManager externalProfileManager )
throws ProjectBuildingException;
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Fri Oct 12 17:10:29 2007
@@ -66,13 +66,7 @@
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator;
-import org.codehaus.plexus.PlexusConstants;
-import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
-import org.codehaus.plexus.context.Context;
-import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringUtils;
@@ -140,11 +134,8 @@
public class DefaultMavenProjectBuilder
extends AbstractLogEnabled
implements MavenProjectBuilder,
- Initializable,
- Contextualizable
+ Initializable
{
- protected PlexusContainer container;
-
protected MavenProfilesBuilder profilesBuilder;
protected ArtifactResolver artifactResolver;
@@ -229,9 +220,9 @@
public MavenProject buildStandaloneSuperProject()
throws ProjectBuildingException
{
- if ( this.superProject != null )
+ if ( superProject != null )
{
- return this.superProject;
+ return superProject;
}
Model superModel = getSuperModel();
@@ -252,7 +243,12 @@
}
catch ( InvalidRepositoryException e )
{
- // This will never happen with the repositories in the SuperPOM
+ // we shouldn't be swallowing exceptions, no matter how unlikely.
+ // or, if we do, we should pay attention to the one coming from getSuperModel()...
+ throw new ProjectBuildingException( STANDALONE_SUPERPOM_GROUPID + ":"
+ + STANDALONE_SUPERPOM_ARTIFACTID,
+ "Maven super-POM contains an invalid repository!",
+ e );
}
superProject.setOriginalModel( superModel );
@@ -288,8 +284,6 @@
Map managedVersions = project.getManagedVersionMap();
- ensureMetadataSourceIsInitialized();
-
try
{
project.setDependencyArtifacts( project.createArtifacts( artifactFactory, null, null ) );
@@ -298,7 +292,7 @@
{
throw new ProjectBuildingException( projectId,
"Unable to build project due to an invalid dependency version: " +
- e.getMessage(), e );
+ e.getMessage(), projectDescriptor.getAbsolutePath(), e );
}
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
@@ -320,25 +314,8 @@
//
// ----------------------------------------------------------------------
- private void ensureMetadataSourceIsInitialized()
- throws ProjectBuildingException
- {
- if ( artifactMetadataSource == null )
- {
- try
- {
- artifactMetadataSource = (ArtifactMetadataSource) container.lookup( ArtifactMetadataSource.ROLE );
- }
- catch ( ComponentLookupException e )
- {
- throw new ProjectBuildingException( "all", "Cannot lookup metadata source for building the project.",
- e );
- }
- }
- }
-
private Map createManagedVersionMap( String projectId,
- DependencyManagement dependencyManagement )
+ DependencyManagement dependencyManagement, File pomFile )
throws ProjectBuildingException
{
Map map = null;
@@ -397,7 +374,7 @@
catch ( InvalidVersionSpecificationException e )
{
throw new ProjectBuildingException( projectId, "Unable to parse version '" + d.getVersion() +
- "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), e );
+ "' for dependency '" + d.getManagementKey() + "': " + e.getMessage(), pomFile.getAbsolutePath(), e );
}
}
}
@@ -560,13 +537,6 @@
boolean strict )
throws ProjectBuildingException
{
- File projectDir = null;
-
- if ( projectDescriptor != null )
- {
- projectDir = projectDescriptor.getAbsoluteFile().getParentFile();
- }
-
Model superModel = getSuperModel();
MavenProject superProject = new MavenProject( superModel );
@@ -586,7 +556,7 @@
}
catch ( ProfileActivationException e )
{
- throw new ProjectBuildingException( projectId, "Failed to activate external profiles.", e );
+ throw new ProjectBuildingException( projectId, "Failed to activate external profiles.", projectDescriptor.getAbsolutePath(), e );
}
explicitlyActive = externalProfileManager.getExplicitlyActivatedIds();
@@ -600,14 +570,14 @@
explicitlyInactive = Collections.EMPTY_LIST;
}
- superProject.setActiveProfiles( profileAdvisor.applyActivatedProfiles( superModel, null, explicitlyActive, explicitlyInactive ) );
+ superProject.setActiveProfiles( profileAdvisor.applyActivatedProfiles( superModel, projectDescriptor, explicitlyActive, explicitlyInactive ) );
//noinspection CollectionDeclaredAsConcreteClass
LinkedList lineage = new LinkedList();
LinkedHashSet aggregatedRemoteWagonRepositories = collectInitialRepositories( model, superModel,
parentSearchRepositories,
- projectDir, explicitlyActive,
+ projectDescriptor, explicitlyActive,
explicitlyInactive );
Model originalModel = ModelUtils.cloneModel( model );
@@ -616,7 +586,7 @@
try
{
- project = assembleLineage( model, lineage, localRepository, projectDir, aggregatedRemoteWagonRepositories, externalProfileManager, strict );
+ project = assembleLineage( model, lineage, localRepository, projectDescriptor, aggregatedRemoteWagonRepositories, externalProfileManager, strict );
}
catch ( InvalidRepositoryException e )
{
@@ -672,7 +642,7 @@
try
{
- project = processProjectLogic( pomLocation, project, projectDir, strict );
+ project = processProjectLogic( pomLocation, project, projectDescriptor, strict );
}
catch ( ModelInterpolationException e )
{
@@ -718,7 +688,7 @@
}
}
- project.setManagedVersionMap( createManagedVersionMap( projectId, project.getDependencyManagement() ) );
+ project.setManagedVersionMap( createManagedVersionMap( projectId, project.getDependencyManagement(), projectDescriptor ) );
return project;
}
@@ -735,16 +705,16 @@
private LinkedHashSet collectInitialRepositories( Model model,
Model superModel,
List parentSearchRepositories,
- File projectDir,
+ File pomFile,
List explicitlyActive,
List explicitlyInactive )
throws ProjectBuildingException
{
LinkedHashSet collected = new LinkedHashSet();
- collectInitialRepositoriesFromModel( collected, model, projectDir, explicitlyActive, explicitlyInactive );
+ collectInitialRepositoriesFromModel( collected, model, pomFile, explicitlyActive, explicitlyInactive );
- collectInitialRepositoriesFromModel( collected, superModel, projectDir, explicitlyActive, explicitlyInactive );
+ collectInitialRepositoriesFromModel( collected, superModel, null, explicitlyActive, explicitlyInactive );
if ( ( parentSearchRepositories != null ) && !parentSearchRepositories.isEmpty() )
{
@@ -756,12 +726,12 @@
private void collectInitialRepositoriesFromModel( LinkedHashSet collected,
Model model,
- File projectDir,
+ File pomFile,
List explicitlyActive,
List explicitlyInactive )
throws ProjectBuildingException
{
- Set reposFromProfiles = profileAdvisor.getArtifactRepositoriesFromActiveProfiles( model, projectDir, explicitlyActive, explicitlyInactive );
+ Set reposFromProfiles = profileAdvisor.getArtifactRepositoriesFromActiveProfiles( model, pomFile, explicitlyActive, explicitlyInactive );
if ( ( reposFromProfiles != null ) && !reposFromProfiles.isEmpty() )
{
@@ -829,7 +799,7 @@
*/
private MavenProject processProjectLogic( String pomLocation,
MavenProject project,
- File projectDir,
+ File pomFile,
boolean strict )
throws ProjectBuildingException, ModelInterpolationException, InvalidRepositoryException
{
@@ -843,9 +813,9 @@
// mkleint - using System.getProperties() is almost definitely bad for embedding.
Map context = new HashMap( System.getProperties() );
- if ( projectDir != null )
+ if ( pomFile != null )
{
- context.put( "basedir", projectDir.getAbsolutePath() );
+ context.put( "basedir", pomFile.getParentFile().getAbsolutePath() );
}
// TODO: this is a hack to ensure MNG-2124 can be satisfied without triggering MNG-1927
@@ -919,11 +889,11 @@
mavenTools.buildArtifactRepositories( model.getRepositories() ) );
// TODO: these aren't taking active project artifacts into consideration in the reactor
- project.setPluginArtifacts( createPluginArtifacts( projectId, project.getBuildPlugins() ) );
+ project.setPluginArtifacts( createPluginArtifacts( projectId, project.getBuildPlugins(), pomLocation ) );
- project.setReportArtifacts( createReportArtifacts( projectId, project.getReportPlugins() ) );
+ project.setReportArtifacts( createReportArtifacts( projectId, project.getReportPlugins(), pomLocation ) );
- project.setExtensionArtifacts( createExtensionArtifacts( projectId, project.getBuildExtensions() ) );
+ project.setExtensionArtifacts( createExtensionArtifacts( projectId, project.getBuildExtensions(), pomLocation ) );
return project;
}
@@ -936,7 +906,7 @@
private MavenProject assembleLineage( Model model,
LinkedList lineage,
ArtifactRepository localRepository,
- File projectDir,
+ File pomFile,
Set aggregatedRemoteWagonRepositories,
ProfileManager externalProfileManager,
boolean strict )
@@ -944,7 +914,7 @@
{
ModelLineage modelLineage = new DefaultModelLineage();
- modelLineage.setOrigin( model, new File( projectDir, "pom.xml" ), new ArrayList( aggregatedRemoteWagonRepositories ) );
+ modelLineage.setOrigin( model, pomFile, new ArrayList( aggregatedRemoteWagonRepositories ) );
modelLineageBuilder.resumeBuildingModelLineage( modelLineage, localRepository, externalProfileManager, !strict );
@@ -983,7 +953,7 @@
projectContext.setCurrentProject( project );
projectContext.store( buildContextManager );
- project.setActiveProfiles( profileAdvisor.applyActivatedProfiles( currentModel, projectDir, explicitlyActive,
+ project.setActiveProfiles( profileAdvisor.applyActivatedProfiles( currentModel, currentPom, explicitlyActive,
explicitlyInactive ) );
if ( lastProject != null )
@@ -1011,7 +981,7 @@
active.addAll( existingActiveProfiles );
}
- profileAdvisor.applyActivatedExternalProfiles( result.getModel(), projectDir, externalProfileManager );
+ profileAdvisor.applyActivatedExternalProfiles( result.getModel(), pomFile, externalProfileManager );
}
return result;
@@ -1031,12 +1001,12 @@
catch ( FileNotFoundException e )
{
throw new ProjectBuildingException( projectId,
- "Could not find the model file '" + file.getAbsolutePath() + "'.", e );
+ "Could not find the model file '" + file.getAbsolutePath() + "'.", file.getAbsolutePath(), e );
}
catch ( IOException e )
{
throw new ProjectBuildingException( projectId, "Failed to build model from file '" +
- file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", e );
+ file.getAbsolutePath() + "'.\nError: \'" + e.getLocalizedMessage() + "\'", file.getAbsolutePath(), e );
}
finally
{
@@ -1088,7 +1058,7 @@
catch ( IOException e )
{
throw new ProjectBuildingException( projectId, "Failed build model from URL \'" + url.toExternalForm() +
- "\'\nError: \'" + e.getLocalizedMessage() + "\'", e );
+ "\'\nError: \'" + e.getLocalizedMessage() + "\'", url.toExternalForm(), e );
}
finally
{
@@ -1096,15 +1066,8 @@
}
}
- private static String createCacheKey( String groupId,
- String artifactId,
- String version )
- {
- return groupId + ":" + artifactId + ":" + version;
- }
-
protected Set createPluginArtifacts( String projectId,
- List plugins )
+ List plugins, String pomLocation )
throws ProjectBuildingException
{
Set pluginArtifacts = new HashSet();
@@ -1133,7 +1096,7 @@
{
throw new ProjectBuildingException( projectId, "Unable to parse version '" + version +
"' for plugin '" + ArtifactUtils.versionlessKey( p.getGroupId(), p.getArtifactId() ) + "': " +
- e.getMessage(), e );
+ e.getMessage(), pomLocation, e );
}
if ( artifact != null )
@@ -1147,7 +1110,7 @@
// TODO: share with createPluginArtifacts?
protected Set createReportArtifacts( String projectId,
- List reports )
+ List reports, String pomLocation )
throws ProjectBuildingException
{
Set pluginArtifacts = new HashSet();
@@ -1178,7 +1141,7 @@
{
throw new ProjectBuildingException( projectId, "Unable to parse version '" + version +
"' for report '" + ArtifactUtils.versionlessKey( p.getGroupId(), p.getArtifactId() ) + "': " +
- e.getMessage(), e );
+ e.getMessage(), pomLocation, e );
}
if ( artifact != null )
@@ -1193,7 +1156,7 @@
// TODO: share with createPluginArtifacts?
protected Set createExtensionArtifacts( String projectId,
- List extensions )
+ List extensions, String pomLocation )
throws ProjectBuildingException
{
Set extensionArtifacts = new HashSet();
@@ -1225,7 +1188,7 @@
{
throw new ProjectBuildingException( projectId, "Unable to parse version '" + version +
"' for extension '" + ArtifactUtils.versionlessKey( ext.getGroupId(), ext.getArtifactId() ) +
- "': " + e.getMessage(), e );
+ "': " + e.getMessage(), pomLocation, e );
}
if ( artifact != null )
@@ -1250,11 +1213,5 @@
String projectId = safeVersionlessKey( STANDALONE_SUPERPOM_GROUPID, STANDALONE_SUPERPOM_ARTIFACTID );
return readModel( projectId, url, STRICT_MODEL_PARSING );
- }
-
- public void contextualize( Context context )
- throws ContextException
- {
- container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DuplicateProjectException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DuplicateProjectException.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DuplicateProjectException.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DuplicateProjectException.java Fri Oct 12 17:10:29 2007
@@ -1,5 +1,6 @@
package org.apache.maven.project;
+import java.io.File;
/*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -22,20 +23,42 @@
/**
* Exception that occurs when the project list contains duplicate projects instead of ignoring one.
- *
+ *
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
public class DuplicateProjectException
extends Exception
{
- public DuplicateProjectException( String message )
+ private final String projectId;
+
+ private final File existingProjectFile;
+
+ private final File conflictingProjectFile;
+
+ public DuplicateProjectException( String projectId,
+ File existingProjectFile,
+ File conflictingProjectFile,
+ String message )
{
super( message );
+ this.projectId = projectId;
+ this.existingProjectFile = existingProjectFile;
+ this.conflictingProjectFile = conflictingProjectFile;
}
-
- public DuplicateProjectException( String message, Exception e )
+
+ public String getProjectId()
+ {
+ return projectId;
+ }
+
+ public File getExistingProjectFile()
+ {
+ return existingProjectFile;
+ }
+
+ public File getConflictingProjectFile()
{
- super( message, e );
+ return conflictingProjectFile;
}
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/InvalidProjectModelException.java Fri Oct 12 17:10:29 2007
@@ -19,50 +19,60 @@
* under the License.
*/
+import org.apache.maven.artifact.InvalidRepositoryException;
+import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.apache.maven.project.validation.ModelValidationResult;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
public class InvalidProjectModelException
extends ProjectBuildingException
{
- private final String pomLocation;
-
private ModelValidationResult validationResult;
- public InvalidProjectModelException( String projectId, String pomLocation, String message, Throwable cause )
+ public InvalidProjectModelException( String projectId,
+ String pomLocation,
+ String message,
+ ModelInterpolationException cause )
+ {
+ super( projectId, message, pomLocation, cause );
+ }
+
+ public InvalidProjectModelException( String projectId,
+ String pomLocation,
+ String message,
+ InvalidRepositoryException cause )
{
- super( projectId, message, cause );
- this.pomLocation = pomLocation;
+ super( projectId, message, pomLocation, cause );
}
- public InvalidProjectModelException( String projectId, String pomLocation, String message,
+ public InvalidProjectModelException( String projectId,
+ String pomLocation,
+ String message,
ModelValidationResult validationResult )
{
- super( projectId, message );
+ super( projectId, message, pomLocation );
- this.pomLocation = pomLocation;
this.validationResult = validationResult;
}
- public InvalidProjectModelException( String projectId, String pomLocation, String message )
+ public InvalidProjectModelException( String projectId,
+ String pomLocation,
+ String message )
{
- super( projectId, message );
-
- this.pomLocation = pomLocation;
+ super( projectId, message, pomLocation );
}
- public final String getPomLocation()
+ public InvalidProjectModelException( String projectId,
+ String pomLocation,
+ String message,
+ XmlPullParserException cause )
{
- return pomLocation;
+ super( projectId, message, pomLocation, cause );
}
public final ModelValidationResult getValidationResult()
{
return validationResult;
- }
-
- public String getMessage()
- {
- return super.getMessage() + " at " + this.pomLocation;
}
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuilder.java Fri Oct 12 17:10:29 2007
@@ -41,7 +41,6 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.profiles.ProfileManager;
-import org.apache.maven.wagon.events.TransferListener;
import java.io.File;
import java.util.List;
@@ -82,7 +81,7 @@
throws ProjectBuildingException;
/**
- *
+ *
* @return
* @throws ProjectBuildingException
*/
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuildingResult.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuildingResult.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuildingResult.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProjectBuildingResult.java Fri Oct 12 17:10:29 2007
@@ -20,7 +20,6 @@
*/
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
-import org.apache.maven.project.validation.ModelValidationResult;
/**
* @author Jason van Zyl
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java Fri Oct 12 17:10:29 2007
@@ -1,5 +1,16 @@
package org.apache.maven.project;
+import org.apache.maven.artifact.InvalidRepositoryException;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+import org.apache.maven.profiles.activation.ProfileActivationException;
+import org.apache.maven.project.artifact.InvalidDependencyVersionException;
+import org.apache.maven.project.interpolation.ModelInterpolationException;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+import java.io.IOException;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,25 +39,160 @@
{
private final String projectId;
- public ProjectBuildingException( String projectId, String message )
+ private String pomLocation;
+
+ public ProjectBuildingException( String projectId,
+ String message )
+ {
+ super( message );
+ this.projectId = projectId;
+ }
+
+ protected ProjectBuildingException( String projectId,
+ String message,
+ String pomLocation )
{
super( message );
this.projectId = projectId;
+ this.pomLocation = pomLocation;
}
- public ProjectBuildingException( String projectId, String message, Throwable cause )
+ public ProjectBuildingException( String projectId,
+ String message,
+ String pomLocation,
+ ProfileActivationException cause )
{
super( message, cause );
this.projectId = projectId;
+ this.pomLocation = pomLocation;
}
-
+
+ public ProjectBuildingException( String projectId,
+ String message,
+ String pomLocation,
+ IOException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ this.pomLocation = pomLocation;
+ }
+
+ public ProjectBuildingException( String projectId,
+ String message,
+ String pomLocation,
+ XmlPullParserException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ this.pomLocation = pomLocation;
+ }
+
+ protected ProjectBuildingException( String projectId,
+ String message,
+ XmlPullParserException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ }
+
+ public ProjectBuildingException( String projectId,
+ String message,
+ String pomLocation,
+ InvalidRepositoryException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ this.pomLocation = pomLocation;
+ }
+
+ public ProjectBuildingException( String projectId,
+ String message,
+ InvalidRepositoryException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ }
+
+ public ProjectBuildingException( String projectId,
+ String message,
+ ArtifactResolutionException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ }
+
+ public ProjectBuildingException( String projectId,
+ String message,
+ ArtifactNotFoundException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ }
+
+ public ProjectBuildingException( String projectId,
+ String message,
+ String pomLocation,
+ ArtifactResolutionException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ this.pomLocation = pomLocation;
+ }
+
+ public ProjectBuildingException( String projectId,
+ String message,
+ String pomLocation,
+ ArtifactNotFoundException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ this.pomLocation = pomLocation;
+ }
+
+ public ProjectBuildingException( String projectId,
+ String message,
+ String pomLocation,
+ InvalidVersionSpecificationException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ this.pomLocation = pomLocation;
+ }
+
+ public ProjectBuildingException( String projectId,
+ String message,
+ String pomLocation,
+ InvalidDependencyVersionException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ this.pomLocation = pomLocation;
+ }
+
+ protected ProjectBuildingException( String projectId,
+ String message,
+ String pomLocation,
+ ModelInterpolationException cause )
+ {
+ super( message, cause );
+ this.projectId = projectId;
+ this.pomLocation = pomLocation;
+ }
+
+ public String getPomLocation()
+ {
+ return pomLocation;
+ }
+
public String getProjectId()
{
return projectId;
}
- public String getMessage()
+ public String getMessage()
{
- return super.getMessage() + " for project " + this.projectId;
+ return super.getMessage() + " for project " + projectId
+ + ( ( pomLocation == null ? "" : " at " + pomLocation ) );
}
+
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectSorter.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectSorter.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectSorter.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectSorter.java Fri Oct 12 17:10:29 2007
@@ -87,7 +87,14 @@
if ( dag.getVertex( id ) != null )
{
- throw new DuplicateProjectException( "Project '" + id + "' is duplicated in the reactor" );
+ MavenProject conflictingProject = (MavenProject) projectMap.get( id );
+
+ throw new DuplicateProjectException( id,
+ conflictingProject.getFile(),
+ project.getFile(),
+ "Project '"
+ + id
+ + "' is duplicated in the reactor" );
}
dag.addVertex( id );
@@ -138,7 +145,7 @@
{
Plugin plugin = (Plugin) j.next();
String pluginId = ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() );
- if ( dag.getVertex( pluginId ) != null && !pluginId.equals( id ) )
+ if ( ( dag.getVertex( pluginId ) != null ) && !pluginId.equals( id ) )
{
addEdgeWithParentCheck( projectMap, pluginId, project, id );
}
@@ -152,7 +159,7 @@
{
ReportPlugin plugin = (ReportPlugin) j.next();
String pluginId = ArtifactUtils.versionlessKey( plugin.getGroupId(), plugin.getArtifactId() );
- if ( dag.getVertex( pluginId ) != null && !pluginId.equals( id ) )
+ if ( ( dag.getVertex( pluginId ) != null ) && !pluginId.equals( id ) )
{
addEdgeWithParentCheck( projectMap, pluginId, project, id );
}
@@ -186,7 +193,7 @@
throws CycleDetectedException
{
MavenProject extProject = (MavenProject) projectMap.get( projectRefId );
-
+
if ( extProject == null )
{
return;
@@ -211,7 +218,7 @@
{
if ( topLevelProject == null )
{
- for ( Iterator i = sortedProjects.iterator(); i.hasNext() && topLevelProject == null; )
+ for ( Iterator i = sortedProjects.iterator(); i.hasNext() && ( topLevelProject == null ); )
{
MavenProject project = (MavenProject) i.next();
if ( project.isExecutionRoot() )
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java Fri Oct 12 17:10:29 2007
@@ -19,17 +19,14 @@
* under the License.
*/
-import org.apache.maven.artifact.InvalidRepositoryException;
+import org.apache.maven.artifact.UnknownRepositoryLayoutException;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.Repository;
-import org.apache.maven.model.RepositoryBase;
import org.apache.maven.model.RepositoryPolicy;
import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import java.util.ArrayList;
import java.util.Iterator;
@@ -44,7 +41,7 @@
public static List buildArtifactRepositories( List repositories,
ArtifactRepositoryFactory artifactRepositoryFactory,
PlexusContainer container )
- throws InvalidRepositoryException
+ throws UnknownRepositoryLayoutException
{
List repos = new ArrayList();
@@ -67,17 +64,14 @@
public static ArtifactRepository buildDeploymentArtifactRepository( DeploymentRepository repo,
ArtifactRepositoryFactory artifactRepositoryFactory,
PlexusContainer container )
- throws InvalidRepositoryException
+ throws UnknownRepositoryLayoutException
{
if ( repo != null )
{
String id = repo.getId();
String url = repo.getUrl();
- // TODO: make this a map inside the factory instead, so no lookup needed
- ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
-
- return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, layout,
+ return artifactRepositoryFactory.createDeploymentArtifactRepository( id, url, repo.getLayout(),
repo.isUniqueVersion() );
}
else
@@ -89,20 +83,17 @@
public static ArtifactRepository buildArtifactRepository( Repository repo,
ArtifactRepositoryFactory artifactRepositoryFactory,
PlexusContainer container )
- throws InvalidRepositoryException
+ throws UnknownRepositoryLayoutException
{
if ( repo != null )
{
String id = repo.getId();
String url = repo.getUrl();
- // TODO: make this a map inside the factory instead, so no lookup needed
- ArtifactRepositoryLayout layout = getRepositoryLayout( repo, container );
-
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() );
ArtifactRepositoryPolicy releases = buildArtifactRepositoryPolicy( repo.getReleases() );
- return artifactRepositoryFactory.createArtifactRepository( id, url, layout, snapshots, releases );
+ return artifactRepositoryFactory.createArtifactRepository( id, url, repo.getLayout(), snapshots, releases );
}
else
{
@@ -130,24 +121,6 @@
}
return new ArtifactRepositoryPolicy( enabled, updatePolicy, checksumPolicy );
- }
-
- private static ArtifactRepositoryLayout getRepositoryLayout( RepositoryBase mavenRepo, PlexusContainer container )
- throws InvalidRepositoryException
- {
- String layout = mavenRepo.getLayout();
-
- ArtifactRepositoryLayout repositoryLayout;
- try
- {
- repositoryLayout = (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE, layout );
- }
- catch ( ComponentLookupException e )
- {
- throw new InvalidRepositoryException( "Cannot find layout implementation corresponding to: \'" + layout +
- "\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e );
- }
- return repositoryLayout;
}
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java Fri Oct 12 17:10:29 2007
@@ -1,5 +1,7 @@
package org.apache.maven.project.artifact;
+import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
@@ -28,7 +30,7 @@
public class InvalidDependencyVersionException
extends Exception
{
- public InvalidDependencyVersionException( String message, Exception cause )
+ public InvalidDependencyVersionException( String message, InvalidVersionSpecificationException cause )
{
super( message, cause );
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Fri Oct 12 17:10:29 2007
@@ -47,7 +47,13 @@
import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.build.ProjectBuildCache;
import org.apache.maven.project.validation.ModelValidationResult;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
@@ -65,7 +71,7 @@
*/
public class MavenMetadataSource
extends AbstractLogEnabled
- implements ArtifactMetadataSource
+ implements ArtifactMetadataSource, Contextualizable
{
public static final String ROLE_HINT = "default";
@@ -74,12 +80,14 @@
private ArtifactFactory artifactFactory;
private RepositoryMetadataManager repositoryMetadataManager;
-
+
private BuildContextManager buildContextManager;
// lazily instantiated and cached.
private MavenProject superProject;
+ private PlexusContainer container;
+
/**
* Retrieve the metadata for the project from the repository.
* Uses the ProjectBuilder, to enable post-processing and inheritance calculation before retrieving the
@@ -88,8 +96,17 @@
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List remoteRepositories )
throws ArtifactMetadataRetrievalException
{
+ try
+ {
+ loadProjectBuilder();
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new ArtifactMetadataRetrievalException( "Cannot lookup MavenProjectBuilder component instance: " + e.getMessage(), e );
+ }
+
ProjectBuildCache cache = ProjectBuildCache.read( buildContextManager );
-
+
MavenProject project = null;
Artifact pomArtifact;
@@ -107,7 +124,7 @@
else
{
project = cache.getCachedProject( artifact );
-
+
if ( project == null )
{
try
@@ -122,7 +139,7 @@
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "Reason: " + e.getMessage() );
-
+
ModelValidationResult validationResult = e.getValidationResult();
if ( validationResult != null )
@@ -144,7 +161,7 @@
artifact.getDependencyConflictId() + "': " + e.getMessage(), e );
}
}
-
+
if ( project != null )
{
@@ -154,7 +171,7 @@
if ( distMgmt != null )
{
relocation = distMgmt.getRelocation();
-
+
artifact.setDownloadUrl( distMgmt.getDownloadUrl() );
pomArtifact.setDownloadUrl( distMgmt.getDownloadUrl() );
}
@@ -174,7 +191,7 @@
artifact.setVersionRange( VersionRange.createFromVersion( relocation.getVersion() ) );
}
- if ( artifact.getDependencyFilter() != null &&
+ if ( ( artifact.getDependencyFilter() != null ) &&
!artifact.getDependencyFilter().include( artifact ) )
{
return null;
@@ -188,7 +205,7 @@
message += " " + relocation.getMessage() + "\n";
}
- if ( artifact.getDependencyTrail() != null && artifact.getDependencyTrail().size() == 1 )
+ if ( ( artifact.getDependencyTrail() != null ) && ( artifact.getDependencyTrail().size() == 1 ) )
{
getLogger().warn( "While downloading " + artifact.getGroupId() + ":" +
artifact.getArtifactId() + ":" + artifact.getVersion() + message + "\n" );
@@ -217,8 +234,8 @@
{
// TODO: this could come straight from the project, negating the need to set it in the project itself?
artifact.setDownloadUrl( pomArtifact.getDownloadUrl() );
- }
-
+ }
+
ResolutionGroup result;
if ( project == null )
@@ -255,6 +272,15 @@
return result;
}
+ private void loadProjectBuilder()
+ throws ComponentLookupException
+ {
+ if ( mavenProjectBuilder == null )
+ {
+ mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.class );
+ }
+ }
+
private List aggregateRepositoryLists( List remoteRepositories, List remoteArtifactRepositories )
throws ArtifactMetadataRetrievalException
{
@@ -284,7 +310,7 @@
{
ArtifactRepository repo = (ArtifactRepository) aggregatedIterator.next();
- // if the repository exists in the list and was introduced by another POM's super-pom,
+ // if the repository exists in the list and was introduced by another POM's super-pom,
// remove it...the repository definitions from the super-POM should only be at the end of
// the list.
// if the repository has been redefined, leave it.
@@ -352,10 +378,10 @@
}
ArtifactFilter artifactFilter = dependencyFilter;
-
- if ( artifact != null && ( artifactFilter == null || artifactFilter.include( artifact ) ) )
+
+ if ( ( artifact != null ) && ( ( artifactFilter == null ) || artifactFilter.include( artifact ) ) )
{
- if ( d.getExclusions() != null && !d.getExclusions().isEmpty() )
+ if ( ( d.getExclusions() != null ) && !d.getExclusions().isEmpty() )
{
List exclusions = new ArrayList();
for ( Iterator j = d.getExclusions().iterator(); j.hasNext(); )
@@ -409,7 +435,7 @@
List versions;
Metadata repoMetadata = metadata.getMetadata();
- if ( repoMetadata != null && repoMetadata.getVersioning() != null )
+ if ( ( repoMetadata != null ) && ( repoMetadata.getVersioning() != null ) )
{
List metadataVersions = repoMetadata.getVersioning().getVersions();
versions = new ArrayList( metadataVersions.size() );
@@ -425,5 +451,11 @@
}
return versions;
+ }
+
+ public void contextualize( Context context )
+ throws ContextException
+ {
+ container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}
}
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/build/model/DefaultModelLineageBuilder.java Fri Oct 12 17:10:29 2007
@@ -197,11 +197,11 @@
}
catch ( IOException e )
{
- throw new ProjectBuildingException( "unknown", "Failed to read model from: " + pomFile, e );
+ throw new ProjectBuildingException( "unknown", "Failed to read model from: " + pomFile, pomFile.getAbsolutePath(), e );
}
catch ( XmlPullParserException e )
{
- throw new ProjectBuildingException( "unknown", "Failed to parse model from: " + pomFile, e );
+ throw new ProjectBuildingException( "unknown", "Failed to parse model from: " + pomFile, pomFile.getAbsolutePath(), e );
}
finally
{
@@ -250,7 +250,7 @@
catch ( InvalidRepositoryException e )
{
throw new ProjectBuildingException( model.getId(), "Failed to create ArtifactRepository list for: "
- + pomFile, e );
+ + pomFile, pomFile.getAbsolutePath(), e );
}
}
@@ -258,7 +258,7 @@
}
private void loadActiveProfileRepositories( List repositories, Model model, ProfileManager profileManager,
- File projectDir )
+ File pomFile )
throws ProjectBuildingException
{
List explicitlyActive;
@@ -275,9 +275,9 @@
explicitlyInactive = Collections.EMPTY_LIST;
}
- LinkedHashSet profileRepos = profileAdvisor.getArtifactRepositoriesFromActiveProfiles( profileManager, model.getId() );
+ LinkedHashSet profileRepos = profileAdvisor.getArtifactRepositoriesFromActiveProfiles( profileManager, pomFile, model.getId() );
- profileRepos.addAll( profileAdvisor.getArtifactRepositoriesFromActiveProfiles( model, projectDir,
+ profileRepos.addAll( profileAdvisor.getArtifactRepositoriesFromActiveProfiles( model, pomFile,
explicitlyActive,
explicitlyInactive ) );
@@ -310,7 +310,7 @@
File parentPomFile = projectBuildCache.getCachedModelFile( modelParent );
- if ( parentPomFile == null )
+ if ( ( parentPomFile == null ) && ( modelPomFile != null ) )
{
parentPomFile = resolveParentWithRelativePath( modelParent, modelPomFile );
}
@@ -319,7 +319,7 @@
{
try
{
- parentPomFile = resolveParentFromRepositories( modelParent, localRepository, remoteRepositories, modelPomFile );
+ parentPomFile = resolveParentFromRepositories( modelParent, localRepository, remoteRepositories, model.getId() );
}
catch( ProjectBuildingException e )
{
@@ -388,7 +388,7 @@
}
private File resolveParentFromRepositories( Parent modelParent, ArtifactRepository localRepository,
- List remoteRepositories, File pomFile )
+ List remoteRepositories, String childId )
throws ProjectBuildingException
{
Artifact parentPomArtifact = artifactFactory.createBuildArtifact( modelParent.getGroupId(), modelParent
@@ -405,12 +405,12 @@
catch ( ArtifactResolutionException e )
{
throw new ProjectBuildingException( "Parent: " + modelParent.getId(),
- "Failed to resolve POM for parent of: " + pomFile, e );
+ "Failed to resolve POM for parent of: " + childId, e );
}
catch ( ArtifactNotFoundException e )
{
throw new ProjectBuildingException( "Parent: " + modelParent.getId(), "Cannot find parent: "
- + parentPomArtifact.getId() + " of: " + pomFile, e );
+ + parentPomArtifact.getId() + " of: " + childId, e );
}
if ( parentPomArtifact.isResolved() )
Modified: maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml Fri Oct 12 17:10:29 2007
@@ -148,6 +148,10 @@
<implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation>
<requirements>
<requirement>
+ <role>org.apache.maven.artifact.metadata.ArtifactMetadataSource</role>
+ <role-hint>default</role-hint>
+ </requirement>
+ <requirement>
<role>org.apache.maven.project.build.model.ModelLineageBuilder</role>
<role-hint>default</role-hint>
</requirement>
@@ -312,9 +316,6 @@
<implementation>org.apache.maven.project.artifact.MavenMetadataSource</implementation>
<requirements>
<requirement>
- <role>org.apache.maven.project.MavenProjectBuilder</role>
- </requirement>
- <requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
@@ -333,9 +334,6 @@
<implementation>org.apache.maven.project.artifact.MavenMetadataSource</implementation>
<requirements>
<requirement>
- <role>org.apache.maven.project.MavenProjectBuilder</role>
- </requirement>
- <requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement>
<requirement>
@@ -352,10 +350,6 @@
<role>org.apache.maven.MavenTools</role>
<implementation>org.apache.maven.DefaultMavenTools</implementation>
<requirements>
- <requirement>
- <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
- <role-hint>default</role-hint>
- </requirement>
<requirement>
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
Modified: maven/components/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/pom.xml?rev=584343&r1=584342&r2=584343&view=diff
==============================================================================
--- maven/components/trunk/pom.xml (original)
+++ maven/components/trunk/pom.xml Fri Oct 12 17:10:29 2007
@@ -121,7 +121,7 @@
<module>maven-embedder</module>
</modules>
<properties>
- <plexusVersion>1.0-alpha-30</plexusVersion>
+ <plexusVersion>1.0-alpha-33-SNAPSHOT</plexusVersion>
<wagonVersion>1.0-beta-2</wagonVersion>
</properties>
<dependencies>
@@ -267,4 +267,4 @@
</profile>
</profiles>
-</project>
+</project>
\ No newline at end of file