o Decoupled from production plugins

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@750850 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2009-03-06 11:24:19 +00:00
parent 0f015a5254
commit d3db081c33
4 changed files with 23 additions and 88 deletions

View File

@ -20,6 +20,7 @@ package org.apache.maven.it;
*/
import java.io.File;
import java.util.Properties;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
@ -45,20 +46,17 @@ public class MavenITmng3747PrefixedPathExpressionTest
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3747" );
File pluginDir = new File( testDir, "maven-mng3747-plugin" );
File projectDir = new File( testDir, "project" );
Verifier verifier;
verifier = new Verifier( pluginDir.getAbsolutePath() );
verifier.executeGoal( "install" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
verifier = new Verifier( projectDir.getAbsolutePath() );
Verifier verifier = new Verifier( testDir.getAbsolutePath() );
verifier.setAutoclean( false );
verifier.deleteDirectory( "target" );
verifier.executeGoal( "validate" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
Properties props = verifier.loadProperties( "target/config.properties" );
assertEquals( "path is: " + new File( testDir, "relative" ).getAbsolutePath() + "/somepath",
props.getProperty( "stringParam" ) );
}
}

View File

@ -1,16 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?><project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3747</groupId>
<artifactId>maven-mng3747-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>maven-mng3747-plugin Maven Mojo</name>
<version>1</version>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</project>

View File

@ -1,56 +0,0 @@
package jar;
/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.File;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
/**
* @goal test
*/
public class MyMojo
extends AbstractMojo
{
/**
* Location of the file.
* @parameter default-value="${project.build.directory}"
* @readonly
*/
private File buildDirectory;
/**
* @parameter
* @required
*/
private String config;
public void execute()
throws MojoExecutionException
{
if ( !buildDirectory.isAbsolute() )
{
throw new MojoExecutionException( "The expression 'project.build.directory' didn't render an absolute path when injected from a plugin parameter default value." );
}
if ( config.indexOf( buildDirectory.getAbsolutePath() ) < 0 )
{
throw new MojoExecutionException( "The expression 'project.build.directory' didn't render an absolute path when used inside a plugin configuration of type String." );
}
}
}

View File

@ -1,27 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<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.mng3747</groupId>
<artifactId>project</artifactId>
<version>1</version>
<packaging>pom</packaging>
<name>Maven Integration Test :: MNG-3747</name>
<description>
Test that expressions prefixed with "project.|pom." that reference build paths which are given as relative paths
in the POM are still interpolated with absolute paths when used in String-type plugin parameters.
</description>
<build>
<!-- NOTE: Intentionally a relative path! -->
<directory>relative</directory>
<plugins>
<plugin>
<groupId>org.apache.maven.its.mng3747</groupId>
<artifactId>maven-mng3747-plugin</artifactId>
<version>1</version>
<groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-configuration</artifactId>
<version>2.1-SNAPSHOT</version>
<executions>
<execution>
<id>test</id>
<phase>validate</phase>
<goals>
<goal>test</goal>
<goal>config</goal>
</goals>
<configuration>
<config>path is: ${project.build.directory}/somepath</config>
<propertiesFile>target/config.properties</propertiesFile>
<stringParam>path is: ${project.build.directory}/somepath</stringParam>
</configuration>
</execution>
</executions>