mirror of https://github.com/apache/maven.git
PomClassicTransformer now using a factory to create domain model.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@720277 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d486ebbe5c
commit
f312012e8a
|
@ -0,0 +1,29 @@
|
|||
package org.apache.maven.project.builder;
|
||||
|
||||
import org.apache.maven.shared.model.DomainModelFactory;
|
||||
import org.apache.maven.shared.model.DomainModel;
|
||||
import org.apache.maven.shared.model.ModelProperty;
|
||||
import org.apache.maven.shared.model.ModelMarshaller;
|
||||
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
import java.util.List;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
|
||||
public class PomClassicDomainModelFactory implements DomainModelFactory
|
||||
{
|
||||
public DomainModel createDomainModel(List<ModelProperty> modelProperties) throws IOException
|
||||
{
|
||||
String xml = null;
|
||||
try
|
||||
{
|
||||
xml = ModelMarshaller.unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri );
|
||||
return new PomClassicDomainModel( new MavenXpp3Reader().read( new StringReader( xml ) ) );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
throw new IOException( e + ":\r\n" + xml );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -35,6 +35,13 @@ public final class PomClassicTransformer
|
|||
implements ModelTransformer
|
||||
{
|
||||
|
||||
private final DomainModelFactory factory;
|
||||
|
||||
public PomClassicTransformer(DomainModelFactory factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
private static Map<String, List<ModelProperty>> cache = new HashMap<String, List<ModelProperty>>();
|
||||
|
||||
/**
|
||||
|
@ -168,16 +175,7 @@ public final class PomClassicTransformer
|
|||
}
|
||||
}
|
||||
|
||||
String xml = null;
|
||||
try
|
||||
{
|
||||
xml = ModelMarshaller.unmarshalModelPropertiesToXml( props, ProjectUri.baseUri );
|
||||
return new PomClassicDomainModel( new MavenXpp3Reader().read( new StringReader( xml ) ) );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
{
|
||||
throw new IOException( e + ":\r\n" + xml );
|
||||
}
|
||||
return factory.createDomainModel( props );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -161,7 +161,7 @@ public final class DefaultProjectBuilder
|
|||
domainModels.add( new PomClassicDomainModel( model ) );
|
||||
}
|
||||
|
||||
PomClassicTransformer transformer = new PomClassicTransformer( );
|
||||
PomClassicTransformer transformer = new PomClassicTransformer( new PomClassicDomainModelFactory() );
|
||||
ModelTransformerContext ctx = new ModelTransformerContext(
|
||||
Arrays.asList( new ArtifactModelContainerFactory(), new IdModelContainerFactory() ) );
|
||||
|
||||
|
|
Loading…
Reference in New Issue