mirror of https://github.com/apache/maven.git
Added in Project Event Listeners. Still need to hook up a plexus component and a model container factory for configuring listeners.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@714109 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
378ee24d22
commit
1a9ef5d0e0
|
@ -115,9 +115,9 @@ public final class PomClassicTransformer
|
|||
}
|
||||
|
||||
/**
|
||||
* @see ModelTransformer#transformToDomainModel(java.util.List)
|
||||
* @see ModelTransformer#transformToDomainModel(java.util.List, java.util.List)
|
||||
*/
|
||||
public DomainModel transformToDomainModel( List<ModelProperty> properties )
|
||||
public DomainModel transformToDomainModel( List<ModelProperty> properties, List<ModelEventListener> eventListeners)
|
||||
throws IOException
|
||||
{
|
||||
if ( properties == null )
|
||||
|
@ -125,6 +125,15 @@ public final class PomClassicTransformer
|
|||
throw new IllegalArgumentException( "properties: null" );
|
||||
}
|
||||
|
||||
if( eventListeners == null )
|
||||
{
|
||||
eventListeners = new ArrayList<ModelEventListener>();
|
||||
}
|
||||
else
|
||||
{
|
||||
eventListeners = new ArrayList<ModelEventListener>(eventListeners);
|
||||
}
|
||||
|
||||
List<ModelProperty> props = new ArrayList<ModelProperty>( properties );
|
||||
|
||||
//dependency management
|
||||
|
@ -226,6 +235,16 @@ public final class PomClassicTransformer
|
|||
}
|
||||
props.removeAll( removeProperties );
|
||||
|
||||
for(ModelEventListener listener : eventListeners)
|
||||
{
|
||||
ModelDataSource ds = new DefaultModelDataSource();
|
||||
ds.init( props, listener.getModelContainerFactories() );
|
||||
for(String uri : listener.getUris() )
|
||||
{
|
||||
listener.fire(ds.queryFor(uri));
|
||||
}
|
||||
}
|
||||
|
||||
String xml = null;
|
||||
try
|
||||
{
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
package org.apache.maven.project.builder;
|
||||
|
||||
public class ProjectEventListeners {
|
||||
}
|
|
@ -177,7 +177,8 @@ public final class DefaultProjectBuilder
|
|||
transformer,
|
||||
transformer,
|
||||
importModels,
|
||||
properties ) );
|
||||
properties,
|
||||
null) );
|
||||
try
|
||||
{
|
||||
MavenProject mavenProject = new MavenProject( transformedDomainModel.getModel(), artifactFactory,
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
package org.apache.maven.shared.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
public interface ModelEventListener {
|
||||
|
||||
public void fire(List<ModelContainer> modelContainers);
|
||||
|
||||
List<String> getUris();
|
||||
|
||||
Collection<ModelContainerFactory> getModelContainerFactories();
|
||||
}
|
|
@ -39,7 +39,7 @@ public interface ModelTransformer
|
|||
* @param properties list of model properties to transform into domain model. List may not be null.
|
||||
* @return domain model
|
||||
*/
|
||||
DomainModel transformToDomainModel( List<ModelProperty> properties )
|
||||
DomainModel transformToDomainModel( List<ModelProperty> properties, List<ModelEventListener> eventListeners)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -213,12 +213,24 @@ public final class ModelTransformerContext
|
|||
* @param interpolatorProperties properties to use during interpolation. @return processed domain model
|
||||
* @throws IOException if there was a problem with the transform
|
||||
*/
|
||||
public DomainModel transform(List<DomainModel> domainModels, ModelTransformer fromModelTransformer,
|
||||
public DomainModel transform(List<DomainModel> domainModels,
|
||||
ModelTransformer fromModelTransformer,
|
||||
ModelTransformer toModelTransformer,
|
||||
Collection<ImportModel> importModels, List<InterpolatorProperty> interpolatorProperties)
|
||||
Collection<ImportModel> importModels,
|
||||
List<InterpolatorProperty> interpolatorProperties,
|
||||
List<ModelEventListener> eventListeners)
|
||||
throws IOException
|
||||
{
|
||||
|
||||
if( eventListeners == null )
|
||||
{
|
||||
eventListeners = new ArrayList<ModelEventListener>();
|
||||
}
|
||||
else
|
||||
{
|
||||
eventListeners = new ArrayList<ModelEventListener>(eventListeners);
|
||||
}
|
||||
|
||||
List<ModelProperty> transformedProperties =
|
||||
importModelProperties(importModels, fromModelTransformer.transformToModelProperties( domainModels));
|
||||
|
||||
|
@ -290,7 +302,7 @@ public final class ModelTransformerContext
|
|||
|
||||
try
|
||||
{
|
||||
DomainModel domainModel = toModelTransformer.transformToDomainModel( mps );
|
||||
DomainModel domainModel = toModelTransformer.transformToDomainModel( mps, eventListeners );
|
||||
domainModel.setEventHistory(modelDataSource.getEventHistory());
|
||||
return domainModel;
|
||||
}
|
||||
|
@ -316,7 +328,7 @@ public final class ModelTransformerContext
|
|||
ModelTransformer toModelTransformer )
|
||||
throws IOException
|
||||
{
|
||||
return this.transform( domainModels, fromModelTransformer, toModelTransformer, null, systemInterpolatorProperties );
|
||||
return this.transform( domainModels, fromModelTransformer, toModelTransformer, null, systemInterpolatorProperties, null );
|
||||
}
|
||||
|
||||
private static List<ModelProperty> importModelProperties(Collection<ImportModel> importModels,
|
||||
|
|
Loading…
Reference in New Issue