Fix: Interpolation of standalone super poms.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@695615 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Britton Isbell 2008-09-15 20:45:04 +00:00
parent bc3660ec47
commit 9e7c8be43c
2 changed files with 46 additions and 2 deletions

View File

@ -45,6 +45,7 @@ import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.apache.maven.project.builder.PomArtifactResolver; import org.apache.maven.project.builder.PomArtifactResolver;
import org.apache.maven.project.builder.ProjectBuilder; import org.apache.maven.project.builder.ProjectBuilder;
import org.apache.maven.project.builder.PomInterpolatorTag; import org.apache.maven.project.builder.PomInterpolatorTag;
import org.apache.maven.project.builder.PomClassicTransformer;
import org.apache.maven.project.validation.ModelValidationResult; import org.apache.maven.project.validation.ModelValidationResult;
import org.apache.maven.project.validation.ModelValidator; import org.apache.maven.project.validation.ModelValidator;
import org.apache.maven.project.workspace.ProjectWorkspace; import org.apache.maven.project.workspace.ProjectWorkspace;
@ -253,6 +254,48 @@ public class DefaultMavenProjectBuilder
} }
} }
List<InterpolatorProperty> interpolatorProperties = new ArrayList<InterpolatorProperty>();
interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getExecutionProperties(),
PomInterpolatorTag.SYSTEM_PROPERTIES.name()));
interpolatorProperties.addAll( InterpolatorProperty.toInterpolatorProperties( config.getUserProperties(),
PomInterpolatorTag.USER_PROPERTIES.name()));
if(config.getBuildStartTime() != null)
{
interpolatorProperties.add(new InterpolatorProperty("${build.timestamp}",
new SimpleDateFormat("yyyyMMdd-hhmm").format( config.getBuildStartTime() ),
PomInterpolatorTag.PROJECT_PROPERTIES.name()));
}
File basedir = null;
for(InterpolatorProperty ip : interpolatorProperties )
{
if(ip.getKey().equals("${basedir}"))
{
basedir = new File(ip.getValue());
break;
}
}
if(basedir == null)
{
String bd = System.getProperty("basedir");
if( bd != null )
{
basedir = new File(bd);
}
}
try
{
superModel = PomClassicTransformer.interpolateModel(superModel, interpolatorProperties, basedir);
}
catch (IOException e)
{
throw new ProjectBuildingException(STANDALONE_SUPERPOM_GROUPID + ":" + STANDALONE_SUPERPOM_ARTIFACTID,
"Interpolation failure:", e);
}
MavenProject project; MavenProject project;
try try
{ {

View File

@ -582,10 +582,11 @@ public final class PomClassicTransformer
} }
} }
String basedir = domainModel.getProjectDirectory().getAbsolutePath();
List<InterpolatorProperty> standardInterpolatorProperties = new ArrayList<InterpolatorProperty>(); List<InterpolatorProperty> standardInterpolatorProperties = new ArrayList<InterpolatorProperty>();
if(domainModel.isPomInBuild()) if(domainModel.isPomInBuild())
{ {
String basedir = domainModel.getProjectDirectory().getAbsolutePath();
standardInterpolatorProperties.add(new InterpolatorProperty("${project.basedir}", basedir, standardInterpolatorProperties.add(new InterpolatorProperty("${project.basedir}", basedir,
PomInterpolatorTag.PROJECT_PROPERTIES.name() )); PomInterpolatorTag.PROJECT_PROPERTIES.name() ));
standardInterpolatorProperties.add(new InterpolatorProperty("${basedir}", basedir, standardInterpolatorProperties.add(new InterpolatorProperty("${basedir}", basedir,
@ -621,7 +622,7 @@ public final class PomClassicTransformer
//SECOND PASS - Set absolute paths on build directories //SECOND PASS - Set absolute paths on build directories
if( domainModel.isPomInBuild() ) if( domainModel.isPomInBuild() )
{ { String basedir = domainModel.getProjectDirectory().getAbsolutePath();
Map<ModelProperty, ModelProperty> buildDirectories = new HashMap<ModelProperty, ModelProperty>(); Map<ModelProperty, ModelProperty> buildDirectories = new HashMap<ModelProperty, ModelProperty>();
for(ModelProperty mp : secondPassModelProperties) for(ModelProperty mp : secondPassModelProperties)
{ {