o Reverted r750083 which is a bad approach with respect to embedding, instead just programmatically injected the central repo if not already given/overriden in the settings

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@750098 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-03-04 18:40:33 +00:00
parent fd1c4b534c
commit d9bf8c6a60
4 changed files with 37 additions and 34 deletions

View File

@ -244,37 +244,6 @@ under the License.
</properties> </properties>
</profile> </profile>
--> -->
<profile>
<id>maven-central-repository</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<id>central</id>
<name>Maven Repository Switchboard</name>
<layout>default</layout>
<url>http://repo1.maven.org/maven2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<name>Maven Plugin Repository</name>
<url>http://repo1.maven.org/maven2</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles> </profiles>
<!-- activeProfiles <!-- activeProfiles

View File

@ -208,8 +208,6 @@ END SNIPPET: ant-bootstrap -->
<arg value="install"/> <arg value="install"/>
<arg value="-Dmaven.repo.local=${maven.repo.local}"/> <arg value="-Dmaven.repo.local=${maven.repo.local}"/>
<arg value="-Dsurefire.useFile=${surefire.useFile}"/> <arg value="-Dsurefire.useFile=${surefire.useFile}"/>
<arg value="--global-settings"/>
<arg file="apache-maven/src/conf/settings.xml"/>
</java> </java>
</target> </target>

View File

@ -31,7 +31,6 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import org.apache.maven.Maven; import org.apache.maven.Maven;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException; import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;

View File

@ -18,6 +18,7 @@ package org.apache.maven.embedder.execution;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashSet; import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
@ -35,6 +36,7 @@ import org.apache.maven.errors.DefaultCoreErrorReporter;
import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.model.Profile; import org.apache.maven.model.Profile;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.model.RepositoryPolicy;
import org.apache.maven.monitor.event.DefaultEventMonitor; import org.apache.maven.monitor.event.DefaultEventMonitor;
import org.apache.maven.monitor.event.EventMonitor; import org.apache.maven.monitor.event.EventMonitor;
import org.apache.maven.profiles.DefaultProfileManager; import org.apache.maven.profiles.DefaultProfileManager;
@ -224,9 +226,44 @@ public class DefaultMavenExecutionRequestPopulator
} }
} }
injectDefaultRepositories( request );
processRepositoriesInSettings( request, configuration ); processRepositoriesInSettings( request, configuration );
} }
private void injectDefaultRepositories( MavenExecutionRequest request )
throws MavenEmbedderException
{
Set<String> definedRepositories = new HashSet<String>();
if ( request.getRemoteRepositories() != null )
{
for ( ArtifactRepository repository : request.getRemoteRepositories() )
{
definedRepositories.add( repository.getId() );
}
}
if ( !definedRepositories.contains( "central" ) )
{
Repository repo = new Repository();
repo.setId( "central" );
repo.setUrl( "http://repo1.maven.org/maven2" );
repo.setName( "Maven Repository Switchboard" );
RepositoryPolicy snapshotPolicy = new RepositoryPolicy();
snapshotPolicy.setEnabled( false );
repo.setSnapshots( snapshotPolicy );
try
{
ArtifactRepository ar = repositorySystem.buildArtifactRepository( repo );
request.addRemoteRepository( ar );
}
catch ( InvalidRepositoryException e )
{
throw new MavenEmbedderException( "Cannot create remote repository " + repo.getId(), e );
}
}
}
private void processRepositoriesInSettings( MavenExecutionRequest request, Configuration configuration ) private void processRepositoriesInSettings( MavenExecutionRequest request, Configuration configuration )
throws MavenEmbedderException throws MavenEmbedderException
{ {