Author: jvanzyl
Date: Mon Jan 9 17:45:00 2006
New Revision: 367457
URL: http://svn.apache.org/viewcvs?rev=367457&view=rev
Log:
[MNG-1927] Fixing the ${pom.build.directory} path translation and interpolation
so that an absolute path
is rendered.
Added:
maven/components/trunk/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/InterpolatedPomConfigurationMojo.java
(with props)
Modified:
maven/components/trunk/maven-core-it/it0088/pom.xml
maven/components/trunk/maven-core-it/it0088/src/test/java/org/apache/maven/it0088/PomInterpolationTest.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
Added:
maven/components/trunk/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/InterpolatedPomConfigurationMojo.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/InterpolatedPomConfigurationMojo.java?rev=367457&view=auto
==============================================================================
---
maven/components/trunk/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/InterpolatedPomConfigurationMojo.java
(added)
+++
maven/components/trunk/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/InterpolatedPomConfigurationMojo.java
Mon Jan 9 17:45:00 2006
@@ -0,0 +1,47 @@
+package org.apache.maven.plugin.coreit;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.util.Properties;
+import java.io.FileOutputStream;
+import java.io.File;
+
+/**
+ * Take some configuration values that use interpolated POM values and write
them to a properties file
+ * to make sure they are passing through the system properly. We have reports
(MNG-1927) that we're
+ *
+ * @goal generate-properties
+ */
+public class InterpolatedPomConfigurationMojo
+ extends AbstractMojo
+{
+ /**
+ * @parameter expression="${basedir}"
+ */
+ private String basedir;
+
+ /**
+ * @parameter expression="${project.build.directory}"
+ */
+ private String projectBuildDirectory;
+
+ public void execute()
+ throws MojoExecutionException
+ {
+ try
+ {
+ Properties mojoGeneratedPropeties = new Properties();
+
+ mojoGeneratedPropeties.put( "project.build.directory",
projectBuildDirectory );
+
+ FileOutputStream fos = new FileOutputStream( new File( basedir,
"target/mojo-generated.properties" ) );
+
+ mojoGeneratedPropeties.store( fos, "# Properties generated by the
execution of a mojo that uses interpolated POM values for configuration." );
+ }
+ catch( Exception e )
+ {
+ getLog().error( "Error creating mojo generated properties.", e );
+ }
+ }
+}
Propchange:
maven/components/trunk/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/InterpolatedPomConfigurationMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/components/trunk/integration-tests/maven-core-it-plugin/src/main/java/org/apache/maven/plugin/coreit/InterpolatedPomConfigurationMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/components/trunk/maven-core-it/it0088/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0088/pom.xml?rev=367457&r1=367456&r2=367457&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/it0088/pom.xml (original)
+++ maven/components/trunk/maven-core-it/it0088/pom.xml Mon Jan 9 17:45:00 2006
@@ -19,5 +19,22 @@
<filtering>true</filtering>
</resource>
</resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-core-it-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>process-resources</phase>
+ <configuration>
+ <pomBuildDirectory>${pom.build.directory}</pomBuildDirectory>
+ </configuration>
+ <goals>
+ <goal>generate-properties</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
</project>
Modified:
maven/components/trunk/maven-core-it/it0088/src/test/java/org/apache/maven/it0088/PomInterpolationTest.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0088/src/test/java/org/apache/maven/it0088/PomInterpolationTest.java?rev=367457&r1=367456&r2=367457&view=diff
==============================================================================
---
maven/components/trunk/maven-core-it/it0088/src/test/java/org/apache/maven/it0088/PomInterpolationTest.java
(original)
+++
maven/components/trunk/maven-core-it/it0088/src/test/java/org/apache/maven/it0088/PomInterpolationTest.java
Mon Jan 9 17:45:00 2006
@@ -17,12 +17,28 @@
basedir = System.getProperty( "basedir" );
}
- public void testProjectBuildDirectory()
+ public void testProjectBuildDirectoryAfterResourceFiltering()
throws Exception
{
Properties testProperties = new Properties();
File testPropertiesFile = new File( basedir,
"target/classes/test.properties" );
+
+ assertTrue( testPropertiesFile.exists() );
+
+ testProperties.load( new FileInputStream( testPropertiesFile ) );
+
+ File projectBuildDirectory = new File( basedir, "target" );
+
+ assertEquals( testProperties.getProperty( "project.build.directory" ),
projectBuildDirectory.getAbsolutePath() );
+ }
+
+ public void testProjectBuildDirectoryAfterForMojoExecution()
+ throws Exception
+ {
+ Properties testProperties = new Properties();
+
+ File testPropertiesFile = new File( basedir,
"target/mojo-generated.properties" );
assertTrue( testPropertiesFile.exists() );
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=367457&r1=367456&r2=367457&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Mon Jan 9 17:45:00 2006
@@ -722,6 +722,43 @@
context.put( "basedir", projectDir.getAbsolutePath() );
}
+ //
----------------------------------------------------------------------
+ // We need to translate the paths before interpolation so that things
+ // like this:
+ //
+ //<project>
+ // ...
+ // <build>
+ // <plugins>
+ // <plugin>
+ // <groupId>org.apache.maven.plugins</groupId>
+ // <artifactId>maven-core-it-plugin</artifactId>
+ // <executions>
+ // <execution>
+ // <phase>process-resources</phase>
+ // <configuration>
+ //
<pomBuildDirectory>${pom.build.directory}</pomBuildDirectory>
+ // </configuration>
+ // <goals>
+ // <goal>generate-properties</goal>
+ // </goals>
+ // </execution>
+ // </executions>
+ // </plugin>
+ // </plugins>
+ // </build>
+ //</project>
+ //
+ // Are handled correctly where the ${pom.build.directory} must be path
+ // translated in the POM first. So in the Super POM the
${pom.build.directory}
+ // will get shifted to /some/absolute/path/target and then during the
+ // interpolation phase the <pomBuildDirectory/> element up thre will
+ // have the ${pom.build.directory} string swapped out and replaced with
+ // /some/absolute/path/target. [MNG-1927]
+ //
----------------------------------------------------------------------
+
+ pathTranslator.alignToBaseDirectory( project.getModel(), projectDir );
+
model = modelInterpolator.interpolate( model, context, strict );
// interpolation is before injection, because interpolation is
off-limits in the injected variables
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java?rev=367457&r1=367456&r2=367457&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
(original)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/path/DefaultPathTranslator.java
Mon Jan 9 17:45:00 2006
@@ -80,7 +80,7 @@
if ( requiresBaseDirectoryAlignment( s ) )
{
- s = new File( basedir, s ).getPath();
+ s = new File( basedir, s ).getAbsolutePath();
}
return s;