mirror of https://github.com/apache/maven.git
o limit system scoped resolution from interacting with repositories all together.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@797675 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
606336da20
commit
aae5e98767
|
@ -367,7 +367,6 @@ public ArtifactResolutionResult resolve( ArtifactResolutionRequest request )
|
|||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
// won't happen
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,16 @@
|
|||
*/
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.Authentication;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.repository.LegacyRepositorySystem;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
@ -31,7 +38,6 @@
|
|||
public class LegacyRepositorySystemTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
|
||||
private RepositorySystem repositorySystem;
|
||||
|
||||
@Override
|
||||
|
@ -39,7 +45,6 @@ protected void setUp()
|
|||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
repositorySystem = lookup( RepositorySystem.class, "default" );
|
||||
}
|
||||
|
||||
|
@ -48,7 +53,6 @@ protected void tearDown()
|
|||
throws Exception
|
||||
{
|
||||
repositorySystem = null;
|
||||
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
|
@ -57,7 +61,6 @@ public void testThatLocalRepositoryWithSpacesIsProperlyHandled()
|
|||
{
|
||||
File basedir = new File( "target/spacy path" ).getAbsoluteFile();
|
||||
ArtifactRepository repo = repositorySystem.createLocalRepository( basedir );
|
||||
|
||||
assertEquals( basedir, new File( repo.getBasedir() ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -107,15 +107,7 @@ public MavenExecutionResult execute( MavenExecutionRequest request )
|
|||
List<MavenProject> projects;
|
||||
try
|
||||
{
|
||||
projects = getProjectsForMavenReactor( request );
|
||||
|
||||
//TODO: We really need to get rid of this requirement in here. If we know there is no project present
|
||||
if ( projects.isEmpty() )
|
||||
{
|
||||
MavenProject project = projectBuilder.buildStandaloneSuperProject( request.getProjectBuildingRequest() );
|
||||
projects.add( project );
|
||||
request.setProjectPresent( false );
|
||||
}
|
||||
projects = getProjectsForMavenReactor( request );
|
||||
}
|
||||
catch ( ProjectBuildingException e )
|
||||
{
|
||||
|
@ -234,19 +226,20 @@ private MavenExecutionResult processResult( MavenExecutionResult result, Excepti
|
|||
private List<MavenProject> getProjectsForMavenReactor( MavenExecutionRequest request )
|
||||
throws MavenExecutionException, ProjectBuildingException
|
||||
{
|
||||
List<MavenProject> projects = new ArrayList<MavenProject>();
|
||||
|
||||
// We have no POM file.
|
||||
//
|
||||
if ( request.getPom() == null || !request.getPom().exists() )
|
||||
{
|
||||
return new ArrayList<MavenProject>();
|
||||
MavenProject project = projectBuilder.buildStandaloneSuperProject( request.getProjectBuildingRequest() );
|
||||
projects.add( project );
|
||||
request.setProjectPresent( false );
|
||||
return projects;
|
||||
}
|
||||
|
||||
List<File> files = Arrays.asList( request.getPom().getAbsoluteFile() );
|
||||
|
||||
List<MavenProject> projects = new ArrayList<MavenProject>();
|
||||
|
||||
List<File> files = Arrays.asList( request.getPom().getAbsoluteFile() );
|
||||
collectProjects( projects, files, request );
|
||||
|
||||
return projects;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public ReactorArtifactRepository( Map<String, MavenProject> reactorProjects )
|
|||
public Artifact find( Artifact artifact )
|
||||
{
|
||||
String projectKey = ArtifactUtils.key( artifact );
|
||||
|
||||
|
||||
MavenProject project = reactorProjects.get( projectKey );
|
||||
|
||||
if ( project != null )
|
||||
|
|
|
@ -84,6 +84,15 @@ public class MavenMetadataSource
|
|||
public ResolutionGroup retrieve( Artifact artifact, ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws ArtifactMetadataRetrievalException
|
||||
{
|
||||
//
|
||||
// If we have a system scoped artifact then we do not want any searching in local or remote repositories
|
||||
// and we want artifact resolution to only return the system scoped artifact itself.
|
||||
//
|
||||
if ( artifact.getScope() != null && artifact.getScope().equals( Artifact.SCOPE_SYSTEM ) )
|
||||
{
|
||||
return new ResolutionGroup( null, null, null );
|
||||
}
|
||||
|
||||
ResolutionGroup cached = cache.get( artifact, localRepository, remoteRepositories );
|
||||
|
||||
if ( cached != null )
|
||||
|
|
|
@ -1,22 +1,18 @@
|
|||
package org.apache.maven.cli;
|
||||
|
||||
/*
|
||||
* 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 java.io.File;
|
||||
|
@ -30,7 +26,6 @@
|
|||
import org.apache.maven.embedder.MavenEmbedderConsoleLogger;
|
||||
import org.apache.maven.embedder.MavenEmbedderException;
|
||||
import org.apache.maven.embedder.MavenEmbedderFileLogger;
|
||||
import org.apache.maven.embedder.MavenEmbedderLogger;
|
||||
import org.apache.maven.exception.ExceptionSummary;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionResult;
|
||||
|
@ -61,8 +56,7 @@ public static int main( String[] args, ClassWorld classWorld )
|
|||
return cli.doMain( args, classWorld );
|
||||
}
|
||||
|
||||
public int doMain( String[] args,
|
||||
ClassWorld classWorld )
|
||||
public int doMain( String[] args, ClassWorld classWorld )
|
||||
{
|
||||
// ----------------------------------------------------------------------
|
||||
// Setup the command line parser
|
||||
|
@ -154,7 +148,7 @@ else if ( debug || commandLine.hasOption( CLIManager.SHOW_VERSION ) )
|
|||
}
|
||||
|
||||
MavenEmbedder mavenEmbedder;
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
mavenEmbedder = new MavenEmbedder( configuration );
|
||||
|
@ -178,22 +172,22 @@ else if ( debug || commandLine.hasOption( CLIManager.SHOW_VERSION ) )
|
|||
}
|
||||
|
||||
// The exception handling should be handled in Maven itself.
|
||||
|
||||
|
||||
if ( result.hasExceptions() )
|
||||
{
|
||||
ExceptionSummary es = result.getExceptionSummary();
|
||||
|
||||
|
||||
if ( es == null )
|
||||
{
|
||||
result.getExceptions().get( 0 ).printStackTrace();
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println( es.getMessage() );
|
||||
|
||||
es.getException().printStackTrace();
|
||||
System.out.println( es.getMessage() );
|
||||
|
||||
es.getException().printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( request.getReactorFailureBehavior() ) )
|
||||
{
|
||||
System.out.println( "+ Build failures were ignored." );
|
||||
|
@ -235,16 +229,11 @@ private Configuration buildEmbedderConfiguration( MavenExecutionRequest request,
|
|||
globalSettingsFile = MavenEmbedder.DEFAULT_GLOBAL_SETTINGS_FILE;
|
||||
}
|
||||
|
||||
Configuration configuration = new DefaultConfiguration()
|
||||
.setUserSettingsFile( userSettingsFile )
|
||||
.setGlobalSettingsFile( globalSettingsFile )
|
||||
.setClassWorld( classWorld );
|
||||
Configuration configuration = new DefaultConfiguration().setUserSettingsFile( userSettingsFile ).setGlobalSettingsFile( globalSettingsFile ).setClassWorld( classWorld );
|
||||
|
||||
if ( commandLine.hasOption( CLIManager.LOG_FILE ) )
|
||||
{
|
||||
File logFile = new File(
|
||||
request.getBaseDirectory(),
|
||||
commandLine.getOptionValue( CLIManager.LOG_FILE ) );
|
||||
File logFile = new File( request.getBaseDirectory(), commandLine.getOptionValue( CLIManager.LOG_FILE ) );
|
||||
|
||||
configuration.setMavenEmbedderLogger( new MavenEmbedderFileLogger( logFile ) );
|
||||
}
|
||||
|
@ -259,7 +248,7 @@ private Configuration buildEmbedderConfiguration( MavenExecutionRequest request,
|
|||
{
|
||||
configuration.setLocalRepository( new File( localRepoProperty ) );
|
||||
}
|
||||
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue