Need to interpolate the plugin configurations that are stored in MojoExecution instances, created during build planning.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@672794 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-06-30 15:27:16 +00:00
parent 3e03ce0956
commit ff3312c747
2 changed files with 47 additions and 2 deletions

View File

@ -59,6 +59,7 @@ import org.apache.maven.project.ProjectBuildingException;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.artifact.MavenMetadataSource;
import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.apache.maven.project.interpolation.ModelInterpolator;
import org.apache.maven.project.path.PathTranslator;
import org.apache.maven.realm.MavenRealmManager;
import org.apache.maven.realm.RealmManagementException;
@ -83,7 +84,11 @@ import org.codehaus.plexus.logging.AbstractLogEnabled;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@ -135,6 +140,8 @@ public class DefaultPluginManager
protected MavenProjectBuilder mavenProjectBuilder;
protected ModelInterpolator modelInterpolator;
protected PluginMappingManager pluginMappingManager;
private PluginManagerSupport pluginManagerSupport;
@ -556,8 +563,43 @@ public class DefaultPluginManager
Xpp3Dom dom = mojoExecution.getConfiguration();
if ( dom != null )
{
// make a defensive copy, to keep things from getting polluted.
dom = new Xpp3Dom( dom );
try
{
String interpolatedDom = modelInterpolator.interpolate( String.valueOf( dom ),
project.getModel(),
project.getBasedir(),
session.getProjectBuilderConfiguration(),
getLogger().isDebugEnabled() );
dom = Xpp3DomBuilder.build( new StringReader( interpolatedDom ) );
}
catch ( ModelInterpolationException e )
{
throw new PluginManagerException(
mojoDescriptor,
project,
"Failed to calculate concrete state for configuration of: "
+ mojoDescriptor.getHumanReadableKey(),
e );
}
catch ( XmlPullParserException e )
{
throw new PluginManagerException(
mojoDescriptor,
project,
"Failed to calculate concrete state for configuration of: "
+ mojoDescriptor.getHumanReadableKey(),
e );
}
catch ( IOException e )
{
throw new PluginManagerException(
mojoDescriptor,
project,
"Failed to calculate concrete state for configuration of: "
+ mojoDescriptor.getHumanReadableKey(),
e );
}
}
// Event monitoring.

View File

@ -215,6 +215,9 @@ under the License.
<requirement>
<role>org.apache.maven.plugin.PluginManagerSupport</role>
</requirement>
<requirement>
<role>org.apache.maven.project.interpolation.ModelInterpolator</role>
</requirement>
<requirement>
<role>org.apache.maven.ArtifactFilterManager</role>
</requirement>