[MNG-3530] Adding a second integration test that shows how POM properties display a similarly locked-down behavior after initial POM interpolation...this even happens in 2.0.8, in the case of POM properties.

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@663339 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2008-06-04 18:49:07 +00:00
parent 97ccd08783
commit 110547eef7
17 changed files with 293 additions and 101 deletions

View File

@ -47,10 +47,38 @@ public class MavenITmng3530ChangedPathInterpolationTest
super( "(2.0.9,)" ); // only test in 2.0.9+
}
public void testitMNG3530 ()
public void testitMNG3530_BuildPath()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3530-changedPathInterpolation" );
File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3530-changedPathInterpolation/build-path" );
File pluginDir = new File( testDir, "plugin" );
File projectDir = new File( testDir, "project" );
// First, install the plugin that modifies the project.build.directory and
// validates that the modification propagated into the validation-mojo
// configuration. Once this is installed, we can run a project build that
// uses it to see how Maven will respond to a modification in the project build directory.
Verifier verifier = new Verifier( pluginDir.getAbsolutePath() );
verifier.executeGoal( "install" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
// Now, build the project. If the plugin configuration doesn't recognize
// the update to the project.build.directory, it will fail the build.
verifier = new Verifier( projectDir.getAbsolutePath() );
verifier.executeGoal( "package" );
verifier.verifyErrorFreeLog();
verifier.resetStreams();
}
public void testitMNG3530_POMProperty()
throws Exception
{
File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-3530-changedPathInterpolation/pom-property" );
File pluginDir = new File( testDir, "plugin" );
File projectDir = new File( testDir, "project" );

View File

@ -2,7 +2,7 @@
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3530</groupId>
<artifactId>plugin</artifactId>
<artifactId>build-path-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1</version>
<name>plugin Maven Mojo</name>

View File

@ -2,7 +2,7 @@
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.mng3530</groupId>
<artifactId>project</artifactId>
<artifactId>build-path-project</artifactId>
<packaging>jar</packaging>
<version>1</version>
<name>project</name>
@ -20,7 +20,7 @@
<plugins>
<plugin>
<groupId>org.apache.maven.its.mng3530</groupId>
<artifactId>plugin</artifactId>
<artifactId>build-path-maven-plugin</artifactId>
<version>1</version>
<executions>
<execution>

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.its.mng3530</groupId>
<artifactId>pom-property-maven-plugin</artifactId>
<packaging>maven-plugin</packaging>
<version>1</version>
<name>plugin Maven Mojo</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0.6</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,69 @@
package mng3530;
/*
* 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 org.apache.maven.plugin.Mojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
/**
* Modify the POM property myDirectory, contained in the current
* project instance. This and the corresponding {@link ValidatePropertyMojo} should
* prove or disprove the ability to have POM-property modifications ripple through
* the project's values, such as plugin configurations.
*
* @goal set
* @phase compile
*/
public class SetPropertyMojo
implements Mojo
{
public static final String MODIFIED_PROPERTY_VALUE = "modified";
/**
* Project instance to modify.
*
* @parameter default-value="${project}"
* @required
* @readonly
*/
private MavenProject project;
private Log log;
public void execute()
throws MojoExecutionException
{
getLog().info( "Before modification, myDirectory is: " + project.getProperties().getProperty( "myDirectory" ) );
project.getProperties().setProperty( "myDirectory", MODIFIED_PROPERTY_VALUE );
getLog().info( "After modification, myDirectory is: " + project.getProperties().getProperty( "myDirectory" ) );
getLog().info( "Modifications complete." );
}
public Log getLog()
{
return log;
}
public void setLog( Log log )
{
this.log = log;
}
}

View File

@ -0,0 +1,63 @@
package mng3530;
import org.apache.maven.plugin.Mojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
/**
* Validate that the POM property has been reset by the {@link SetPropertyMojo}.
*
* @goal validate
* @phase package
*/
public class ValidatePropertyMojo
implements Mojo
{
/**
* @parameter
*/
private String buildDirectory;
/**
* Project instance to validate.
*
* @parameter expression="${project}"
* @required
* @readonly
*/
private MavenProject project;
private Log log;
public void execute()
throws MojoExecutionException, MojoFailureException
{
getLog().info( "Validating buildDirectory parameter: " + buildDirectory );
String apiValue = project.getProperties().getProperty( "myDirectory" );
if ( !apiValue.equals( buildDirectory ) )
{
throw new MojoExecutionException( "buildDirectory parameter value:\n\n" + buildDirectory
+ "\n\ndoes not match ${myDirectory} from project:\n\n"
+ apiValue + "\n" );
}
else
{
getLog().info( "buildDirectory matches ${myDirectory} in the current POM instance." );
}
}
public Log getLog()
{
return log;
}
public void setLog( Log log )
{
this.log = log;
}
}

View File

@ -0,0 +1,49 @@
<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.mng3530</groupId>
<artifactId>pom-property-project</artifactId>
<packaging>jar</packaging>
<version>1</version>
<name>project</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<myDirectory>something</myDirectory>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.its.mng3530</groupId>
<artifactId>pom-property-maven-plugin</artifactId>
<version>1</version>
<executions>
<execution>
<id>set</id>
<goals>
<goal>set</goal>
</goals>
</execution>
<execution>
<id>validate</id>
<goals>
<goal>validate</goal>
</goals>
<configuration>
<buildDirectory>${myDirectory}</buildDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,13 @@
package tests;
/**
* Hello world!
*
*/
public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

View File

@ -0,0 +1,38 @@
package tests;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}

