mirror of https://github.com/apache/maven.git
Default interpolator annotated.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@765796 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7014f578e9
commit
554927a598
|
@ -73,11 +73,9 @@ import org.apache.maven.project.MavenProjectBuilder;
|
|||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.builder.DefaultInterpolator;
|
||||
import org.apache.maven.project.builder.Interpolator;
|
||||
import org.apache.maven.project.builder.InterpolatorProperty;
|
||||
import org.apache.maven.project.builder.ModelProperty;
|
||||
import org.apache.maven.project.builder.PomInterpolatorTag;
|
||||
import org.apache.maven.project.builder.ProcessorContext;
|
||||
import org.apache.maven.project.builder.ProjectUri;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.realm.MavenRealmManager;
|
||||
import org.apache.maven.realm.RealmManagementException;
|
||||
|
@ -153,6 +151,9 @@ public class DefaultPluginManager
|
|||
@Requirement
|
||||
protected RepositoryMetadataManager repositoryMetadataManager;
|
||||
|
||||
@Requirement
|
||||
protected Interpolator interpolator;
|
||||
|
||||
private Map pluginDefinitionsByPrefix = new HashMap();
|
||||
|
||||
public DefaultPluginManager()
|
||||
|
@ -511,7 +512,7 @@ public class DefaultPluginManager
|
|||
PomInterpolatorTag.EXECUTION_PROPERTIES.name() ) );
|
||||
interpolatorProperties
|
||||
.addAll( InterpolatorProperty.toInterpolatorProperties( session.getProjectBuilderConfiguration().getUserProperties(), PomInterpolatorTag.USER_PROPERTIES.name() ) );
|
||||
String interpolatedDom = new DefaultInterpolator().interpolateXmlString( String.valueOf( dom ), interpolatorProperties );
|
||||
String interpolatedDom = interpolator.interpolateXmlString( String.valueOf( dom ), interpolatorProperties );
|
||||
dom = Xpp3DomBuilder.build( new StringReader( interpolatedDom ) );
|
||||
}
|
||||
catch ( XmlPullParserException e )
|
||||
|
|
|
@ -26,6 +26,10 @@
|
|||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-model</artifactId>
|
||||
|
@ -45,6 +49,13 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-metadata</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -25,7 +25,9 @@ import org.apache.maven.model.Build;
|
|||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Reporting;
|
||||
import org.apache.maven.model.Resource;
|
||||
import org.codehaus.plexus.component.annotations.Component;
|
||||
|
||||
@Component(role=Interpolator.class)
|
||||
public class DefaultInterpolator implements Interpolator {
|
||||
|
||||
public String interpolateXmlString(String xml,
|
||||
|
|
|
@ -40,6 +40,53 @@ import org.codehaus.plexus.util.xml.Xpp3Dom;
|
|||
public class ProcessorContext
|
||||
{
|
||||
|
||||
/**
|
||||
* Parent domain models on bottom.
|
||||
*
|
||||
* @param domainModels
|
||||
* @param listeners
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static PomClassicDomainModel build( List<DomainModel> domainModels, List<ModelEventListener> listeners )
|
||||
throws IOException
|
||||
{
|
||||
PomClassicDomainModel child = null;
|
||||
for ( DomainModel domainModel : domainModels )
|
||||
{
|
||||
if(domainModel.isMostSpecialized())
|
||||
{
|
||||
child = (PomClassicDomainModel) domainModel;
|
||||
}
|
||||
}
|
||||
if(child == null)
|
||||
{
|
||||
throw new IOException("Could not find child model");
|
||||
}
|
||||
|
||||
List<Processor> processors =
|
||||
Arrays.<Processor> asList( new BuildProcessor( new ArrayList<Processor>() ), new ModuleProcessor(),
|
||||
new PropertiesProcessor(), new ParentProcessor(), new OrganizationProcessor(),
|
||||
new MailingListProcessor(), new IssueManagementProcessor(),
|
||||
new CiManagementProcessor(), new ReportingProcessor(),
|
||||
new RepositoriesProcessor(), new DistributionManagementProcessor(),
|
||||
new LicensesProcessor(), new ScmProcessor(), new PrerequisitesProcessor(),
|
||||
new ContributorsProcessor(), new DevelopersProcessor(), new ProfilesProcessor() );
|
||||
Model target = processModelsForInheritance( convertDomainModelsToMavenModels( domainModels ), processors );
|
||||
if(listeners != null)
|
||||
{
|
||||
for(ModelEventListener listener : listeners)
|
||||
{
|
||||
listener.fire(target);
|
||||
}
|
||||
}
|
||||
PomClassicDomainModel domainModel = new PomClassicDomainModel( target, child.isMostSpecialized() );
|
||||
domainModel.setProjectDirectory(child.getProjectDirectory());
|
||||
domainModel.setParentFile(child.getParentFile());
|
||||
|
||||
return domainModel;
|
||||
}
|
||||
|
||||
public static PomClassicDomainModel mergeProfilesIntoModel(Collection<Profile> profiles, PomClassicDomainModel domainModel) throws IOException
|
||||
{
|
||||
List<Model> profileModels = new ArrayList<Model>();
|
||||
|
@ -150,53 +197,6 @@ public class ProcessorContext
|
|||
|
||||
return models;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parent domain models on bottom.
|
||||
*
|
||||
* @param domainModels
|
||||
* @param listeners
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static PomClassicDomainModel build( List<DomainModel> domainModels, List<ModelEventListener> listeners )
|
||||
throws IOException
|
||||
{
|
||||
PomClassicDomainModel child = null;
|
||||
for ( DomainModel domainModel : domainModels )
|
||||
{
|
||||
if(domainModel.isMostSpecialized())
|
||||
{
|
||||
child = (PomClassicDomainModel) domainModel;
|
||||
}
|
||||
}
|
||||
if(child == null)
|
||||
{
|
||||
throw new IOException("Could not find child model");
|
||||
}
|
||||
|
||||
List<Processor> processors =
|
||||
Arrays.<Processor> asList( new BuildProcessor( new ArrayList<Processor>() ), new ModuleProcessor(),
|
||||
new PropertiesProcessor(), new ParentProcessor(), new OrganizationProcessor(),
|
||||
new MailingListProcessor(), new IssueManagementProcessor(),
|
||||
new CiManagementProcessor(), new ReportingProcessor(),
|
||||
new RepositoriesProcessor(), new DistributionManagementProcessor(),
|
||||
new LicensesProcessor(), new ScmProcessor(), new PrerequisitesProcessor(),
|
||||
new ContributorsProcessor(), new DevelopersProcessor(), new ProfilesProcessor() );
|
||||
Model target = processModelsForInheritance( convertDomainModelsToMavenModels( domainModels ), processors );
|
||||
if(listeners != null)
|
||||
{
|
||||
for(ModelEventListener listener : listeners)
|
||||
{
|
||||
listener.fire(target);
|
||||
}
|
||||
}
|
||||
PomClassicDomainModel domainModel = new PomClassicDomainModel( target, child.isMostSpecialized() );
|
||||
domainModel.setProjectDirectory(child.getProjectDirectory());
|
||||
domainModel.setParentFile(child.getParentFile());
|
||||
|
||||
return domainModel;
|
||||
}
|
||||
|
||||
private static Model processModelsForInheritance(List<Model> models, List<Processor> processors)
|
||||
{
|
||||
|
|
|
@ -45,6 +45,7 @@ import org.apache.maven.profiles.ProfileManager;
|
|||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.builder.DefaultInterpolator;
|
||||
import org.apache.maven.project.builder.DomainModel;
|
||||
import org.apache.maven.project.builder.Interpolator;
|
||||
import org.apache.maven.project.builder.InterpolatorProperty;
|
||||
import org.apache.maven.project.builder.ModelEventListener;
|
||||
import org.apache.maven.project.builder.PomClassicDomainModel;
|
||||
|
@ -84,6 +85,9 @@ public class DefaultMavenProjectBuilder
|
|||
@Requirement
|
||||
List<ModelEventListener> listeners;
|
||||
|
||||
@Requirement
|
||||
private Interpolator interpolator;
|
||||
|
||||
@Requirement
|
||||
private ResolutionErrorHandler resolutionErrorHandler;
|
||||
|
||||
|
@ -387,20 +391,7 @@ public class DefaultMavenProjectBuilder
|
|||
|
||||
try
|
||||
{
|
||||
//List<ModelProperty> mps = domainModel.getModelProperties();
|
||||
model = new DefaultInterpolator().interpolateDomainModel( domainModel, interpolatorProperties ).getModel();
|
||||
/*
|
||||
if ( domainModel.getProjectDirectory() != null )
|
||||
{
|
||||
mps = ProcessorContext.alignPaths( mps, domainModel.getProjectDirectory() );
|
||||
}
|
||||
File f = domainModel.getParentFile();
|
||||
domainModel = new PomClassicDomainModel( mps, false );
|
||||
domainModel.setParentFile(f);
|
||||
|
||||
model = domainModel.getModel();
|
||||
*/
|
||||
|
||||
model = interpolator.interpolateDomainModel( domainModel, interpolatorProperties ).getModel();
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue