mirror of https://github.com/apache/maven.git
Descriptions inherited. Modified API to add listeners to processors. Still need to modify the listener API as weell.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@759482 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3cfbbb52c6
commit
28d05ee6d4
|
@ -1,5 +0,0 @@
|
||||||
package org.apache.maven.project.builder;
|
|
||||||
|
|
||||||
public interface ModelNodeProcessor {
|
|
||||||
|
|
||||||
}
|
|
|
@ -25,20 +25,29 @@ import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.model.Build;
|
import org.apache.maven.model.Build;
|
||||||
import org.apache.maven.model.BuildBase;
|
import org.apache.maven.model.BuildBase;
|
||||||
import org.apache.maven.model.Dependency;
|
|
||||||
import org.apache.maven.model.Extension;
|
import org.apache.maven.model.Extension;
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.model.PluginManagement;
|
import org.apache.maven.model.PluginManagement;
|
||||||
import org.apache.maven.model.Resource;
|
import org.apache.maven.model.Resource;
|
||||||
|
import org.apache.maven.shared.model.ModelEventListener;
|
||||||
|
|
||||||
public class BuildProcessor
|
public class BuildProcessor
|
||||||
extends BaseProcessor
|
extends BaseProcessor
|
||||||
{
|
{
|
||||||
|
private List<ModelEventListener> listeners;
|
||||||
|
|
||||||
public BuildProcessor( Collection<Processor> processors )
|
public BuildProcessor( Collection<Processor> processors )
|
||||||
{
|
{
|
||||||
super( processors );
|
super( processors );
|
||||||
}
|
listeners = new ArrayList<ModelEventListener>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BuildProcessor( Collection<Processor> processors, List<ModelEventListener> listeners)
|
||||||
|
{
|
||||||
|
super( processors );
|
||||||
|
listeners = (listeners == null) ? new ArrayList<ModelEventListener>() : new ArrayList<ModelEventListener>(listeners);
|
||||||
|
}
|
||||||
|
|
||||||
public void processWithProfile( BuildBase build, Model target )
|
public void processWithProfile( BuildBase build, Model target )
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,9 +106,13 @@ public class ModelProcessor
|
||||||
if ( isChildMostSpecialized )
|
if ( isChildMostSpecialized )
|
||||||
{
|
{
|
||||||
t.setName( c.getName() );
|
t.setName( c.getName() );
|
||||||
t.setDescription( c.getDescription() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(c.getDescription() != null)
|
||||||
|
{
|
||||||
|
t.setDescription( c.getDescription() );
|
||||||
|
}
|
||||||
|
|
||||||
if ( c.getInceptionYear() != null )
|
if ( c.getInceptionYear() != null )
|
||||||
{
|
{
|
||||||
t.setInceptionYear( c.getInceptionYear() );
|
t.setInceptionYear( c.getInceptionYear() );
|
||||||
|
|
|
@ -51,6 +51,7 @@ import org.apache.maven.project.builder.PomInterpolatorTag;
|
||||||
import org.apache.maven.project.builder.ProjectUri;
|
import org.apache.maven.project.builder.ProjectUri;
|
||||||
import org.apache.maven.shared.model.DomainModel;
|
import org.apache.maven.shared.model.DomainModel;
|
||||||
import org.apache.maven.shared.model.InterpolatorProperty;
|
import org.apache.maven.shared.model.InterpolatorProperty;
|
||||||
|
import org.apache.maven.shared.model.ModelEventListener;
|
||||||
import org.apache.maven.shared.model.ModelProperty;
|
import org.apache.maven.shared.model.ModelProperty;
|
||||||
import org.apache.maven.shared.model.ModelTransformerContext;
|
import org.apache.maven.shared.model.ModelTransformerContext;
|
||||||
import org.codehaus.plexus.util.WriterFactory;
|
import org.codehaus.plexus.util.WriterFactory;
|
||||||
|
@ -169,18 +170,11 @@ public class ProcessorContext
|
||||||
|
|
||||||
return models;
|
return models;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Parent domain models on bottom.
|
|
||||||
*
|
|
||||||
* @param domainModels
|
|
||||||
* @return
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public static PomClassicDomainModel build( List<DomainModel> domainModels,
|
public static PomClassicDomainModel build( List<DomainModel> domainModels,
|
||||||
List<InterpolatorProperty> interpolationProperties )
|
List<InterpolatorProperty> interpolationProperties, List<ModelEventListener> listeners)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
PomClassicDomainModel child = null;
|
PomClassicDomainModel child = null;
|
||||||
for ( DomainModel domainModel : domainModels )
|
for ( DomainModel domainModel : domainModels )
|
||||||
{
|
{
|
||||||
|
@ -223,7 +217,20 @@ public class ProcessorContext
|
||||||
{
|
{
|
||||||
modelProperties = model.getModelProperties();
|
modelProperties = model.getModelProperties();
|
||||||
}
|
}
|
||||||
return new PomClassicDomainModel( modelProperties );
|
return new PomClassicDomainModel( modelProperties );
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Parent domain models on bottom.
|
||||||
|
*
|
||||||
|
* @param domainModels
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static PomClassicDomainModel build( List<DomainModel> domainModels,
|
||||||
|
List<InterpolatorProperty> interpolationProperties )
|
||||||
|
throws IOException
|
||||||
|
{
|
||||||
|
return build(domainModels, interpolationProperties, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Model processModelsForInheritance(List<Model> models, List<Processor> processors)
|
private static Model processModelsForInheritance(List<Model> models, List<Processor> processors)
|
||||||
|
|
|
@ -117,17 +117,6 @@ public class ModelProcessorTest
|
||||||
assertEquals( "description", targetModel.getDescription() );
|
assertEquals( "description", targetModel.getDescription() );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testDescriptionNotSpecialized()
|
|
||||||
{
|
|
||||||
Model targetModel = new Model();
|
|
||||||
Model childModel = new Model();
|
|
||||||
childModel.setDescription( "description" );
|
|
||||||
|
|
||||||
ModelProcessor mp = new ModelProcessor( new ArrayList<Processor>() );
|
|
||||||
mp.process( null, childModel, targetModel, false );
|
|
||||||
assertNull( targetModel.getDescription() );
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testInceptionYearFromChild()
|
public void testInceptionYearFromChild()
|
||||||
{
|
{
|
||||||
Model targetModel = new Model();
|
Model targetModel = new Model();
|
||||||
|
|
Loading…
Reference in New Issue