Adding plexus-interpolation to the POM and build.xml/.properties, to prepare for the fix to MNG-3355 and MNG-2339(a)...also adding a new embedder-driven integration-test project to eventually hold the error-reporting tests currently in the maven-embedder tests.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@644352 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-04-03 15:13:24 +00:00
parent 30ea33aefb
commit 05e92de35e
7 changed files with 178 additions and 1 deletions

View File

@ -21,7 +21,8 @@ retrotranslator.version=1.2.1
backport.version=3.0
classworlds.version=1.2-alpha-10
plexus.version=1.0-alpha-44
plexus-utils.version=1.4.5
plexus-utils.version=1.5.2-SNAPSHOT
plexus-interpolation.version=1.0-SNAPSHOT
maven-artifact.version=3.0-SNAPSHOT
commons-cli.version=1.0
wagon.version=1.0-beta-2

View File

@ -120,6 +120,7 @@ under the License.
<pull orgpath="backport-util-concurrent/backport-util-concurrent" version="${backport.version}" name="backport-util-concurrent"/>
<pull orgpath="commons-cli/commons-cli" version="${commons-cli.version}" name="commons-cli"/>
<pull orgpath="org/codehaus/plexus/plexus-utils" version="${plexus-utils.version}" name="plexus-utils" repository="codehaus"/>
<pull orgpath="org/codehaus/plexus/plexus-interpolation" version="${plexus-interpolation.version}" name="plexus-interpolation" repository="codehaus"/>
<pull orgpath="org/codehaus/plexus/plexus-container-default" version="${plexus.version}" name="plexus-container-default" repository="codehaus"/>
<pull orgpath="org/codehaus/plexus/plexus-classworlds" version="${classworlds.version}" name="plexus-classworlds" repository="codehaus"/>
<pull orgpath="org/apache/maven/maven-parent" version="4" name="maven-parent" type="pom"/>
@ -149,6 +150,7 @@ under the License.
<pathelement location="${maven.repo.local}/commons-cli/commons-cli/${commons-cli.version}/commons-cli-${commons-cli.version}.jar"/>
<pathelement location="${maven.repo.local}/commons-lang/commons-lang/${commons-lang.version}/commons-lang-${commons-lang.version}.jar"/>
<pathelement location="${maven.repo.local}/org/codehaus/plexus/plexus-utils/${plexus-utils.version}/plexus-utils-${plexus-utils.version}.jar"/>
<pathelement location="${maven.repo.local}/org/codehaus/plexus/plexus-interpolation/${plexus-interpolation.version}/plexus-interpolation-${plexus-interpolation.version}.jar"/>
<pathelement location="${maven.repo.local}/org/codehaus/plexus/plexus-container-default/${plexus.version}/plexus-container-default-${plexus.version}.jar"/>
<pathelement location="${maven.repo.local}/org/codehaus/plexus/plexus-classworlds/${classworlds.version}/plexus-classworlds-${classworlds.version}.jar"/>
<pathelement location="${maven.repo.local}/org/codehaus/plexus/plexus-interactivity-api/${plexus-interactivity-api.version}/plexus-interactivity-api-${plexus-interactivity-api.version}.jar"/>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<parent>
<groupId>org.apache.maven</groupId>
<artifactId>maven</artifactId>
<version>2.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-embedder-integration-tests</artifactId>
<name>Integration Tests for Maven Embedder</name>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>2.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,112 @@
package org.apache.maven.embedder.its;
import org.apache.maven.embedder.Configuration;
import org.apache.maven.embedder.DefaultConfiguration;
import org.apache.maven.embedder.MavenEmbedder;
import org.apache.maven.embedder.MavenEmbedderConsoleLogger;
import org.apache.maven.embedder.MavenEmbedderLogger;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.FileUtils;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
public class MNG3355Test
extends PlexusTestCase
{
protected String basedir;
protected MavenEmbedder maven;
protected void setUp()
throws Exception
{
super.setUp();
basedir = System.getProperty( "basedir" );
if ( basedir == null )
{
basedir = new File( "." ).getCanonicalPath();
}
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
Configuration configuration = new DefaultConfiguration()
.setClassLoader( classLoader )
.setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
maven = new MavenEmbedder( configuration );
}
protected void tearDown()
throws Exception
{
maven.stop();
}
protected void assertNoExceptions( MavenExecutionResult result )
{
List exceptions = result.getExceptions();
if ( ( exceptions == null ) || exceptions.isEmpty() )
{
// everything is a-ok.
return;
}
System.err.println( "Encountered " + exceptions.size() + " exception(s)." );
Iterator it = exceptions.iterator();
while ( it.hasNext() )
{
Exception exception = (Exception) it.next();
exception.printStackTrace( System.err );
}
fail( "Encountered Exceptions in MavenExecutionResult during " + getName() );
}
public void testMNG_3355()
throws Exception
{
File targetDirectory = getProjectDirectory( "mng-3355" );
List goals = new ArrayList();
goals.add( "clean" );
goals.add( "validate" );
Properties userProperties = new Properties();
userProperties.setProperty( "version", "foo" );
MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( targetDirectory )
.setLoggingLevel( MavenEmbedderLogger.LEVEL_DEBUG )
.setUserProperties( userProperties )
.setGoals( goals );
MavenExecutionResult result = maven.execute( request );
assertNoExceptions( result );
// MavenProject project = result.getProject();
}
private File getProjectDirectory( String projectPath )
throws IOException
{
File testDirectory = new File( basedir, "src/test/projects/" + projectPath );
File targetDirectory = new File( basedir, "target/projects/" + projectPath );
FileUtils.copyDirectoryStructure( testDirectory, targetDirectory );
return targetDirectory;
}
}

View File

@ -0,0 +1,25 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng2339</groupId>
<artifactId>translated-path-property-expression-interpolation</artifactId>
<version>1</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-project-interpolation</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>check-property</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<myDirectory>${project.build.directory}/foo</myDirectory>
</properties>
</project>

View File

@ -0,0 +1,5 @@
Verifies that references to ${project.build.directory} are interpolated with absolute path values, even when referenced in places that the pathTranslator doesn't touch, like properties. Simply run:
mvn validate
to see this test work. The maven-it-plugin-project-interpolation does the rest, verifying that the <myDirectory/> property has been interpolated to the result of ${project.build.directory}/foo.

View File

@ -244,6 +244,11 @@ under the License.
<artifactId>plexus-utils</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interpolation</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
@ -361,6 +366,7 @@ under the License.
<profile>
<id>run-its</id>
<modules>
<module>maven-embedder-integration-tests</module>
<module>maven-core-it-runner</module>
</modules>
</profile>