mirror of https://github.com/apache/maven.git
o Decoupled POM tests from plugin mananger and repository system (these tests were originally written without merging of default configuration in mind)
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@771971 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
97d3c99dc8
commit
5ec5c90c89
|
@ -61,6 +61,12 @@ public abstract class AbstractMavenProjectTestCase
|
|||
return projectBuilder;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getCustomConfigurationName()
|
||||
{
|
||||
return AbstractMavenProjectTestCase.class.getName().replace( '.', '/' ) + ".xml";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Local repository
|
||||
// ----------------------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,81 @@
|
|||
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.
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutionException;
|
||||
import org.apache.maven.lifecycle.LifecycleExecutor;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.MojoExecution;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
/**
|
||||
* A stub implementation that assumes an empty lifecycle to bypass interaction with the plugin manager and to avoid
|
||||
* plugin artifact resolution from repositories.
|
||||
*
|
||||
* @author Benjamin Bentmann
|
||||
*/
|
||||
public class EmptyLifecycleExecutor
|
||||
implements LifecycleExecutor
|
||||
{
|
||||
|
||||
public List<MojoExecution> calculateLifecyclePlan( String lifecyclePhase, MavenSession session )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public void execute( MavenSession session )
|
||||
throws LifecycleExecutionException, MojoFailureException, MojoExecutionException
|
||||
{
|
||||
}
|
||||
|
||||
public Xpp3Dom getDefaultPluginConfiguration( String groupId, String artifactId, String version, String goal,
|
||||
MavenProject project, ArtifactRepository localRepository )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<String> getLifecyclePhases()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging )
|
||||
{
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
public Set<Plugin> populateDefaultConfigurationForPlugins( Set<Plugin> plugins, MavenProject project,
|
||||
ArtifactRepository localRepository )
|
||||
throws LifecycleExecutionException
|
||||
{
|
||||
return plugins;
|
||||
}
|
||||
|
||||
}
|
|
@ -1435,13 +1435,6 @@ public class PomConstructionTest
|
|||
PomTestWrapper pom = buildPom( "dependency-management-with-interpolation/sub" );
|
||||
}
|
||||
|
||||
public void testMaven()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "maven/sub" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
}
|
||||
|
||||
private void assertPathSuffixEquals( String expected, Object actual )
|
||||
{
|
||||
String a = actual.toString();
|
||||
|
@ -1454,40 +1447,41 @@ public class PomConstructionTest
|
|||
assertEquals( new File( value.toString() ).getPath(), value.toString() );
|
||||
}
|
||||
|
||||
private PomTestWrapper buildPom( String pomPath, Properties properties)
|
||||
throws Exception
|
||||
{
|
||||
File pomFile = new File( testDirectory , pomPath );
|
||||
if ( pomFile.isDirectory() )
|
||||
{
|
||||
pomFile = new File( pomFile, "pom.xml" );
|
||||
}
|
||||
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
|
||||
config.setLocalRepository(new DefaultArtifactRepository("default", "", new DefaultRepositoryLayout()));
|
||||
ProfileActivationContext pCtx = new ProfileActivationContext(null, true);
|
||||
|
||||
config.setExecutionProperties(properties);
|
||||
config.setGlobalProfileManager(new DefaultProfileManager(pCtx));
|
||||
return new PomTestWrapper( pomFile, mavenProjectBuilder.build( pomFile, config ) );
|
||||
}
|
||||
|
||||
private PomTestWrapper buildPom( String pomPath, String... profileIds )
|
||||
throws Exception
|
||||
{
|
||||
File pomFile = new File( testDirectory , pomPath );
|
||||
return buildPom( pomPath, null, profileIds );
|
||||
}
|
||||
|
||||
private PomTestWrapper buildPom( String pomPath, Properties executionProperties, String... profileIds )
|
||||
throws Exception
|
||||
{
|
||||
File pomFile = new File( testDirectory, pomPath );
|
||||
if ( pomFile.isDirectory() )
|
||||
{
|
||||
pomFile = new File( pomFile, "pom.xml" );
|
||||
}
|
||||
|
||||
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
|
||||
config.setLocalRepository(new DefaultArtifactRepository("default", "", new DefaultRepositoryLayout()));
|
||||
ProfileActivationContext pCtx = new ProfileActivationContext(null, true);
|
||||
|
||||
String localRepoUrl =
|
||||
System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" );
|
||||
localRepoUrl = "file://" + localRepoUrl;
|
||||
config.setLocalRepository( new DefaultArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout() ) );
|
||||
|
||||
ProfileActivationContext pCtx = new ProfileActivationContext( null, true );
|
||||
if ( profileIds != null )
|
||||
{
|
||||
pCtx.setExplicitlyActiveProfileIds( Arrays.asList( profileIds ) );
|
||||
}
|
||||
|
||||
config.setGlobalProfileManager(new DefaultProfileManager(pCtx));
|
||||
if ( executionProperties != null )
|
||||
{
|
||||
config.setExecutionProperties( executionProperties );
|
||||
}
|
||||
|
||||
config.setGlobalProfileManager( new DefaultProfileManager( pCtx ) );
|
||||
|
||||
return new PomTestWrapper( pomFile, mavenProjectBuilder.build( pomFile, config ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -93,9 +93,14 @@ public class PomConstructionWithSettingsTest
|
|||
}
|
||||
|
||||
ProjectBuilderConfiguration config = new DefaultProjectBuilderConfiguration();
|
||||
config.setLocalRepository(new DefaultArtifactRepository("default", "", new DefaultRepositoryLayout()));
|
||||
|
||||
String localRepoUrl =
|
||||
System.getProperty( "maven.repo.local", System.getProperty( "user.home" ) + "/.m2/repository" );
|
||||
localRepoUrl = "file://" + localRepoUrl;
|
||||
config.setLocalRepository( new DefaultArtifactRepository( "local", localRepoUrl, new DefaultRepositoryLayout() ) );
|
||||
|
||||
config.setGlobalProfileManager(profileManager);
|
||||
|
||||
return new PomTestWrapper( pomFile, mavenProjectBuilder.build( pomFile, config ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plexus>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.LifecycleExecutor</role>
|
||||
<implementation>org.apache.maven.project.EmptyLifecycleExecutor</implementation>
|
||||
</component>
|
||||
</components>
|
||||
</plexus>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plexus>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.LifecycleExecutor</role>
|
||||
<implementation>org.apache.maven.project.EmptyLifecycleExecutor</implementation>
|
||||
</component>
|
||||
</components>
|
||||
</plexus>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plexus>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.LifecycleExecutor</role>
|
||||
<implementation>org.apache.maven.project.EmptyLifecycleExecutor</implementation>
|
||||
</component>
|
||||
</components>
|
||||
</plexus>
|
Loading…
Reference in New Issue