mirror of https://github.com/apache/maven.git
o start of harness for validating the spec, i have my first error expressed in a test where plugin executions are
not joined properly. and the journey begins ... git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@727322 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
9f5976a871
commit
2b808a15d1
|
@ -387,7 +387,7 @@ public class DefaultMavenProjectBuilder
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
mavenProject = projectBuilder.buildFromLocalPath( projectDescriptor,
|
mavenProject = projectBuilder.buildFromLocalPath( projectDescriptor,
|
||||||
Arrays.asList( projectBuilder.getSuperModel() ),
|
null,
|
||||||
interpolatorProperties,
|
interpolatorProperties,
|
||||||
resolver,
|
resolver,
|
||||||
config );
|
config );
|
||||||
|
|
|
@ -35,7 +35,6 @@ import org.apache.maven.shared.model.InterpolatorProperty;
|
||||||
public interface ProjectBuilder
|
public interface ProjectBuilder
|
||||||
{
|
{
|
||||||
public PomClassicDomainModel buildModel( File pom,
|
public PomClassicDomainModel buildModel( File pom,
|
||||||
List<Model> mixins,
|
|
||||||
Collection<InterpolatorProperty> interpolatorProperties,
|
Collection<InterpolatorProperty> interpolatorProperties,
|
||||||
PomArtifactResolver resolver )
|
PomArtifactResolver resolver )
|
||||||
throws IOException;
|
throws IOException;
|
||||||
|
|
|
@ -73,6 +73,14 @@ public final class DefaultProjectBuilder
|
||||||
|
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
|
public PomClassicDomainModel buildModel( File pom,
|
||||||
|
Collection<InterpolatorProperty> interpolatorProperties,
|
||||||
|
PomArtifactResolver resolver )
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
return buildModel( pom, null, interpolatorProperties, resolver );
|
||||||
|
}
|
||||||
|
|
||||||
public PomClassicDomainModel buildModel( File pom,
|
public PomClassicDomainModel buildModel( File pom,
|
||||||
List<Model> mixins,
|
List<Model> mixins,
|
||||||
Collection<InterpolatorProperty> interpolatorProperties,
|
Collection<InterpolatorProperty> interpolatorProperties,
|
||||||
|
@ -92,6 +100,7 @@ public final class DefaultProjectBuilder
|
||||||
if ( mixins == null )
|
if ( mixins == null )
|
||||||
{
|
{
|
||||||
mixins = new ArrayList<Model>();
|
mixins = new ArrayList<Model>();
|
||||||
|
mixins.add( getSuperModel() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,83 @@
|
||||||
|
package org.apache.maven.project.builder;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.maven.MavenTools;
|
||||||
|
import org.apache.maven.artifact.Artifact;
|
||||||
|
import org.apache.maven.model.Model;
|
||||||
|
import org.apache.maven.model.Plugin;
|
||||||
|
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
|
||||||
|
import org.apache.maven.project.MavenProject;
|
||||||
|
import org.apache.maven.project.MavenProjectBuilder;
|
||||||
|
import org.apache.maven.project.ProjectBuilderConfiguration;
|
||||||
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
|
||||||
|
public class PomConstructionTest
|
||||||
|
extends PlexusTestCase
|
||||||
|
{
|
||||||
|
private static String BASE_POM_DIR = "src/test/resources-project-builder";
|
||||||
|
|
||||||
|
private ProjectBuilder projectBuilder;
|
||||||
|
|
||||||
|
private MavenTools mavenTools;
|
||||||
|
|
||||||
|
private File testDirectory;
|
||||||
|
|
||||||
|
protected void setUp()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
testDirectory = new File( getBasedir(), BASE_POM_DIR );
|
||||||
|
|
||||||
|
projectBuilder = lookup( ProjectBuilder.class );
|
||||||
|
|
||||||
|
mavenTools = lookup( MavenTools.class );
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNexusPoms()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
Map<String,File> artifacts = new HashMap<String,File>();
|
||||||
|
|
||||||
|
File nexusAggregator = new File( testDirectory, "nexus/pom.xml" );
|
||||||
|
File nexusParent = new File( testDirectory, "nexus/nexus-test-harness-parent/pom.xml" );
|
||||||
|
File nexusLauncher = new File( testDirectory, "nexus/nexus-test-harness-launcher/pom.xml" );
|
||||||
|
|
||||||
|
artifacts.put( "nexus-test-harness-parent", nexusParent );
|
||||||
|
artifacts.put( "nexus-test-harness-launcher" , nexusLauncher );
|
||||||
|
artifacts.put( "nexus-test-harness", nexusAggregator );
|
||||||
|
|
||||||
|
PomArtifactResolver resolver = new FileBasedPomArtifactResolver( artifacts );
|
||||||
|
|
||||||
|
PomClassicDomainModel model = projectBuilder.buildModel( nexusLauncher, null, resolver );
|
||||||
|
|
||||||
|
Model m = model.getModel();
|
||||||
|
|
||||||
|
Plugin plugin = (Plugin) m.getBuild().getPlugins().get( 0 );
|
||||||
|
|
||||||
|
List executions = plugin.getExecutions();
|
||||||
|
|
||||||
|
//assertEquals( 7, executions.size() );
|
||||||
|
}
|
||||||
|
|
||||||
|
class FileBasedPomArtifactResolver
|
||||||
|
implements PomArtifactResolver
|
||||||
|
{
|
||||||
|
private Map<String,File> artifacts = new HashMap<String,File>();
|
||||||
|
|
||||||
|
public FileBasedPomArtifactResolver( Map<String, File> artifacts )
|
||||||
|
{
|
||||||
|
this.artifacts = artifacts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void resolve( Artifact artifact )
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
System.out.println( artifact );
|
||||||
|
artifact.setFile( artifacts.get( artifact.getArtifactId() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue