mirror of https://github.com/apache/maven.git
o removal of as many deprecated methods from the project builder as possible. so far i've discovered two obsolete methods used by plugins directly
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@699838 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b6c2132bc7
commit
cf62d1c301
|
@ -115,17 +115,16 @@ public class DefaultMavenProjectBuilder
|
|||
// MavenProjectBuilder Implementation
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public MavenProject build( File projectDescriptor, ArtifactRepository localRepository,
|
||||
ProfileManager profileManager )
|
||||
// This is used by the SITE plugin.
|
||||
public MavenProject build( File project, ArtifactRepository localRepository, ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
ProjectBuilderConfiguration config =
|
||||
new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository )
|
||||
.setGlobalProfileManager( profileManager );
|
||||
|
||||
return build( projectDescriptor, config );
|
||||
}
|
||||
|
||||
ProjectBuilderConfiguration cbf = new DefaultProjectBuilderConfiguration();
|
||||
cbf.setLocalRepository( localRepository );
|
||||
cbf.setGlobalProfileManager( profileManager );
|
||||
return build( project, cbf );
|
||||
}
|
||||
|
||||
public MavenProject build( File projectDescriptor, ProjectBuilderConfiguration config )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
|
@ -148,21 +147,14 @@ public class DefaultMavenProjectBuilder
|
|||
return project;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||
ArtifactRepository localRepository, boolean allowStub )
|
||||
// This is used by the RR plugin
|
||||
public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStubs )
|
||||
throws ProjectBuildingException
|
||||
|
||||
{
|
||||
return buildFromRepository( artifact, remoteArtifactRepositories, localRepository );
|
||||
}
|
||||
|
||||
public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||
ArtifactRepository localRepository )
|
||||
public MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
File f = artifact.getFile();
|
||||
|
@ -186,22 +178,6 @@ public class DefaultMavenProjectBuilder
|
|||
return project;
|
||||
}
|
||||
|
||||
// what is using this externally? jvz.
|
||||
public MavenProject buildStandaloneSuperProject()
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
//TODO mkleint - use the (Container, Properties) constructor to make system properties embeddable
|
||||
return buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration() );
|
||||
}
|
||||
|
||||
public MavenProject buildStandaloneSuperProject( ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
//TODO mkleint - use the (Container, Properties) constructor to make system properties embeddable
|
||||
return buildStandaloneSuperProject(
|
||||
new DefaultProjectBuilderConfiguration().setGlobalProfileManager( profileManager ) );
|
||||
}
|
||||
|
||||
public MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
|
@ -309,31 +285,6 @@ public class DefaultMavenProjectBuilder
|
|||
return project;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.0.x
|
||||
*/
|
||||
public MavenProject buildWithDependencies( File projectDescriptor, ArtifactRepository localRepository,
|
||||
ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
return buildProjectWithDependencies( projectDescriptor, localRepository, profileManager ).getProject();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 2.1
|
||||
*/
|
||||
public MavenProjectBuildingResult buildProjectWithDependencies( File projectDescriptor,
|
||||
ArtifactRepository localRepository,
|
||||
ProfileManager profileManager )
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
ProjectBuilderConfiguration config =
|
||||
new DefaultProjectBuilderConfiguration().setLocalRepository( localRepository )
|
||||
.setGlobalProfileManager( profileManager );
|
||||
|
||||
return buildProjectWithDependencies( projectDescriptor, config );
|
||||
}
|
||||
|
||||
public MavenProjectBuildingResult buildProjectWithDependencies( File projectDescriptor,
|
||||
ProjectBuilderConfiguration config )
|
||||
throws ProjectBuildingException
|
||||
|
@ -636,4 +587,4 @@ public class DefaultMavenProjectBuilder
|
|||
setBuildOutputDirectoryOnParent( parent );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +1,18 @@
|
|||
package org.apache.maven.project;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more contributor license
|
||||
* agreements. See the NOTICE file distributed with this work for additional information regarding
|
||||
* copyright ownership. The ASF licenses this file to you 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;
|
||||
|
@ -38,60 +34,26 @@ public interface MavenProjectBuilder
|
|||
|
||||
boolean STRICT_MODEL_PARSING = true;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link MavenProjectBuilder#build(File, ProjectBuilderConfiguration)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
MavenProject build( File project, ArtifactRepository localRepository, ProfileManager globalProfileManager )
|
||||
// Used directly by plugins
|
||||
|
||||
// site
|
||||
MavenProject build( File project, ArtifactRepository localRepository, ProfileManager profileManager )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
// remote resources plugin
|
||||
MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository, boolean allowStub )
|
||||
throws ProjectBuildingException;
|
||||
//
|
||||
|
||||
MavenProject build( File project, ProjectBuilderConfiguration configuration )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProject buildWithDependencies( File project, ArtifactRepository localRepository,
|
||||
ProfileManager globalProfileManager )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProjectBuildingResult buildProjectWithDependencies( File project, ProjectBuilderConfiguration config )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link MavenProjectBuilder#buildProjectWithDependencies(File, ProjectBuilderConfiguration)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
MavenProjectBuildingResult buildProjectWithDependencies( File project, ArtifactRepository localRepository,
|
||||
ProfileManager globalProfileManager )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
|
||||
MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||
ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
/**
|
||||
* @deprecated We do not want to allow projects to not have POMs. Maven 1.x repositories be damned.
|
||||
*/
|
||||
@Deprecated
|
||||
MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories,
|
||||
ArtifactRepository localRepository, boolean allowStub )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link MavenProjectBuilder#buildStandaloneSuperProject(ProjectBuilderConfiguration)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
MavenProject buildStandaloneSuperProject()
|
||||
throws ProjectBuildingException;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link MavenProjectBuilder#buildStandaloneSuperProject(ProjectBuilderConfiguration)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
MavenProject buildStandaloneSuperProject( ProfileManager profileManager )
|
||||
MavenProject buildFromRepository( Artifact artifact, List remoteArtifactRepositories, ArtifactRepository localRepository )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
MavenProject buildStandaloneSuperProject( ProjectBuilderConfiguration config )
|
||||
throws ProjectBuildingException;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,166 @@
|
|||
package org.apache.maven.project.artifact;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.DefaultArtifact;
|
||||
import org.apache.maven.artifact.InvalidArtifactRTException;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.artifact.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class AttachedArtifact
|
||||
extends DefaultArtifact
|
||||
{
|
||||
|
||||
private final Artifact parent;
|
||||
|
||||
public AttachedArtifact( Artifact parent, String type, String classifier, ArtifactHandler artifactHandler )
|
||||
{
|
||||
super( parent.getGroupId(), parent.getArtifactId(), parent.getVersionRange(), parent.getScope(), type,
|
||||
classifier, artifactHandler, parent.isOptional() );
|
||||
|
||||
setDependencyTrail( Collections.singletonList( parent.getId() ) );
|
||||
|
||||
this.parent = parent;
|
||||
|
||||
if ( getId().equals( parent.getId() ) )
|
||||
{
|
||||
throw new InvalidArtifactRTException( parent.getGroupId(), parent.getArtifactId(), parent.getVersion(), parent.getType(), "An attached artifact must have a different ID than its corresponding main artifact." );
|
||||
}
|
||||
}
|
||||
|
||||
public AttachedArtifact( Artifact parent, String type, ArtifactHandler artifactHandler )
|
||||
{
|
||||
this( parent, type, null, artifactHandler );
|
||||
}
|
||||
|
||||
public void setArtifactId( String artifactId )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public List getAvailableVersions()
|
||||
{
|
||||
return parent.getAvailableVersions();
|
||||
}
|
||||
|
||||
public void setAvailableVersions( List availableVersions )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getBaseVersion()
|
||||
{
|
||||
return parent.getBaseVersion();
|
||||
}
|
||||
|
||||
public void setBaseVersion( String baseVersion )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getDownloadUrl()
|
||||
{
|
||||
return parent.getDownloadUrl();
|
||||
}
|
||||
|
||||
public void setDownloadUrl( String downloadUrl )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public void setGroupId( String groupId )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public ArtifactRepository getRepository()
|
||||
{
|
||||
return parent.getRepository();
|
||||
}
|
||||
|
||||
public void setRepository( ArtifactRepository repository )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getScope()
|
||||
{
|
||||
return parent.getScope();
|
||||
}
|
||||
|
||||
public void setScope( String scope )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public String getVersion()
|
||||
{
|
||||
return parent.getVersion();
|
||||
}
|
||||
|
||||
public void setVersion( String version )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public VersionRange getVersionRange()
|
||||
{
|
||||
return parent.getVersionRange();
|
||||
}
|
||||
|
||||
public void setVersionRange( VersionRange range )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public boolean isRelease()
|
||||
{
|
||||
return parent.isRelease();
|
||||
}
|
||||
|
||||
public void setRelease( boolean release )
|
||||
{
|
||||
// ignore this. We should ALWAYS use the information from the parent artifact.
|
||||
}
|
||||
|
||||
public boolean isSnapshot()
|
||||
{
|
||||
return parent.isSnapshot();
|
||||
}
|
||||
|
||||
public void addMetadata( ArtifactMetadata metadata )
|
||||
{
|
||||
// ignore. The parent artifact will handle metadata.
|
||||
// we must fail silently here to avoid problems with the artifact transformers.
|
||||
}
|
||||
|
||||
public Collection getMetadataList()
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
}
|
|
@ -41,6 +41,7 @@ import org.apache.maven.model.Dependency;
|
|||
import org.apache.maven.model.DistributionManagement;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
import org.apache.maven.model.Relocation;
|
||||
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
|
||||
import org.apache.maven.project.InvalidProjectModelException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
|
@ -75,6 +76,8 @@ public class MavenMetadataSource
|
|||
|
||||
private RepositoryMetadataManager repositoryMetadataManager;
|
||||
|
||||
public HashMap<String, MavenProject> hm = new HashMap<String, MavenProject>();
|
||||
|
||||
// lazily instantiated and cached.
|
||||
private MavenProject superProject;
|
||||
|
||||
|
@ -143,8 +146,6 @@ public class MavenMetadataSource
|
|||
{
|
||||
return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion();
|
||||
}
|
||||
|
||||
private HashMap<String, MavenProject> hm = new HashMap<String, MavenProject>();
|
||||
|
||||
private ProjectRelocation retrieveRelocatedProject( Artifact artifact, ArtifactRepository localRepository,
|
||||
List<ArtifactRepository> remoteRepositories )
|
||||
|
@ -407,7 +408,7 @@ public class MavenMetadataSource
|
|||
{
|
||||
try
|
||||
{
|
||||
superProject = mavenProjectBuilder.buildStandaloneSuperProject();
|
||||
superProject = mavenProjectBuilder.buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration() );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,206 @@
|
|||
package org.apache.maven.project.artifact;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.metadata.ArtifactMetadataRetrievalException;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.resolver.metadata.ArtifactMetadata;
|
||||
import org.apache.maven.artifact.resolver.metadata.MetadataResolution;
|
||||
import org.apache.maven.artifact.resolver.metadata.MetadataRetrievalException;
|
||||
import org.apache.maven.artifact.resolver.metadata.MetadataSource;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.project.InvalidProjectModelException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
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 java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
* @version $Id$
|
||||
*/
|
||||
public class PomMetadataSource
|
||||
extends AbstractLogEnabled
|
||||
implements MetadataSource,
|
||||
Contextualizable
|
||||
{
|
||||
public static final String ROLE_HINT = "default";
|
||||
|
||||
private MavenProjectBuilder mavenProjectBuilder;
|
||||
|
||||
private ArtifactFactory artifactFactory;
|
||||
|
||||
// lazily instantiated and cached.
|
||||
private MavenProject superProject;
|
||||
|
||||
private PlexusContainer container;
|
||||
|
||||
/** Unfortunately we have projects that are still sending us JARs without the accompanying POMs. */
|
||||
private boolean strictlyEnforceThePresenceOfAValidMavenPOM = true;
|
||||
|
||||
public MetadataResolution retrieve( ArtifactMetadata artifactMetadata,
|
||||
ArtifactRepository localRepository,
|
||||
List remoteRepositories )
|
||||
throws MetadataRetrievalException
|
||||
{
|
||||
try
|
||||
{
|
||||
loadProjectBuilder();
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
throw new MetadataRetrievalException(
|
||||
"Cannot lookup MavenProjectBuilder component instance: " + e.getMessage(), e );
|
||||
}
|
||||
|
||||
MavenProject project = null;
|
||||
|
||||
Artifact pomArtifact = artifactFactory.createProjectArtifact(
|
||||
artifactMetadata.getGroupId()
|
||||
, artifactMetadata.getArtifactId()
|
||||
, artifactMetadata.getVersion()
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository );
|
||||
if ( pomArtifact.getFile() != null )
|
||||
{
|
||||
artifactMetadata.setArtifactUri( pomArtifact.getFile().toURI().toString() );
|
||||
}
|
||||
}
|
||||
catch ( InvalidProjectModelException e )
|
||||
{
|
||||
// We want to capture this in the graph so that we can display the error to the user
|
||||
artifactMetadata.setError( e.getMessage() );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
if ( strictlyEnforceThePresenceOfAValidMavenPOM )
|
||||
{
|
||||
throw new MetadataRetrievalException(
|
||||
"Unable to read the metadata file for artifactMetadata '" +
|
||||
artifactMetadata.getDependencyConflictId() + "': " + e.getMessage(), e, artifactMetadata );
|
||||
}
|
||||
}
|
||||
|
||||
Set artifacts = new HashSet();
|
||||
|
||||
for ( Iterator i = project.getDependencies().iterator(); i.hasNext(); )
|
||||
{
|
||||
Dependency d = (Dependency) i.next();
|
||||
|
||||
artifacts.add( new ArtifactMetadata( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getType(),
|
||||
d.getScope(), d.getClassifier(), null, null, false, null ) );
|
||||
}
|
||||
|
||||
// The remote repositories is intentially null here while working in the graph in the least invasive way
|
||||
// and making sure repositories added for a POM are scope only for a particular POM. We don't want
|
||||
// repositories lingering around or being aggregated after they are used. jvz
|
||||
|
||||
artifactMetadata.setDependencies( artifacts );
|
||||
|
||||
return new MetadataResolution( artifactMetadata );
|
||||
}
|
||||
|
||||
private void loadProjectBuilder()
|
||||
throws ComponentLookupException
|
||||
{
|
||||
if ( mavenProjectBuilder == null )
|
||||
{
|
||||
mavenProjectBuilder = (MavenProjectBuilder) container.lookup( MavenProjectBuilder.class );
|
||||
}
|
||||
}
|
||||
|
||||
private List aggregateRepositoryLists( List remoteRepositories,
|
||||
List remoteArtifactRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
if ( superProject == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
superProject = mavenProjectBuilder.buildStandaloneSuperProject();
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
throw new ArtifactMetadataRetrievalException(
|
||||
"Unable to parse the Maven built-in model: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
List repositories = new ArrayList();
|
||||
|
||||
repositories.addAll( remoteRepositories );
|
||||
|
||||
// ensure that these are defined
|
||||
for ( Iterator it = superProject.getRemoteArtifactRepositories().iterator(); it.hasNext(); )
|
||||
{
|
||||
ArtifactRepository superRepo = (ArtifactRepository) it.next();
|
||||
|
||||
for ( Iterator aggregatedIterator = repositories.iterator(); aggregatedIterator.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repo = (ArtifactRepository) aggregatedIterator.next();
|
||||
|
||||
// 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.
|
||||
if ( repo.getId().equals( superRepo.getId() ) && repo.getUrl().equals( superRepo.getUrl() ) )
|
||||
{
|
||||
aggregatedIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this list should contain the super-POM repositories, so we don't have to explicitly add them back.
|
||||
for ( Iterator it = remoteArtifactRepositories.iterator(); it.hasNext(); )
|
||||
{
|
||||
ArtifactRepository repository = (ArtifactRepository) it.next();
|
||||
|
||||
if ( !repositories.contains( repository ) )
|
||||
{
|
||||
repositories.add( repository );
|
||||
}
|
||||
}
|
||||
|
||||
return repositories;
|
||||
}
|
||||
|
||||
public void contextualize( Context context )
|
||||
throws ContextException
|
||||
{
|
||||
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
|
||||
}
|
||||
}
|
|
@ -112,9 +112,12 @@ public abstract class AbstractMavenProjectTestCase
|
|||
protected MavenProject getProjectWithDependencies( File pom )
|
||||
throws Exception
|
||||
{
|
||||
ProjectBuilderConfiguration pbc = new DefaultProjectBuilderConfiguration();
|
||||
pbc.setLocalRepository( getLocalRepository() );
|
||||
|
||||
try
|
||||
{
|
||||
return projectBuilder.buildWithDependencies( pom, getLocalRepository(), null );
|
||||
return projectBuilder.buildProjectWithDependencies( pom, pbc).getProject();
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
|
@ -136,7 +139,11 @@ public abstract class AbstractMavenProjectTestCase
|
|||
Properties props = System.getProperties();
|
||||
ProfileActivationContext ctx = new DefaultProfileActivationContext( props, false );
|
||||
|
||||
return projectBuilder.build( pom, getLocalRepository(), new DefaultProfileManager( getContainer(), ctx ) );
|
||||
ProjectBuilderConfiguration pbc = new DefaultProjectBuilderConfiguration();
|
||||
pbc.setLocalRepository( getLocalRepository() );
|
||||
pbc.setGlobalProfileManager( new DefaultProfileManager( getContainer(), ctx ) );
|
||||
|
||||
return projectBuilder.build( pom, pbc );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -58,7 +58,9 @@ public class SuperPomProjectBuilderTest
|
|||
pm.addProfile( profile );
|
||||
pm.explicitlyActivate( profile.getId() );
|
||||
|
||||
MavenProject project = projectBuilder.buildStandaloneSuperProject( pm );
|
||||
ProjectBuilderConfiguration pbc = new DefaultProjectBuilderConfiguration();
|
||||
pbc.setGlobalProfileManager( pm );
|
||||
MavenProject project = projectBuilder.buildStandaloneSuperProject( pbc );
|
||||
|
||||
assertRepository( repo.getId(), project.getRepositories() );
|
||||
assertRepository( repo.getId(), project.getPluginRepositories() );
|
||||
|
@ -69,7 +71,7 @@ public class SuperPomProjectBuilderTest
|
|||
public void testStandaloneSuperPomContainsCentralRepo()
|
||||
throws ProjectBuildingException
|
||||
{
|
||||
MavenProject project = projectBuilder.buildStandaloneSuperProject();
|
||||
MavenProject project = projectBuilder.buildStandaloneSuperProject( new DefaultProjectBuilderConfiguration() );
|
||||
|
||||
assertRepository( "central", project.getRepositories() );
|
||||
assertRepository( "central", project.getPluginRepositories() );
|
||||
|
|
Loading…
Reference in New Issue