View File

@ -1,5 +0,0 @@
#Generated by Maven
#Tue Jun 03 18:23:15 EDT 2008
version=1
groupId=org.apache.maven.its.mng3530
artifactId=project

View File

@ -1,87 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuite errors="0" skipped="0" tests="1" time="0.017" failures="0" name="tests.AppTest">
<properties>
<property value="Apple Computer, Inc." name="java.vendor"/>
<property value="/Users/jdcasey/.m2/repository" name="localRepository"/>
<property value="SUN_STANDARD" name="sun.java.launcher"/>
<property value="a854b0" name="env.SECURITYSESSIONID"/>
<property value="Mac OS X" name="os.name"/>
<property value="/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/classes.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/ui.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/laf.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/sunrsasign.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/jsse.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/jce.jar:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Classes/charsets.jar" name="sun.boot.class.path"/>
<property value="/Users/jdcasey/workspace/maven/core-integration-testing/mng-3530/src/test/resources/mng-3530-changedPathInterpolation/project" name="env.PWD"/>
<property value="" name="sun.java2d.fontpath"/>
<property value="Sun Microsystems Inc." name="java.vm.specification.vendor"/>
<property value="1.4.2_16-b05-303" name="java.runtime.version"/>
<property value="jdcasey" name="user.name"/>
<property value="jdcasey" name="env.USER"/>
<property value="/bin/bash" name="env.SHELL"/>
<property value="0x1F5:0:0" name="env.__CF_USER_TEXT_ENCODING"/>
<property value="true" name="awt.nativeDoubleBuffering"/>
<property value="/Users/jdcasey/apps/maven/apache-maven-2.0.9/bin:/Users/jdcasey/bin:/Users/jdcasey/apps/amazonws/current-ec2/bin:/usr/local/bin:/usr/local/sbin:/sbin:/usr/sbin:/sw/bin:/sw/sbin:/usr/local/graphviz-2.14/bin:/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin:/usr/X11R6/bin" name="env.PATH"/>
<property value="en" name="user.language"/>
<property value="/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Libraries" name="sun.boot.library.path"/>
<property value="/Users/jdcasey/apps/maven/apache-maven-2.0.9/bin/m2.conf" name="classworlds.conf"/>
<property value="1.4.2_16" name="java.version"/>
<property value="America/New_York" name="user.timezone"/>
<property value="32" name="sun.arch.data.model"/>
<property value="/Users/jdcasey/apps/amazonws/current-ec2" name="env.EC2_HOME"/>
<property value="/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/lib/endorsed" name="java.endorsed.dirs"/>
<property value="" name="sun.cpu.isalist"/>
<property value="sun.io" name="file.encoding.pkg"/>
<property value="2" name="env.SHLVL"/>
<property value="/" name="file.separator"/>
<property value="Java Platform API Specification" name="java.specification.name"/>
<property value="48.0" name="java.class.version"/>
<property value="US" name="user.country"/>
<property value="/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home" name="java.home"/>
<property value="mixed mode" name="java.vm.info"/>
<property value="2.0.9" name="env.MAVEN_VERSION"/>
<property value="jdcasey" name="env.LOGNAME"/>
<property value="10.4.11" name="os.version"/>
<property value=":" name="path.separator"/>
<property value="1.4.2-86" name="java.vm.version"/>
<property value="java.util.prefs.MacOSXPreferencesFactory" name="java.util.prefs.PreferencesFactory"/>
<property value="/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home" name="env.JAVA_HOME"/>
<property value="apple.awt.CPrinterJob" name="java.awt.printerjob"/>
<property value="linux" name="env.TERM"/>
<property value="UnicodeLittle" name="sun.io.unicode.encoding"/>
<property value="apple.awt.CToolkit" name="awt.toolkit"/>
<property value="/usr/local/share/man:/usr/share/man:/sw/share/man:/usr/local/graphviz-2.14/share/man:/usr/X11R6/man:/sw/lib/perl5/5.8.6/man" name="env.MANPATH"/>
<property value="/Users/jdcasey" name="user.home"/>
<property value="Sun Microsystems Inc." name="java.specification.vendor"/>
<property value="org.codehaus.classworlds.Launcher" name="env.JAVA_MAIN_CLASS_1404"/>
<property value="iTerm.app" name="env.TERM_PROGRAM"/>
<property value="/Users/jdcasey/.ec2/cert-LITFAREZRVZT2AQ6GFBVWKS22VHYCLDJ.pem" name="env.EC2_CERT"/>
<property value="/Users/jdcasey/apps/maven/apache-maven-2.0.9" name="env.M2_HOME"/>
<property value=".:/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java" name="java.library.path"/>
<property value="http://apple.com/" name="java.vendor.url"/>
<property value="&quot;Apple Computer, Inc.&quot;" name="java.vm.vendor"/>
<property value="false" name="gopherProxySet"/>
<property value="/Users/jdcasey/.ec2/pk-LITFAREZRVZT2AQ6GFBVWKS22VHYCLDJ.pem" name="env.EC2_PRIVATE_KEY"/>
<property value="/Users/jdcasey/apps/maven/apache-maven-2.0.9" name="maven.home"/>
<property value="Java(TM) 2 Runtime Environment, Standard Edition" name="java.runtime.name"/>
<property value="/Users/jdcasey/apps/maven/apache-maven-2.0.9/boot/classworlds-1.1.jar" name="java.class.path"/>
<property value="ssh" name="env.CVS_RSH"/>
<property value="Java Virtual Machine Specification" name="java.vm.specification.name"/>
<property value="1.0" name="java.vm.specification.version"/>
<property value="little" name="sun.cpu.endian"/>
<property value="unknown" name="sun.os.patch.level"/>
<property value="/Users/jdcasey" name="env.HOME"/>
<property value="/Users/jdcasey/workspace/maven/core-integration-testing/mng-3530/src/test/resources/mng-3530-changedPathInterpolation/project/target/test-classes:/Users/jdcasey/workspace/maven/core-integration-testing/mng-3530/src/test/resources/mng-3530-changedPathInterpolation/project/target/classes:/Users/jdcasey/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar:" name="surefire.test.class.path"/>
<property value="/tmp" name="java.io.tmpdir"/>
<property value="http://developer.apple.com/java/" name="java.vendor.url.bug"/>
<property value="i386" name="os.arch"/>
<property value="apple.awt.CGraphicsEnvironment" name="java.awt.graphicsenv"/>
<property value="/Library/Java/Extensions:/System/Library/Java/Extensions:/System/Library/Frameworks/JavaVM.framework/Versions/1.4.2/Home/lib/ext" name="java.ext.dirs"/>
<property value="/sw/lib/perl5:/sw/lib/perl5/darwin" name="env.PERL5LIB"/>
<property value="/Users/jdcasey/workspace/maven/core-integration-testing/mng-3530/src/test/resources/mng-3530-changedPathInterpolation/project" name="user.dir"/>
<property value="b05-303" name="mrj.version"/>
<property value="/sw/share/info:/sw/info:/usr/share/info" name="env.INFOPATH"/>
<property value="
" name="line.separator"/>
<property value="Java HotSpot(TM) Client VM" name="java.vm.name"/>
<property value="/Users/jdcasey/workspace/maven/core-integration-testing/mng-3530/src/test/resources/mng-3530-changedPathInterpolation/project" name="basedir"/>
<property value="MacRoman" name="file.encoding"/>
<property value="1.4" name="java.specification.version"/>
</properties>
<testcase classname="tests.AppTest" time="0.002" name="testApp"/>
</testsuite>

View File

@ -1,4 +0,0 @@
-------------------------------------------------------------------------------
Test set: tests.AppTest
-------------------------------------------------------------------------------
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.027 sec