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:
Britton Isbell 2009-03-28 15:16:40 +00:00
parent 3cfbbb52c6
commit 28d05ee6d4
5 changed files with 36 additions and 32 deletions

View File

@ -1,5 +0,0 @@
package org.apache.maven.project.builder;
public interface ModelNodeProcessor {
}

View File

@ -25,20 +25,29 @@ import java.util.List;
import org.apache.maven.model.Build;
import org.apache.maven.model.BuildBase;
import org.apache.maven.model.Dependency;
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;
import org.apache.maven.shared.model.ModelEventListener;
public class BuildProcessor
extends BaseProcessor
{
private List<ModelEventListener> listeners;
public BuildProcessor( Collection<Processor> 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 )
{

View File

@ -106,9 +106,13 @@ public class ModelProcessor
if ( isChildMostSpecialized )
{
t.setName( c.getName() );
t.setDescription( c.getDescription() );
}
if(c.getDescription() != null)
{
t.setDescription( c.getDescription() );
}
if ( c.getInceptionYear() != null )
{
t.setInceptionYear( c.getInceptionYear() );

View File

@ -51,6 +51,7 @@ 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.ModelEventListener;
import org.apache.maven.shared.model.ModelProperty;
import org.apache.maven.shared.model.ModelTransformerContext;
import org.codehaus.plexus.util.WriterFactory;
@ -169,18 +170,11 @@ public class ProcessorContext
return models;
}
/**
* Parent domain models on bottom.
*
* @param domainModels
* @return
* @throws IOException
*/
public static PomClassicDomainModel build( List<DomainModel> domainModels,
List<InterpolatorProperty> interpolationProperties )
throws IOException
{
List<InterpolatorProperty> interpolationProperties, List<ModelEventListener> listeners)
throws IOException
{
PomClassicDomainModel child = null;
for ( DomainModel domainModel : domainModels )
{
@ -223,7 +217,20 @@ public class ProcessorContext
{
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)

View File

@ -117,17 +117,6 @@ public class ModelProcessorTest
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()
{
Model targetModel = new Model();