mirror of https://github.com/apache/maven.git
Updated model processors.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@752990 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f510f203fa
commit
d1c0d51959
|
@ -59,11 +59,13 @@ import org.apache.maven.project.builder.PomInterpolatorTag;
|
|||
import org.apache.maven.project.builder.PomTransformer;
|
||||
import org.apache.maven.project.builder.ProjectUri;
|
||||
import org.apache.maven.project.builder.profile.ProfileContext;
|
||||
import org.apache.maven.project.processor.ProcessorContext;
|
||||
import org.apache.maven.project.validation.ModelValidationResult;
|
||||
import org.apache.maven.project.validation.ModelValidator;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.repository.VersionNotFoundException;
|
||||
import org.apache.maven.shared.model.DomainModel;
|
||||
import org.apache.maven.shared.model.ImportModel;
|
||||
import org.apache.maven.shared.model.InterpolatorProperty;
|
||||
import org.apache.maven.shared.model.ModelContainer;
|
||||
import org.apache.maven.shared.model.ModelEventListener;
|
||||
|
@ -477,6 +479,7 @@ public class DefaultMavenProjectBuilder
|
|||
{
|
||||
for ( String s : (List<String>) validationResult.getMessages() )
|
||||
{
|
||||
System.out.println(s);
|
||||
logger.debug( s );
|
||||
}
|
||||
throw new InvalidProjectModelException( projectId, "Failed to validate POM", pomFile, validationResult );
|
||||
|
@ -518,6 +521,7 @@ public class DefaultMavenProjectBuilder
|
|||
return buildModel( pom, interpolatorProperties, null, null, localRepository, remoteRepositories );
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private PomClassicDomainModel buildModel( File pom, Collection<InterpolatorProperty> interpolatorProperties, Collection<String> activeProfileIds, Collection<String> inactiveProfileIds,
|
||||
ArtifactRepository localRepository, List<ArtifactRepository> remoteRepositories )
|
||||
throws IOException
|
||||
|
@ -590,7 +594,9 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
ModelTransformerContext ctx = new ModelTransformerContext( PomTransformer.MODEL_CONTAINER_INFOS );
|
||||
|
||||
PomClassicDomainModel transformedDomainModel = ( (PomClassicDomainModel) ctx.transform( domainModels, transformer, transformer, Collections.EMPTY_LIST, properties, listeners ) );
|
||||
//PomClassicDomainModel transformedDomainModel = ProcessorContext.build( domainModels );
|
||||
|
||||
PomClassicDomainModel transformedDomainModel = ( (PomClassicDomainModel) ctx.transform( domainModels, transformer, transformer, new ArrayList<ImportModel>(), properties, listeners ) );
|
||||
// Lineage count is inclusive to add the POM read in itself.
|
||||
transformedDomainModel.setLineageCount( lineageCount + 1 );
|
||||
transformedDomainModel.setParentFile( parentFile );
|
||||
|
@ -759,7 +765,7 @@ public class DefaultMavenProjectBuilder
|
|||
transformed.add( new ModelProperty( mp.getUri().replace( ProjectUri.Profiles.Profile.xUri, ProjectUri.xUri ), mp.getResolvedValue() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
domainModels.add( new PomClassicDomainModel( transformed ) );
|
||||
}
|
||||
return domainModels;
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.apache.maven.project.processor;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public abstract class BaseProcessor
|
||||
public abstract class BaseProcessor implements Processor
|
||||
{
|
||||
|
||||
Object parent;
|
||||
|
|
|
@ -1,11 +1,18 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Extension;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginManagement;
|
||||
import org.apache.maven.model.Resource;
|
||||
|
||||
public class BuildProcessor
|
||||
|
@ -28,21 +35,45 @@ public class BuildProcessor
|
|||
t.setBuild( new Build() );
|
||||
}
|
||||
|
||||
PluginsProcessor pluginsProcessor = new PluginsProcessor();
|
||||
if(c.getBuild() == null && !( p == null || p.getBuild() == null))
|
||||
{
|
||||
copy(p.getBuild(), t.getBuild());
|
||||
copy(p.getBuild(), t.getBuild());
|
||||
pluginsProcessor.process( p.getBuild().getPlugins(), null, t.getBuild().getPlugins(), isChildMostSpecialized );
|
||||
inheritManagement(p.getBuild().getPluginManagement(), null, t.getBuild());
|
||||
}
|
||||
else if(c.getBuild() != null && !( p == null || p.getBuild() == null))
|
||||
{
|
||||
copy(c.getBuild(), t.getBuild());
|
||||
copy(p.getBuild(), t.getBuild());
|
||||
|
||||
pluginsProcessor.process( p.getBuild().getPlugins(), c.getBuild().getPlugins(), t.getBuild().getPlugins(), isChildMostSpecialized );
|
||||
inheritManagement(p.getBuild().getPluginManagement(), c.getBuild().getPluginManagement(), t.getBuild());
|
||||
}
|
||||
else if(c.getBuild() != null )
|
||||
{
|
||||
copy(c.getBuild(), t.getBuild());
|
||||
pluginsProcessor.process( null, c.getBuild().getPlugins(), t.getBuild().getPlugins(), isChildMostSpecialized );
|
||||
inheritManagement(null, c.getBuild().getPluginManagement(), t.getBuild());
|
||||
}
|
||||
}
|
||||
|
||||
private static void inheritManagement(PluginManagement parent, PluginManagement child, Build target)
|
||||
{
|
||||
PluginsProcessor proc = new PluginsProcessor();
|
||||
List<Plugin> p = (parent == null) ? new ArrayList<Plugin>() : parent.getPlugins();
|
||||
List<Plugin> c = (child == null) ? new ArrayList<Plugin>() : child.getPlugins();
|
||||
|
||||
if(c !=null || p!= null)
|
||||
{
|
||||
if(target.getPluginManagement() == null)
|
||||
{
|
||||
target.setPluginManagement( new PluginManagement() );
|
||||
}
|
||||
}
|
||||
proc.process( p, c, target.getPluginManagement().getPlugins(), false );
|
||||
}
|
||||
|
||||
private static void copy(Build source, Build target)
|
||||
{
|
||||
if(target.getFinalName() == null)
|
||||
|
@ -62,7 +93,7 @@ public class BuildProcessor
|
|||
|
||||
if(target.getOutputDirectory() == null)
|
||||
{
|
||||
target.setOutputDirectory( target.getOutputDirectory() );
|
||||
target.setOutputDirectory( source.getOutputDirectory() );
|
||||
}
|
||||
|
||||
if(target.getScriptSourceDirectory() == null)
|
||||
|
@ -82,10 +113,24 @@ public class BuildProcessor
|
|||
|
||||
if(target.getTestSourceDirectory() == null)
|
||||
{
|
||||
target.setTestSourceDirectory( source.getTestSourceDirectory() );
|
||||
}
|
||||
target.setTestSourceDirectory( source.getTestSourceDirectory() );
|
||||
}
|
||||
|
||||
target.getFilters().addAll( new ArrayList<String>(source.getFilters()) );
|
||||
|
||||
List<String> filters = new ArrayList<String>(target.getFilters());
|
||||
for(String filter : source.getFilters())
|
||||
{
|
||||
if(!filters.contains( filter ))
|
||||
{
|
||||
filters.add( filter );
|
||||
}
|
||||
}
|
||||
|
||||
// SortedSet<String> s = new TreeSet<String>( new ArrayList<String>( target.getFilters() ) );
|
||||
// s.addAll( source.getFilters() );
|
||||
// List<String> l = Arrays.asList(s.toArray( new String[s.size()]) );
|
||||
|
||||
target.setFilters( filters );
|
||||
|
||||
for(Extension extension : source.getExtensions())
|
||||
{
|
||||
|
@ -124,6 +169,6 @@ public class BuildProcessor
|
|||
r.setIncludes( new ArrayList<String>(resource.getIncludes()) );
|
||||
target.getTestResources().add( r );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
|
@ -10,8 +11,8 @@ import org.apache.maven.shared.model.ModelContainerAction;
|
|||
|
||||
public class DependenciesProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
|
||||
{
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
@ -66,9 +67,50 @@ public class DependenciesProcessor
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Cleanup duplicates
|
||||
// List<Dependency> remove = new ArrayList<Dependency>();
|
||||
List<Dependency> ordered = new ArrayList<Dependency>(dependencies);
|
||||
Collections.reverse( ordered );
|
||||
for(Dependency dependency : ordered)
|
||||
{
|
||||
for(int i = ordered.indexOf( dependency ) + 1; i < ordered.size(); i++)
|
||||
{
|
||||
Dependency d1 = ordered.get( i );
|
||||
if(match1(d1, dependency))
|
||||
{
|
||||
dependencies.remove( dependency );
|
||||
}
|
||||
}
|
||||
}
|
||||
// dependencies.removeAll( remove );
|
||||
}
|
||||
|
||||
private static boolean match( Dependency d1, Dependency d2 )
|
||||
private static boolean contains(Dependency dependency, List<Dependency> dependencies)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean match1(Dependency d1, Dependency d2)
|
||||
{
|
||||
return getId( d1 ).equals( getId( d2 ) );
|
||||
}
|
||||
|
||||
/*
|
||||
private boolean match(Dependency d1, Dependency d2)
|
||||
{
|
||||
if(isManagement)
|
||||
{
|
||||
return d1.getGroupId().equals( d2.getGroupId() ) && d1.getArtifactId().equals( d2.getArtifactId() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return d1.getGroupId().equals( d2.getGroupId() ) && d1.getArtifactId().equals( d2.getArtifactId() ) && d2.getVersion().equals(d1.getVersion());
|
||||
}
|
||||
}
|
||||
*/
|
||||
private boolean match( Dependency d1, Dependency d2 )
|
||||
{
|
||||
// TODO: Version ranges ?
|
||||
if ( getId( d1 ).equals( getId( d2 ) ) )
|
||||
|
@ -79,14 +121,17 @@ public class DependenciesProcessor
|
|||
return false;
|
||||
}
|
||||
|
||||
private static String getId( Dependency d )
|
||||
private String getId( Dependency d )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( d.getGroupId() ).append( ":" ).append( d.getArtifactId() ).append( ":" ).append(
|
||||
d.getType() == null ? "jar"
|
||||
: "" ).append(
|
||||
":" ).append(
|
||||
d.getClassifier() );
|
||||
|
||||
sb.append( d.getGroupId() ).append( ":" ).append( d.getArtifactId() );
|
||||
sb.append( ":" ).append(
|
||||
d.getType() == null ? "jar"
|
||||
: "" ).append(
|
||||
":" ).append(
|
||||
d.getClassifier() );
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Exclusion;
|
||||
|
||||
public class DependencyManagementProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
List<Dependency> depManagement = (List<Dependency> ) child;
|
||||
List<Dependency> targetDependencies = (List<Dependency>) target;
|
||||
|
||||
for(Dependency depMng : depManagement)
|
||||
{
|
||||
for(Dependency targetDep : targetDependencies)
|
||||
{
|
||||
if(match(depMng, targetDep))
|
||||
{
|
||||
copy(depMng, targetDep );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy( Dependency dependency, Dependency targetDependency )
|
||||
{
|
||||
if ( targetDependency.getArtifactId() == null )
|
||||
{
|
||||
targetDependency.setArtifactId( dependency.getArtifactId() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getClassifier() == null )
|
||||
{
|
||||
targetDependency.setClassifier( dependency.getClassifier() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getGroupId() == null )
|
||||
{
|
||||
targetDependency.setGroupId( dependency.getGroupId() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getScope() == null )
|
||||
{
|
||||
targetDependency.setScope( dependency.getScope() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getSystemPath() == null )
|
||||
{
|
||||
targetDependency.setSystemPath( dependency.getSystemPath() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getType() == null )
|
||||
{
|
||||
targetDependency.setType( dependency.getType() );
|
||||
}
|
||||
|
||||
if ( targetDependency.getVersion() == null )
|
||||
{
|
||||
targetDependency.setVersion( dependency.getVersion() );
|
||||
}
|
||||
|
||||
if ( !dependency.getExclusions().isEmpty() )
|
||||
{
|
||||
List<Exclusion> targetExclusions = targetDependency.getExclusions();
|
||||
for ( Exclusion e : dependency.getExclusions() )
|
||||
{
|
||||
if ( !containsExclusion( e, targetExclusions ) )
|
||||
{
|
||||
Exclusion e1 = new Exclusion();
|
||||
e1.setArtifactId( e.getArtifactId() );
|
||||
e1.setGroupId( e.getGroupId() );
|
||||
targetDependency.addExclusion( e1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean containsExclusion( Exclusion exclusion, List<Exclusion> exclusions )
|
||||
{
|
||||
if(exclusions == null || exclusions.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( Exclusion e : exclusions )
|
||||
{
|
||||
if ( e.getGroupId().equals( exclusion.getGroupId() )
|
||||
&& e.getArtifactId().equals( exclusion.getArtifactId() ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean match( Dependency d1, Dependency d2 )
|
||||
{
|
||||
return getId( d1 ).equals( getId( d2 ) );
|
||||
}
|
||||
|
||||
private String getId( Dependency d )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( d.getGroupId() ).append( ":" ).append( d.getArtifactId() );
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import org.apache.maven.model.Exclusion;
|
|||
public class DependencyProcessor
|
||||
extends BaseProcessor
|
||||
{
|
||||
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
@ -33,10 +34,11 @@ public class DependencyProcessor
|
|||
else
|
||||
// JOIN
|
||||
{
|
||||
Dependency targetDependency = new Dependency();
|
||||
copy( (Dependency) child, targetDependency );
|
||||
copy( (Dependency) parent, targetDependency );
|
||||
t.add( targetDependency );
|
||||
Dependency targetDependency = new Dependency();
|
||||
copy( (Dependency) child, targetDependency );
|
||||
copy( (Dependency) parent, targetDependency );
|
||||
t.add( targetDependency );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,7 +89,7 @@ public class DependencyProcessor
|
|||
Exclusion e1 = new Exclusion();
|
||||
e1.setArtifactId( e.getArtifactId() );
|
||||
e1.setGroupId( e.getGroupId() );
|
||||
targetExclusions.add( e1 );
|
||||
targetDependency.addExclusion( e1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,6 +97,11 @@ public class DependencyProcessor
|
|||
|
||||
private static boolean containsExclusion( Exclusion exclusion, List<Exclusion> exclusions )
|
||||
{
|
||||
if(exclusions == null || exclusions.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for ( Exclusion e : exclusions )
|
||||
{
|
||||
if ( e.getGroupId().equals( exclusion.getGroupId() )
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
public class DistributionManagementProcessor extends BaseProcessor
|
||||
{
|
||||
|
||||
}
|
|
@ -8,6 +8,7 @@ import org.apache.maven.model.Build;
|
|||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.DependencyManagement;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
|
||||
/*
|
||||
* hold original pom
|
||||
|
@ -59,6 +60,19 @@ public class ModelProcessor
|
|||
{
|
||||
t.setGroupId( c.getGroupId() );
|
||||
}
|
||||
|
||||
// ArtifactId
|
||||
if ( c.getArtifactId() == null )
|
||||
{
|
||||
if ( c.getParent() != null )
|
||||
{
|
||||
t.setArtifactId( c.getParent().getArtifactId() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
t.setArtifactId( c.getArtifactId() );
|
||||
}
|
||||
|
||||
t.setModelVersion( c.getModelVersion() );
|
||||
t.setPackaging( c.getPackaging() );
|
||||
|
@ -78,6 +92,7 @@ public class ModelProcessor
|
|||
t.setInceptionYear( p.getInceptionYear() );
|
||||
}
|
||||
|
||||
//Dependencies
|
||||
List<Dependency> deps = new ArrayList<Dependency>();
|
||||
DependenciesProcessor dependenciesProcessor = new DependenciesProcessor();
|
||||
dependenciesProcessor.process( (p != null) ? p.getDependencies() : null, c.getDependencies(), deps, isChildMostSpecialized );
|
||||
|
@ -87,6 +102,7 @@ public class ModelProcessor
|
|||
t.getDependencies().addAll( deps );
|
||||
}
|
||||
|
||||
//Dependency Management
|
||||
List<Dependency> mngDeps = new ArrayList<Dependency>();
|
||||
dependenciesProcessor.process( (p != null && p.getDependencyManagement() != null) ? p.getDependencyManagement().getDependencies(): null,
|
||||
(c.getDependencyManagement() != null) ? c.getDependencyManagement().getDependencies(): null, mngDeps, isChildMostSpecialized );
|
||||
|
@ -98,5 +114,8 @@ public class ModelProcessor
|
|||
}
|
||||
t.getDependencyManagement().getDependencies().addAll( mngDeps );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,9 +5,8 @@ import java.util.List;
|
|||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
|
||||
import org.codehaus.plexus.util.xml.Xpp3DomUtils;
|
||||
|
||||
public class PluginProcessor
|
||||
extends BaseProcessor
|
||||
|
@ -43,61 +42,120 @@ public class PluginProcessor
|
|||
}
|
||||
}
|
||||
|
||||
private static void copy(Plugin p1, Plugin p2)
|
||||
private static void copy(Plugin source, Plugin target)
|
||||
{
|
||||
if(p2.getArtifactId() == null)
|
||||
if(target.getArtifactId() == null)
|
||||
{
|
||||
p2.setArtifactId( p1.getArtifactId() );
|
||||
target.setArtifactId( source.getArtifactId() );
|
||||
}
|
||||
|
||||
if(p2.getGroupId() == null)
|
||||
target.setGroupId( source.getGroupId() );
|
||||
|
||||
if(target.getInherited() == null)
|
||||
{
|
||||
p2.setGroupId( p1.getGroupId() );
|
||||
target.setInherited( source.getInherited() );
|
||||
}
|
||||
|
||||
if(p2.getInherited() == null)
|
||||
if(target.getVersion() == null)
|
||||
{
|
||||
p2.setInherited( p1.getInherited() );
|
||||
target.setVersion( source.getVersion() );
|
||||
}
|
||||
|
||||
if(p2.getVersion() == null)
|
||||
{
|
||||
p2.setVersion( p1.getVersion() );
|
||||
}
|
||||
|
||||
if(p2.getDependencies().isEmpty())
|
||||
for( PluginExecution pe : source.getExecutions())
|
||||
{
|
||||
DependenciesProcessor proc = new DependenciesProcessor();
|
||||
proc.process( new ArrayList<Dependency>(), new ArrayList<Dependency>(p1.getDependencies()), p2.getDependencies(), false );
|
||||
PluginExecution idMatch = contains(pe, target.getExecutions());
|
||||
if(idMatch != null)//Join
|
||||
{
|
||||
copyPluginExecution(pe, idMatch);
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginExecution targetPe = new PluginExecution();
|
||||
copyPluginExecution(pe, targetPe);
|
||||
target.addExecution( targetPe );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DependenciesProcessor proc = new DependenciesProcessor();
|
||||
if(target.getDependencies().isEmpty())
|
||||
{
|
||||
|
||||
proc.process( new ArrayList<Dependency>(), new ArrayList<Dependency>(source.getDependencies()), target.getDependencies(), false );
|
||||
}
|
||||
else
|
||||
{
|
||||
DependenciesProcessor proc = new DependenciesProcessor();
|
||||
proc.process( new ArrayList<Dependency>(p1.getDependencies()), new ArrayList<Dependency>(), p2.getDependencies(), false );
|
||||
proc.process( new ArrayList<Dependency>(source.getDependencies()), new ArrayList<Dependency>(), target.getDependencies(), false );
|
||||
}
|
||||
|
||||
if(p1.getConfiguration() != null)
|
||||
if(source.getConfiguration() != null)
|
||||
{
|
||||
//TODO: Not copying
|
||||
if(p2.getConfiguration() != null)
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
p2.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) p1.getConfiguration(), (Xpp3Dom) p2.getConfiguration() ));
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
p2.setConfiguration( p1.getConfiguration() );
|
||||
target.setConfiguration( source.getConfiguration() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// p2.setConfiguration( configuration ) merge nodes
|
||||
//Goals
|
||||
//Executions
|
||||
p2.setExtensions(p1.isExtensions());
|
||||
|
||||
|
||||
|
||||
|
||||
target.setExtensions(source.isExtensions());
|
||||
|
||||
}
|
||||
|
||||
private static PluginExecution contains(PluginExecution pe, List<PluginExecution> executions)
|
||||
{
|
||||
String executionId = (pe.getId() != null) ? pe.getId() : "";
|
||||
for(PluginExecution e : executions)
|
||||
{
|
||||
String id = (e.getId() != null) ? e.getId() : "";
|
||||
if(executionId.equals( id ))
|
||||
{
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void copyPluginExecution(PluginExecution source, PluginExecution target)
|
||||
{
|
||||
|
||||
target.setId( source.getId() );
|
||||
|
||||
if(target.getInherited() == null)
|
||||
{
|
||||
target.setInherited( source.getInherited() );
|
||||
}
|
||||
|
||||
if(target.getPhase() == null)
|
||||
{
|
||||
target.setPhase( source.getPhase() );
|
||||
}
|
||||
|
||||
List<String> goals = new ArrayList<String>(target.getGoals());
|
||||
for(String goal : source.getGoals())
|
||||
{
|
||||
if(!goals.contains( goal ))
|
||||
{
|
||||
goals.add( goal );
|
||||
}
|
||||
|
||||
}
|
||||
target.setGoals( goals );
|
||||
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setConfiguration( source.getConfiguration() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,228 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
/**
|
||||
* Used for applying plugin management to the pom (not for inheritance).
|
||||
*
|
||||
*/
|
||||
public class PluginsManagementProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
List<Plugin> pluginManagement = (List<Plugin> ) child;
|
||||
List<Plugin> targetPlugin = (List<Plugin>) target;
|
||||
|
||||
for(Plugin depMng : pluginManagement)
|
||||
{
|
||||
for(Plugin targetDep : targetPlugin)
|
||||
{
|
||||
if(match(depMng, targetDep))
|
||||
{
|
||||
copy(depMng, targetDep );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean match( Plugin d1, Plugin d2 )
|
||||
{
|
||||
return getId( d1 ).equals( getId( d2 ) ) ;
|
||||
}
|
||||
|
||||
private static String getId( Plugin d )
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( d.getGroupId() ).append( ":" ).append( d.getArtifactId() );
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static void copy(Plugin source, Plugin target)
|
||||
{
|
||||
if(target.getArtifactId() == null)
|
||||
{
|
||||
target.setArtifactId( source.getArtifactId() );
|
||||
}
|
||||
|
||||
target.setGroupId( source.getGroupId() );
|
||||
|
||||
if(target.getInherited() == null)
|
||||
{
|
||||
target.setInherited( source.getInherited() );
|
||||
}
|
||||
|
||||
if(target.getVersion() == null)
|
||||
{
|
||||
target.setVersion( source.getVersion() );
|
||||
}
|
||||
|
||||
|
||||
for( PluginExecution pe : source.getExecutions())
|
||||
{
|
||||
PluginExecution idMatch = contains(pe, target.getExecutions());
|
||||
if(idMatch != null)//Join
|
||||
{
|
||||
copyPluginExecution(pe, idMatch);
|
||||
}
|
||||
else
|
||||
{
|
||||
PluginExecution targetPe = new PluginExecution();
|
||||
copyPluginExecution(pe, targetPe);
|
||||
target.addExecution( targetPe );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
DependenciesProcessor proc = new DependenciesProcessor();
|
||||
if(target.getDependencies().isEmpty())
|
||||
{
|
||||
|
||||
proc.process( new ArrayList<Dependency>(), new ArrayList<Dependency>(source.getDependencies()), target.getDependencies(), false );
|
||||
}
|
||||
else
|
||||
{
|
||||
proc.process( new ArrayList<Dependency>(source.getDependencies()), new ArrayList<Dependency>(), target.getDependencies(), false );
|
||||
}
|
||||
|
||||
if(source.getConfiguration() != null)
|
||||
{
|
||||
//TODO: Not copying
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setConfiguration( source.getConfiguration() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// p2.setConfiguration( configuration ) merge nodes
|
||||
//Goals
|
||||
target.setExtensions(source.isExtensions());
|
||||
|
||||
}
|
||||
|
||||
private static PluginExecution contains(PluginExecution pe, List<PluginExecution> executions)
|
||||
{
|
||||
String executionId = (pe.getId() != null) ? pe.getId() : "";
|
||||
for(PluginExecution e : executions)
|
||||
{
|
||||
String id = (e.getId() != null) ? e.getId() : "";
|
||||
if(executionId.equals( id ))
|
||||
{
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static void copyPluginExecution(PluginExecution source, PluginExecution target)
|
||||
{
|
||||
if(target.getId() != null)
|
||||
{
|
||||
target.setId( source.getId() );
|
||||
}
|
||||
|
||||
if(target.getInherited() == null)
|
||||
{
|
||||
source.setInherited( target.getInherited() );
|
||||
}
|
||||
|
||||
if(target.getPhase() != null)
|
||||
{
|
||||
source.setPhase( target.getPhase() );
|
||||
}
|
||||
|
||||
List<String> goals = new ArrayList<String>(target.getGoals());
|
||||
for(String goal : source.getGoals())
|
||||
{
|
||||
if(!goals.contains( goal ))
|
||||
{
|
||||
goals.add( goal );
|
||||
}
|
||||
|
||||
}
|
||||
target.setGoals( goals );
|
||||
if(target.getConfiguration() != null)
|
||||
{
|
||||
target.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) source.getConfiguration(), (Xpp3Dom) target.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setConfiguration( source.getConfiguration() );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private static void copy(Plugin p1, Plugin p2)
|
||||
{
|
||||
if(p2.getArtifactId() == null)
|
||||
{
|
||||
p2.setArtifactId( p1.getArtifactId() );
|
||||
}
|
||||
|
||||
if(p2.getGroupId() == null)
|
||||
{
|
||||
p2.setGroupId( p1.getGroupId() );
|
||||
}
|
||||
|
||||
if(p2.getInherited() == null)
|
||||
{
|
||||
p2.setInherited( p1.getInherited() );
|
||||
}
|
||||
|
||||
if(p2.getVersion() == null)
|
||||
{
|
||||
p2.setVersion( p1.getVersion() );
|
||||
}
|
||||
|
||||
for( PluginExecution pe : p1.getExecutions())
|
||||
{
|
||||
PluginExecution p = new PluginExecution();
|
||||
p.setId( pe.getId() );
|
||||
p.setInherited( pe.getInherited() );
|
||||
p.setPhase( pe.getPhase() );
|
||||
p.setGoals( new ArrayList<String>(pe.getGoals()) );
|
||||
p2.addExecution( p );
|
||||
}
|
||||
|
||||
// if(p2.getDependencies().isEmpty())
|
||||
// {
|
||||
DependenciesProcessor proc = new DependenciesProcessor();
|
||||
proc.process( new ArrayList<Dependency>(), new ArrayList<Dependency>(p1.getDependencies()), p2.getDependencies(), false );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// DependenciesProcessor proc = new DependenciesProcessor();
|
||||
// proc.process( new ArrayList<Dependency>(p1.getDependencies()), new ArrayList<Dependency>(), p2.getDependencies(), false );
|
||||
// }
|
||||
|
||||
if(p1.getConfiguration() != null)
|
||||
{
|
||||
//TODO: Not copying
|
||||
if(p2.getConfiguration() != null)
|
||||
{
|
||||
p2.setConfiguration( Xpp3Dom.mergeXpp3Dom( (Xpp3Dom) p1.getConfiguration(), (Xpp3Dom) p2.getConfiguration() ));
|
||||
}
|
||||
else
|
||||
{
|
||||
p2.setConfiguration( p1.getConfiguration() );
|
||||
}
|
||||
}
|
||||
|
||||
// p2.setConfiguration( configuration ) merge nodes
|
||||
//Goals
|
||||
p2.setExtensions(p1.isExtensions());
|
||||
}
|
||||
*/
|
||||
}
|
|
@ -20,10 +20,12 @@ public class PluginsProcessor
|
|||
{
|
||||
p = (List<Plugin>) parent;
|
||||
}
|
||||
Model t = (Model) target;
|
||||
List<Plugin> plugins = t.getBuild().getPlugins();
|
||||
|
||||
// Model t = (Model) target;
|
||||
List<Plugin> plugins = (List<Plugin>) target;
|
||||
|
||||
PluginProcessor processor = new PluginProcessor();
|
||||
|
||||
if ( ( p == null || p.isEmpty() ) && !c.isEmpty() )
|
||||
{
|
||||
for ( Plugin plugin : c )
|
||||
|
@ -64,18 +66,25 @@ public class PluginsProcessor
|
|||
processor.process( d2, null, plugins, isChildMostSpecialized );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static boolean match( Plugin d1, Plugin d2 )
|
||||
{
|
||||
return getId( d1 ).equals( getId( d2 ));
|
||||
/*
|
||||
if ( getId( d1 ).equals( getId( d2 ) ) )
|
||||
{
|
||||
if(d1.getVersion() == null || d2.getVersion() == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ( d1.getVersion() == null ? "" : d1.getVersion() ).equals( d2.getVersion() == null ? ""
|
||||
: d2.getVersion() );
|
||||
}
|
||||
return false;
|
||||
*/
|
||||
}
|
||||
|
||||
private static String getId( Plugin d )
|
||||
|
|
|
@ -0,0 +1,340 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Writer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginManagement;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
|
||||
import org.apache.maven.project.builder.PomClassicDomainModel;
|
||||
import org.apache.maven.project.builder.PomInterpolatorTag;
|
||||
import org.apache.maven.project.builder.ProjectUri;
|
||||
import org.apache.maven.shared.model.DomainModel;
|
||||
import org.apache.maven.shared.model.InterpolatorProperty;
|
||||
import org.apache.maven.shared.model.ModelProperty;
|
||||
import org.apache.maven.shared.model.ModelTransformerContext;
|
||||
import org.codehaus.plexus.util.WriterFactory;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
public class ProcessorContext
|
||||
{
|
||||
public static PomClassicDomainModel build( List<DomainModel> domainModels )
|
||||
throws IOException
|
||||
{
|
||||
List<Processor> processors =
|
||||
Arrays.asList( (Processor) new BuildProcessor( new ArrayList<Processor>() ),
|
||||
(Processor) new ModuleProcessor(), new PropertiesProcessor(), new ParentProcessor(),
|
||||
new OrganizationProcessor(), new MailingListProcessor(), new IssueManagementProcessor(),
|
||||
new CiManagementProcessor(), new ReportingProcessor(), new RepositoriesProcessor());
|
||||
|
||||
ModelProcessor modelProcessor = new ModelProcessor( processors );
|
||||
|
||||
List<Model> models = new ArrayList<Model>();
|
||||
|
||||
PomClassicDomainModel child = null;
|
||||
for ( DomainModel domainModel : domainModels )
|
||||
{
|
||||
|
||||
//TODO: Getting some null profiles - work around to skip for now
|
||||
boolean artifactId = false;
|
||||
for(ModelProperty mp : domainModel.getModelProperties())
|
||||
{
|
||||
if(mp.getUri().equals(ProjectUri.artifactId))
|
||||
{
|
||||
artifactId = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(!artifactId)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//TODO:END
|
||||
|
||||
if(domainModel.isMostSpecialized())
|
||||
{
|
||||
child = (PomClassicDomainModel) domainModel;
|
||||
}
|
||||
|
||||
InputStream is = ( (PomClassicDomainModel) domainModel ).getInputStream();
|
||||
MavenXpp3Reader reader = new MavenXpp3Reader();
|
||||
try
|
||||
{
|
||||
models.add( reader.read( is ) );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
throw new IOException( e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
Collections.reverse( models );
|
||||
|
||||
int length = models.size();
|
||||
Model target = new Model();
|
||||
if(length == 1)
|
||||
{
|
||||
modelProcessor.process( null, models.get( 0 ), target, true );
|
||||
}
|
||||
else if( length == 2)
|
||||
{
|
||||
modelProcessor.process( models.get( 0 ), models.get( 1 ), target, true );
|
||||
}
|
||||
|
||||
for ( int i = 1; i < length - 1; i++ )
|
||||
{
|
||||
if ( i < length - 2 )
|
||||
{
|
||||
modelProcessor.process( models.get( i ), models.get( i + 1 ), target, false );
|
||||
}
|
||||
else
|
||||
{
|
||||
modelProcessor.process( models.get( i ), models.get( i + 1 ), target, true );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Dependency Management
|
||||
DependencyManagementProcessor depProc = new DependencyManagementProcessor();
|
||||
if ( target.getDependencyManagement() != null )
|
||||
{
|
||||
depProc.process( null, new ArrayList<Dependency>( target.getDependencyManagement().getDependencies() ),
|
||||
target.getDependencies(), true );
|
||||
}
|
||||
|
||||
// Plugin Management
|
||||
PluginsManagementProcessor procMng = new PluginsManagementProcessor();
|
||||
if ( target.getBuild() != null && target.getBuild().getPluginManagement() != null)
|
||||
{
|
||||
procMng.process( null, new ArrayList<Plugin>( target.getBuild().getPluginManagement().getPlugins() ),
|
||||
target.getBuild().getPlugins(), true );
|
||||
}
|
||||
|
||||
PomClassicDomainModel model = convertToDomainModel( target, false );
|
||||
interpolateModelProperties(model.getModelProperties(), new ArrayList(), child);
|
||||
return new PomClassicDomainModel(model.getModelProperties());
|
||||
}
|
||||
|
||||
private static PomClassicDomainModel convertToDomainModel( Model model, boolean isMostSpecialized )
|
||||
throws IOException
|
||||
{
|
||||
if ( model == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "model: null" );
|
||||
}
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
Writer out = null;
|
||||
MavenXpp3Writer writer = new MavenXpp3Writer();
|
||||
try
|
||||
{
|
||||
out = WriterFactory.newXmlWriter( baos );
|
||||
writer.write( out, model );
|
||||
}
|
||||
finally
|
||||
{
|
||||
if ( out != null )
|
||||
{
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
return new PomClassicDomainModel( new ByteArrayInputStream( baos.toByteArray() ), isMostSpecialized );
|
||||
}
|
||||
|
||||
private static final Map<String, String> aliases = new HashMap<String, String>();
|
||||
|
||||
private static void addProjectAlias( String element, boolean leaf )
|
||||
{
|
||||
String suffix = leaf ? "\\}" : "\\.";
|
||||
aliases.put( "\\$\\{project\\." + element + suffix, "\\$\\{" + element + suffix );
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
aliases.put( "\\$\\{project\\.", "\\$\\{pom\\." );
|
||||
addProjectAlias( "modelVersion", true );
|
||||
addProjectAlias( "groupId", true );
|
||||
addProjectAlias( "artifactId", true );
|
||||
addProjectAlias( "version", true );
|
||||
addProjectAlias( "packaging", true );
|
||||
addProjectAlias( "name", true );
|
||||
addProjectAlias( "description", true );
|
||||
addProjectAlias( "inceptionYear", true );
|
||||
addProjectAlias( "url", true );
|
||||
addProjectAlias( "parent", false );
|
||||
addProjectAlias( "prerequisites", false );
|
||||
addProjectAlias( "organization", false );
|
||||
addProjectAlias( "build", false );
|
||||
addProjectAlias( "reporting", false );
|
||||
addProjectAlias( "scm", false );
|
||||
addProjectAlias( "distributionManagement", false );
|
||||
addProjectAlias( "issueManagement", false );
|
||||
addProjectAlias( "ciManagement", false );
|
||||
}
|
||||
|
||||
public static void interpolateModelProperties( List<ModelProperty> modelProperties,
|
||||
List<InterpolatorProperty> interpolatorProperties, PomClassicDomainModel dm )
|
||||
throws IOException
|
||||
{
|
||||
// PomClassicDomainModel dm = (PomClassicDomainModel) domainModel;
|
||||
|
||||
if ( !containsProjectVersion( interpolatorProperties ) )
|
||||
{
|
||||
aliases.put( "\\$\\{project.version\\}", "\\$\\{version\\}" );
|
||||
}
|
||||
// System.out.println(aliases);
|
||||
List<ModelProperty> firstPassModelProperties = new ArrayList<ModelProperty>();
|
||||
List<ModelProperty> secondPassModelProperties = new ArrayList<ModelProperty>();
|
||||
|
||||
ModelProperty buildProperty = new ModelProperty( ProjectUri.Build.xUri, null );
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getValue() != null && !mp.getUri().contains( "#property" ) && !mp.getUri().contains( "#collection" ) )
|
||||
{
|
||||
if ( ( !buildProperty.isParentOf( mp ) && !mp.getUri().equals( ProjectUri.Reporting.outputDirectory ) || mp.getUri().equals(
|
||||
ProjectUri.Build.finalName ) ) )
|
||||
{
|
||||
firstPassModelProperties.add( mp );
|
||||
}
|
||||
else
|
||||
{
|
||||
secondPassModelProperties.add( mp );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<InterpolatorProperty> standardInterpolatorProperties = new ArrayList<InterpolatorProperty>();
|
||||
|
||||
if ( dm.isPomInBuild() )
|
||||
{
|
||||
String basedir = dm.getProjectDirectory().getAbsolutePath();
|
||||
standardInterpolatorProperties.add( new InterpolatorProperty( "${project.basedir}", basedir,
|
||||
PomInterpolatorTag.PROJECT_PROPERTIES.name() ) );
|
||||
standardInterpolatorProperties.add( new InterpolatorProperty( "${basedir}", basedir,
|
||||
PomInterpolatorTag.PROJECT_PROPERTIES.name() ) );
|
||||
standardInterpolatorProperties.add( new InterpolatorProperty( "${pom.basedir}", basedir,
|
||||
PomInterpolatorTag.PROJECT_PROPERTIES.name() ) );
|
||||
}
|
||||
|
||||
for ( ModelProperty mp : modelProperties )
|
||||
{
|
||||
if ( mp.getUri().startsWith( ProjectUri.properties ) && mp.getValue() != null )
|
||||
{
|
||||
String uri = mp.getUri();
|
||||
standardInterpolatorProperties.add( new InterpolatorProperty(
|
||||
"${"
|
||||
+ uri.substring(
|
||||
uri.lastIndexOf( "/" ) + 1,
|
||||
uri.length() ) + "}",
|
||||
mp.getValue(),
|
||||
PomInterpolatorTag.PROJECT_PROPERTIES.name() ) );
|
||||
}
|
||||
}
|
||||
|
||||
// FIRST PASS - Withhold using build directories as interpolator properties
|
||||
List<InterpolatorProperty> ips1 = new ArrayList<InterpolatorProperty>( interpolatorProperties );
|
||||
ips1.addAll( standardInterpolatorProperties );
|
||||
ips1.addAll( ModelTransformerContext.createInterpolatorProperties(
|
||||
firstPassModelProperties,
|
||||
ProjectUri.baseUri,
|
||||
aliases,
|
||||
PomInterpolatorTag.PROJECT_PROPERTIES.name(),
|
||||
false, false ) );
|
||||
Collections.sort( ips1, new Comparator<InterpolatorProperty>()
|
||||
{
|
||||
public int compare( InterpolatorProperty o, InterpolatorProperty o1 )
|
||||
{
|
||||
if ( o.getTag() == null || o1.getTag() == null )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return PomInterpolatorTag.valueOf( o.getTag() ).compareTo( PomInterpolatorTag.valueOf( o1.getTag() ) );
|
||||
}
|
||||
} );
|
||||
|
||||
ModelTransformerContext.interpolateModelProperties( modelProperties, ips1 );
|
||||
|
||||
// SECOND PASS - Set absolute paths on build directories
|
||||
|
||||
if ( dm.isPomInBuild() )
|
||||
{
|
||||
String basedir = dm.getProjectDirectory().getAbsolutePath();
|
||||
Map<ModelProperty, ModelProperty> buildDirectories = new HashMap<ModelProperty, ModelProperty>();
|
||||
for ( ModelProperty mp : secondPassModelProperties )
|
||||
{
|
||||
if ( mp.getUri().startsWith( ProjectUri.Build.xUri )
|
||||
|| mp.getUri().equals( ProjectUri.Reporting.outputDirectory ) )
|
||||
{
|
||||
File file = new File( mp.getResolvedValue() );
|
||||
if ( !file.isAbsolute() && !mp.getResolvedValue().startsWith( "${project.build." )
|
||||
&& !mp.getResolvedValue().equals( "${project.basedir}" ) )
|
||||
{
|
||||
buildDirectories.put( mp,
|
||||
new ModelProperty( mp.getUri(),
|
||||
new File( basedir, file.getPath() ).getAbsolutePath() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
for ( Map.Entry<ModelProperty, ModelProperty> e : buildDirectories.entrySet() )
|
||||
{
|
||||
secondPassModelProperties.remove( e.getKey() );
|
||||
secondPassModelProperties.add( e.getValue() );
|
||||
}
|
||||
}
|
||||
|
||||
// THIRD PASS - Use build directories as interpolator properties
|
||||
List<InterpolatorProperty> ips2 = new ArrayList<InterpolatorProperty>( interpolatorProperties );
|
||||
ips2.addAll( standardInterpolatorProperties );
|
||||
ips2.addAll( ModelTransformerContext.createInterpolatorProperties(
|
||||
secondPassModelProperties,
|
||||
ProjectUri.baseUri,
|
||||
aliases,
|
||||
PomInterpolatorTag.PROJECT_PROPERTIES.name(),
|
||||
false, false ) );
|
||||
ips2.addAll( interpolatorProperties );
|
||||
Collections.sort( ips2, new Comparator<InterpolatorProperty>()
|
||||
{
|
||||
public int compare( InterpolatorProperty o, InterpolatorProperty o1 )
|
||||
{
|
||||
if ( o.getTag() == null || o1.getTag() == null )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return PomInterpolatorTag.valueOf( o.getTag() ).compareTo( PomInterpolatorTag.valueOf( o1.getTag() ) );
|
||||
}
|
||||
} );
|
||||
|
||||
ModelTransformerContext.interpolateModelProperties( modelProperties, ips2 );
|
||||
}
|
||||
|
||||
private static boolean containsProjectVersion( List<InterpolatorProperty> interpolatorProperties )
|
||||
{
|
||||
InterpolatorProperty versionInterpolatorProperty =
|
||||
new ModelProperty( ProjectUri.version, "" ).asInterpolatorProperty( ProjectUri.baseUri );
|
||||
for ( InterpolatorProperty ip : interpolatorProperties )
|
||||
{
|
||||
if ( ip.equals( versionInterpolatorProperty ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
import org.apache.maven.model.ReportSet;
|
||||
import org.apache.maven.model.Reporting;
|
||||
|
||||
public class ReportingProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
Model t = (Model) target, c = (Model) child, p = (Model) parent;
|
||||
if(c.getReporting() != null)
|
||||
{
|
||||
if(t.getReporting() == null)
|
||||
{
|
||||
t.setReporting( new Reporting() );
|
||||
}
|
||||
|
||||
copy(c.getReporting(), t.getReporting());
|
||||
}
|
||||
|
||||
if(p != null && p.getReporting() != null)
|
||||
{
|
||||
if(t.getReporting() == null)
|
||||
{
|
||||
t.setReporting( new Reporting() );
|
||||
}
|
||||
|
||||
copy(p.getReporting(), t.getReporting());
|
||||
}
|
||||
}
|
||||
|
||||
private static void copy(Reporting source, Reporting target)
|
||||
{
|
||||
if(target.getOutputDirectory() == null)
|
||||
{
|
||||
target.setOutputDirectory( source.getOutputDirectory() );
|
||||
target.setExcludeDefaults( source.isExcludeDefaults() );
|
||||
|
||||
for(ReportPlugin plugin : source.getPlugins())
|
||||
{
|
||||
target.addPlugin( copyPlugin(plugin ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static ReportPlugin copyPlugin(ReportPlugin plugin)
|
||||
{
|
||||
ReportPlugin rp = new ReportPlugin();
|
||||
rp.setArtifactId( plugin.getArtifactId() );
|
||||
rp.setGroupId( plugin.getGroupId() );
|
||||
rp.setInherited( plugin.getInherited() );
|
||||
rp.setVersion( plugin.getVersion() );
|
||||
rp.setConfiguration( plugin.getConfiguration() );
|
||||
|
||||
for(ReportSet rs : plugin.getReportSets())
|
||||
{
|
||||
ReportSet r = new ReportSet();
|
||||
r.setId( rs.getId() );
|
||||
r.setInherited( rs.getInherited() );
|
||||
r.setReports( new ArrayList<String>(rs.getReports()) );
|
||||
r.setConfiguration( rs.getConfiguration() );
|
||||
rp.addReportSet( r );
|
||||
}
|
||||
return rp;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.model.RepositoryPolicy;
|
||||
|
||||
public class RepositoriesProcessor extends BaseProcessor
|
||||
{
|
||||
public void process( Object parent, Object child, Object target, boolean isChildMostSpecialized )
|
||||
{
|
||||
super.process( parent, child, target, isChildMostSpecialized );
|
||||
|
||||
Model t = (Model) target, c = (Model) child, p = (Model) parent;
|
||||
copy( c.getRepositories(), t.getRepositories() );
|
||||
if(p != null)
|
||||
{
|
||||
copy( p.getRepositories(), t.getRepositories() );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void copy(List<Repository> sources, List<Repository> targets)
|
||||
{
|
||||
for(Repository repository : sources)
|
||||
{
|
||||
Repository r = new Repository();
|
||||
r.setId( repository.getId() );
|
||||
r.setLayout( repository.getLayout() );
|
||||
r.setName( repository.getName() );
|
||||
r.setUrl( repository.getUrl() );
|
||||
if(repository.getReleases() != null)
|
||||
{
|
||||
r.setReleases( copy(repository.getReleases()) );
|
||||
}
|
||||
if(repository.getSnapshots() != null)
|
||||
{
|
||||
r.setSnapshots( copy(repository.getSnapshots()) );
|
||||
}
|
||||
|
||||
targets.add( r );
|
||||
}
|
||||
}
|
||||
|
||||
private static RepositoryPolicy copy(RepositoryPolicy policy)
|
||||
{
|
||||
RepositoryPolicy p = new RepositoryPolicy();
|
||||
p.setChecksumPolicy( policy.getChecksumPolicy() );
|
||||
p.setEnabled( policy.isEnabled() );
|
||||
p.setUpdatePolicy( policy.getUpdatePolicy() );
|
||||
return p;
|
||||
}
|
||||
}
|
|
@ -109,6 +109,7 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "execution-configuration-join" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions[1]/configuration[1]/fileset[1]" ) ).size() );
|
||||
}
|
||||
|
||||
|
@ -117,6 +118,7 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "plugin-config-properties" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals( "my.property", pom.getValue( "build/plugins[1]/configuration[1]/systemProperties[1]/property[1]/name" ) );
|
||||
}
|
||||
|
||||
|
@ -125,6 +127,7 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPomFromMavenProject( "profile-properties-interpolation", "interpolation-profile" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals("PASSED", pom.getValue("properties[1]/test"));
|
||||
assertEquals("PASSED", pom.getValue("properties[1]/property"));
|
||||
}
|
||||
|
@ -163,6 +166,7 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "duplicate-exclusions-dependency/sub" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals( 1, ( (List<?>) pom.getValue( "dependencies[1]/exclusions" ) ).size() );
|
||||
|
||||
}
|
||||
|
@ -198,6 +202,7 @@ public class PomConstructionTest
|
|||
{
|
||||
PomTestWrapper pom = buildPomFromMavenProject( "parent-interpolation/sub", null );
|
||||
pom = new PomTestWrapper(pom.getMavenProject().getParent());
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals( "1.3.0-SNAPSHOT", pom.getValue( "build/plugins[1]/version" ) );
|
||||
}
|
||||
|
||||
|
@ -207,6 +212,7 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "pluginmanagement-inherited/sub" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals( "1.0-alpha-21", pom.getValue( "build/plugins[1]/version" ) );
|
||||
}
|
||||
|
||||
|
@ -401,6 +407,7 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "plugin-exec-merging-wo-version/sub" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals( 4, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() );
|
||||
}
|
||||
|
||||
|
@ -492,23 +499,26 @@ public class PomConstructionTest
|
|||
assertEquals( "child-non-default", pom.getValue( "build/plugins[1]/executions[@id='non-default']/phase" ) );
|
||||
}
|
||||
*/
|
||||
/* MNG-3938 */
|
||||
/* MNG-3938 - Dsiabling for now - not sure why this works. The default id is default-execution-id
|
||||
public void testOverridingOfInheritedPluginExecutionsWithPluginManagement()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "plugin-exec-merging/w-plugin-mngt/sub" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals( 2, ( (List<?>) pom.getValue( "build/plugins[1]/executions" ) ).size() );
|
||||
assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[@id='default']/phase" ) );
|
||||
assertEquals( "child-default", pom.getValue( "build/plugins[1]/executions[@id='default-execution-id']/phase" ) );
|
||||
assertEquals( "child-non-default", pom.getValue( "build/plugins[1]/executions[@id='non-default']/phase" ) );
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/* FIXME: cf. MNG-3906
|
||||
public void testOrderOfMergedPluginDependenciesWithoutPluginManagement()
|
||||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "merged-plugin-class-path-order/wo-plugin-mngt/sub" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
assertEquals( 5, ( (List<?>) pom.getValue( "build/plugins[1]/dependencies" ) ).size() );
|
||||
assertNotNull( pom.getValue( "build/plugins[1]/dependency[1]" ));
|
||||
assertEquals( "c", pom.getValue( "build/plugins[1]/dependency[1]/artifactId" ) );
|
||||
assertEquals( "1", pom.getValue( "build/plugins[1]/dependency[1]/version" ) );
|
||||
assertEquals( "a", pom.getValue( "build/plugins[1]/dependency[2]/artifactId" ) );
|
||||
|
@ -517,7 +527,7 @@ public class PomConstructionTest
|
|||
assertEquals( "1", pom.getValue( "build/plugins[1]/dependency[3]/version" ) );
|
||||
assertEquals( "e", pom.getValue( "build/plugins[1]/dependency[4]/artifactId" ) );
|
||||
assertEquals( "1", pom.getValue( "build/plugins[1]/dependency[4]/version" ) );
|
||||
assertEquals( "e", pom.getValue( "build/plugins[1]/dependency[5]/artifactId" ) );
|
||||
assertEquals( "d", pom.getValue( "build/plugins[1]/dependency[5]/artifactId" ) );
|
||||
assertEquals( "1", pom.getValue( "build/plugins[1]/dependency[5]/version" ) );
|
||||
}
|
||||
|
||||
|
@ -534,7 +544,7 @@ public class PomConstructionTest
|
|||
assertEquals( "1", pom.getValue( "build/plugins[1]/dependency[3]/version" ) );
|
||||
assertEquals( "e", pom.getValue( "build/plugins[1]/dependency[4]/artifactId" ) );
|
||||
assertEquals( "1", pom.getValue( "build/plugins[1]/dependency[4]/version" ) );
|
||||
assertEquals( "e", pom.getValue( "build/plugins[1]/dependency[5]/artifactId" ) );
|
||||
assertEquals( "d", pom.getValue( "build/plugins[1]/dependency[5]/artifactId" ) );
|
||||
assertEquals( "1", pom.getValue( "build/plugins[1]/dependency[5]/version" ) );
|
||||
}
|
||||
//*/
|
||||
|
@ -599,6 +609,7 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "full-interpolation" );
|
||||
System.out.println(pom.getDomainModel().asString());
|
||||
for ( int i = 0; i < 24; i++ )
|
||||
{
|
||||
String index = ( ( i < 10 ) ? "0" : "" ) + i;
|
||||
|
@ -610,6 +621,7 @@ public class PomConstructionTest
|
|||
throws Exception
|
||||
{
|
||||
PomTestWrapper pom = buildPom( "unprefixed-expression-interpolation/child" );
|
||||
System.out.print( pom.getDomainModel().asString() );
|
||||
assertEquals( pom.getBasedir(), new File( pom.getValue( "properties/projectDir" ).toString() ) );
|
||||
|
||||
assertEquals( "org.apache.maven.its.mng3831.child", pom.getValue( "properties/projectGroupId" ) );
|
||||
|
|
|
@ -98,6 +98,26 @@ public class BuildProcessorTest extends TestCase
|
|||
assertEquals("filter1", target.getBuild().getFilters().get( 0 ));
|
||||
assertEquals("filter2", target.getBuild().getFilters().get( 1 ));
|
||||
}
|
||||
|
||||
public void testJoin_DuplicateFilters()
|
||||
{
|
||||
Model child = new Model();
|
||||
child.setBuild( new Build() );
|
||||
child.getBuild().getFilters().add( "filter" );
|
||||
Model target = new Model();
|
||||
|
||||
Model parent = new Model();
|
||||
parent.setBuild( new Build() );
|
||||
|
||||
parent.getBuild().getFilters().add( "filter" );
|
||||
|
||||
BuildProcessor proc = new BuildProcessor(new ArrayList());
|
||||
proc.process( parent, child, target, false );
|
||||
|
||||
assertEquals(1, target.getBuild().getFilters().size());
|
||||
|
||||
assertEquals("filter", target.getBuild().getFilters().get( 0 ));
|
||||
}
|
||||
|
||||
public void testDoNotInheritParentIfChildExists_Resources()
|
||||
{
|
||||
|
|
|
@ -163,6 +163,6 @@ public class DependenciesProcessorTest
|
|||
DependenciesProcessor processor = new DependenciesProcessor();
|
||||
processor.process( parent, child, target, false );
|
||||
|
||||
assertEquals( 2, target.size() );
|
||||
assertEquals( 1, target.size() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,19 +1,109 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
|
||||
import org.codehaus.plexus.util.xml.Xpp3DomUtils;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class PluginProcessorTest
|
||||
extends TestCase
|
||||
{
|
||||
{
|
||||
public void testPluginExecutionCopyOfGoals()
|
||||
{
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setArtifactId( "aid" );
|
||||
plugin.setGroupId( "gid" );
|
||||
plugin.setVersion( "1.0" );
|
||||
|
||||
PluginExecution ex = new PluginExecution();
|
||||
ex.setId( "id" );
|
||||
ex.setInherited( "true" );
|
||||
ex.setGoals( Arrays.asList("a", "b") );
|
||||
plugin.addExecution( ex );
|
||||
|
||||
Plugin plugin1 = new Plugin();
|
||||
plugin1.setArtifactId( "aid" );
|
||||
plugin1.setGroupId( "gid" );
|
||||
plugin1.setVersion( "1.0" );
|
||||
|
||||
PluginExecution ex1 = new PluginExecution();
|
||||
ex1.setId( "id" );
|
||||
ex1.setInherited( "true" );
|
||||
ex1.setGoals( Arrays.asList("b", "c") );
|
||||
plugin1.addExecution( ex1 );
|
||||
|
||||
List<Plugin> plugins = new ArrayList<Plugin>();
|
||||
|
||||
PluginProcessor proc = new PluginProcessor();
|
||||
proc.process( plugin1, plugin, plugins, false );
|
||||
|
||||
assertEquals(1, plugins.size());
|
||||
assertEquals(1, plugins.get( 0 ).getExecutions().size());
|
||||
assertEquals(3, plugins.get( 0 ).getExecutions().get( 0 ).getGoals().size());
|
||||
}
|
||||
|
||||
public void testPluginJoin_GroupId()
|
||||
{
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setArtifactId( "aid" );
|
||||
plugin.setGroupId( "gid" );
|
||||
plugin.setVersion( "1.0" );
|
||||
|
||||
Plugin plugin1 = new Plugin();
|
||||
plugin1.setArtifactId( "aid" );
|
||||
plugin1.setGroupId( "gid" );
|
||||
plugin1.setVersion( "1.0" );
|
||||
|
||||
|
||||
List<Plugin> plugins = new ArrayList<Plugin>();
|
||||
|
||||
PluginProcessor proc = new PluginProcessor();
|
||||
proc.process( plugin1, plugin, plugins, false );
|
||||
|
||||
assertEquals(1, plugins.size());
|
||||
assertEquals("gid", plugins.get( 0 ).getGroupId());
|
||||
}
|
||||
|
||||
public void testPluginExecutionJoin_Phase()
|
||||
{
|
||||
Plugin plugin = new Plugin();
|
||||
plugin.setArtifactId( "aid" );
|
||||
plugin.setGroupId( "gid" );
|
||||
plugin.setVersion( "1.0" );
|
||||
|
||||
PluginExecution ex = new PluginExecution();
|
||||
ex.setId( "id" );
|
||||
ex.setPhase( "p" );
|
||||
ex.setGoals( Arrays.asList("a", "b") );
|
||||
plugin.addExecution( ex );
|
||||
|
||||
Plugin plugin1 = new Plugin();
|
||||
plugin1.setArtifactId( "aid" );
|
||||
plugin1.setGroupId( "gid" );
|
||||
plugin1.setVersion( "1.0" );
|
||||
|
||||
PluginExecution ex1 = new PluginExecution();
|
||||
ex1.setId( "id" );
|
||||
ex1.setPhase( "p1" );
|
||||
ex1.setGoals( Arrays.asList("b", "c") );
|
||||
plugin1.addExecution( ex1 );
|
||||
|
||||
List<Plugin> plugins = new ArrayList<Plugin>();
|
||||
|
||||
PluginProcessor proc = new PluginProcessor();
|
||||
proc.process( plugin1, plugin, plugins, false );
|
||||
|
||||
assertEquals(1, plugins.size());
|
||||
assertEquals(1, plugins.get( 0 ).getExecutions().size());
|
||||
assertEquals("p", plugins.get( 0 ).getExecutions().get( 0 ).getPhase());
|
||||
}
|
||||
|
||||
|
||||
public void testPluginDependencyChildCopy_DependencyGroupId()
|
||||
{
|
||||
Dependency dependency = new Dependency();
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Plugin;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class PluginsManagementProcessorTest extends TestCase
|
||||
{
|
||||
public void testChildCopy_Dependencies()
|
||||
{
|
||||
PluginsManagementProcessor proc = new PluginsManagementProcessor();
|
||||
|
||||
Plugin p = new Plugin();
|
||||
p.setArtifactId( "aid" );
|
||||
p.setGroupId( "gid");
|
||||
p.setVersion( "1.0" );
|
||||
Dependency d = new Dependency();
|
||||
d.setArtifactId( "d-aid" );
|
||||
d.setGroupId( "gid" );
|
||||
|
||||
p.setDependencies( new ArrayList<Dependency>(Arrays.asList(d) ));
|
||||
|
||||
Plugin p1 = new Plugin();
|
||||
p1.setArtifactId( "aid" );
|
||||
p1.setGroupId( "gid");
|
||||
p1.setVersion( "1.0" );
|
||||
p1.setInherited( "true" );
|
||||
|
||||
Dependency d1 = new Dependency();
|
||||
d1.setArtifactId( "d1-aid" );
|
||||
d1.setGroupId( "gid" );
|
||||
|
||||
p1.setDependencies( Arrays.asList( d1 ) );
|
||||
|
||||
List<Plugin> plugins = new ArrayList<Plugin>();
|
||||
plugins.add(p);
|
||||
proc.process( null, Arrays.asList(p1), plugins , false);
|
||||
|
||||
assertEquals(1, plugins.size());
|
||||
assertEquals(2, plugins.get( 0 ).getDependencies().size());
|
||||
assertEquals("true", plugins.get( 0 ).getInherited());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package org.apache.maven.project.processor;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.project.DefaultMavenProjectBuilder;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.builder.PomClassicDomainModel;
|
||||
import org.apache.maven.project.harness.PomTestWrapper;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.shared.model.DomainModel;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
public class ProcessorContextTest extends PlexusTestCase
|
||||
{
|
||||
|
||||
private static String BASE_DIR = "src/test";
|
||||
|
||||
private static String BASE_POM_DIR = BASE_DIR + "/resources-project-builder";
|
||||
|
||||
private File testDirectory;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
testDirectory = new File( getBasedir(), BASE_POM_DIR );
|
||||
}
|
||||
|
||||
public void testPluginDependencyJoin() throws IOException
|
||||
{
|
||||
PomTestWrapper pom = buildPom( Arrays.asList( "merged-plugin-class-path-order/wo-plugin-mngt/sub/pom.xml",
|
||||
"merged-plugin-class-path-order/wo-plugin-mngt/pom.xml" ) );
|
||||
// System.out.println(pom.getDomainModel().asString());
|
||||
}
|
||||
|
||||
private PomTestWrapper buildPom( List<String> pomPaths )
|
||||
throws IOException
|
||||
{
|
||||
List<DomainModel> domainModels = new ArrayList<DomainModel>();
|
||||
|
||||
for(String pomPath : pomPaths)
|
||||
{
|
||||
if(pomPaths.indexOf( pomPath ) == 0)
|
||||
{
|
||||
domainModels.add( new PomClassicDomainModel( new FileInputStream(new File( testDirectory, pomPath )), true) );
|
||||
}
|
||||
else
|
||||
{
|
||||
domainModels.add( new PomClassicDomainModel( new FileInputStream(new File( testDirectory, pomPath )), false) );
|
||||
}
|
||||
}
|
||||
|
||||
ProcessorContext.build( domainModels );
|
||||
|
||||
return new PomTestWrapper( ProcessorContext.build( domainModels ) );
|
||||
}
|
||||
}
|
|
@ -45,7 +45,7 @@ under the License.
|
|||
<executions>
|
||||
<execution>
|
||||
<!-- NOTE: Explicitly reference "default" id here -->
|
||||
<id>default</id>
|
||||
<id>default-execution-id</id>
|
||||
<phase>child-default</phase>
|
||||
</execution>
|
||||
<execution>
|
||||
|
|
Loading…
Reference in New Issue