From 9e7c8be43cb87f878088024f8e927603b3fc0883 Mon Sep 17 00:00:00 2001 From: Britton Isbell Date: Mon, 15 Sep 2008 20:45:04 +0000 Subject: [PATCH] Fix: Interpolation of standalone super poms. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@695615 13f79535-47bb-0310-9956-ffa450edef68 --- .../project/DefaultMavenProjectBuilder.java | 43 +++++++++++++++++++ .../builder/PomClassicTransformer.java | 5 ++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java index 240aa6ad89..35710a3087 100644 --- a/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java +++ b/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java @@ -45,6 +45,7 @@ import org.apache.maven.project.artifact.InvalidDependencyVersionException; import org.apache.maven.project.builder.PomArtifactResolver; import org.apache.maven.project.builder.ProjectBuilder; 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.ModelValidator; import org.apache.maven.project.workspace.ProjectWorkspace; @@ -253,6 +254,48 @@ public class DefaultMavenProjectBuilder } } + List interpolatorProperties = new ArrayList(); + 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; try { diff --git a/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java b/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java index 749962e51c..d0a9f93c2e 100644 --- a/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java +++ b/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicTransformer.java @@ -582,10 +582,11 @@ public final class PomClassicTransformer } } - String basedir = domainModel.getProjectDirectory().getAbsolutePath(); + List standardInterpolatorProperties = new ArrayList(); if(domainModel.isPomInBuild()) { + String basedir = domainModel.getProjectDirectory().getAbsolutePath(); standardInterpolatorProperties.add(new InterpolatorProperty("${project.basedir}", basedir, PomInterpolatorTag.PROJECT_PROPERTIES.name() )); standardInterpolatorProperties.add(new InterpolatorProperty("${basedir}", basedir, @@ -621,7 +622,7 @@ public final class PomClassicTransformer //SECOND PASS - Set absolute paths on build directories if( domainModel.isPomInBuild() ) - { + { String basedir = domainModel.getProjectDirectory().getAbsolutePath(); Map buildDirectories = new HashMap(); for(ModelProperty mp : secondPassModelProperties) {