diff --git a/maven-core-it/README.txt b/maven-core-it/README.txt index 855f30ce06..fa9e7e5162 100644 --- a/maven-core-it/README.txt +++ b/maven-core-it/README.txt @@ -183,6 +183,8 @@ it0063: Test the use of a system scoped dependency to tools.jar. it0064: Test the use of a mojo that uses setters instead of private fields for the population of configuration values. +it0065: Test that the basedir of the parent is set correctly. + ------------------------------------------------------------------------------- - generated sources diff --git a/maven-core-it/integration-tests.txt b/maven-core-it/integration-tests.txt index 75c5654375..3420e8f56b 100644 --- a/maven-core-it/integration-tests.txt +++ b/maven-core-it/integration-tests.txt @@ -1,3 +1,4 @@ +it0065 it0064 it0063 it0062 diff --git a/maven-core-it/it0065/expected-results.txt b/maven-core-it/it0065/expected-results.txt new file mode 100644 index 0000000000..c7570658f5 --- /dev/null +++ b/maven-core-it/it0065/expected-results.txt @@ -0,0 +1,2 @@ +subproject/target/child-basedir +target/parent-basedir diff --git a/maven-core-it/it0065/goals.txt b/maven-core-it/it0065/goals.txt new file mode 100644 index 0000000000..7c32f55981 --- /dev/null +++ b/maven-core-it/it0065/goals.txt @@ -0,0 +1 @@ +install diff --git a/maven-core-it/it0065/plugin/pom.xml b/maven-core-it/it0065/plugin/pom.xml new file mode 100644 index 0000000000..64b67d5954 --- /dev/null +++ b/maven-core-it/it0065/plugin/pom.xml @@ -0,0 +1,34 @@ + + 4.0.0 + + org.apache.maven.it + maven-core-it0065 + 1.0 + + maven-it0065-plugin + maven-plugin + 1.0-SNAPSHOT + + + org.apache.maven + maven-plugin-api + 2.0-beta-1-SNAPSHOT + jar + compile + + + junit + junit + 3.8.1 + jar + test + + + + + central + Test Repository + file:/tmp/testRepo + + + diff --git a/maven-core-it/it0065/plugin/src/main/java/org/apache/maven/plugin/coreit/TestBasedirMojo.java b/maven-core-it/it0065/plugin/src/main/java/org/apache/maven/plugin/coreit/TestBasedirMojo.java new file mode 100644 index 0000000000..6c9ed94f62 --- /dev/null +++ b/maven-core-it/it0065/plugin/src/main/java/org/apache/maven/plugin/coreit/TestBasedirMojo.java @@ -0,0 +1,76 @@ +package org.apache.maven.plugin.coreit; + +/* + * Copyright 2001-2004 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.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; + +/** + * @goal test-basedir + * @phase compile + */ +public class TestBasedirMojo + extends AbstractMojo +{ + private static final int DELETE_RETRY_SLEEP_MILLIS = 10; + + /** + * @parameter expression="${basedir}/target/child-basedir" + * @required + */ + private String childBasedir; + + /** + * @parameter expression="${project.parent.basedir}/target/parent-basedir" + * @required + */ + private String parentBasedir; + + public void execute() + throws MojoExecutionException + { + write( new File( childBasedir ) ); + + write( new File( parentBasedir ) ); + } + + private void write( File f ) + throws MojoExecutionException + { + if ( !f.getParentFile().exists() ) + { + f.getParentFile().mkdirs(); + } + + try + { + FileWriter w = new FileWriter( f ); + + w.write( f.getPath() ); + + w.close(); + } + catch ( IOException e ) + { + throw new MojoExecutionException( "Error writing verification file.", e ); + } + } +} diff --git a/maven-core-it/it0065/pom.xml b/maven-core-it/it0065/pom.xml new file mode 100644 index 0000000000..4dd9807b1b --- /dev/null +++ b/maven-core-it/it0065/pom.xml @@ -0,0 +1,21 @@ + + 4.0.0 + org.apache.maven.it + maven-core-it0065 + pom + 1.0 + + + junit + junit + 3.8.1 + jar + test + + + + + plugin + subproject + + diff --git a/maven-core-it/it0065/subproject/pom.xml b/maven-core-it/it0065/subproject/pom.xml new file mode 100644 index 0000000000..5678f2f109 --- /dev/null +++ b/maven-core-it/it0065/subproject/pom.xml @@ -0,0 +1,28 @@ + + 4.0.0 + + org.apache.maven.it + maven-core-it0065 + 1.0 + + maven-core-it0065-subproject + jar + 1.0 + + + + + org.apache.maven.it + maven-it0065-plugin + 1.0-SNAPSHOT + + + + test-basedir + + + + + + + diff --git a/maven-core-it/it0065/subproject/src/main/java/org/apache/maven/it0001/Person.java b/maven-core-it/it0065/subproject/src/main/java/org/apache/maven/it0001/Person.java new file mode 100644 index 0000000000..613e499ae0 --- /dev/null +++ b/maven-core-it/it0065/subproject/src/main/java/org/apache/maven/it0001/Person.java @@ -0,0 +1,16 @@ +package org.apache.maven.it0001; + +public class Person +{ + private String name; + + public void setName( String name ) + { + this.name = name; + } + + public String getName() + { + return name; + } +} diff --git a/maven-core-it/it0065/subproject/src/main/resources/it0001.properties b/maven-core-it/it0065/subproject/src/main/resources/it0001.properties new file mode 100644 index 0000000000..f54f8ab106 --- /dev/null +++ b/maven-core-it/it0065/subproject/src/main/resources/it0001.properties @@ -0,0 +1 @@ +name = jason diff --git a/maven-core-it/it0065/subproject/src/test/java/org/apache/maven/it0001/PersonTest.java b/maven-core-it/it0065/subproject/src/test/java/org/apache/maven/it0001/PersonTest.java new file mode 100644 index 0000000000..80014fa03b --- /dev/null +++ b/maven-core-it/it0065/subproject/src/test/java/org/apache/maven/it0001/PersonTest.java @@ -0,0 +1,16 @@ +package org.apache.maven.it0001; + +import junit.framework.TestCase; + +public class PersonTest + extends TestCase +{ + public void testPerson() + { + Person person = new Person(); + + person.setName( "foo" ); + + assertEquals( "foo", person.getName() ); + } +} diff --git a/maven-core-it/it0065/subproject/src/test/java/org/apache/maven/it0001/PersonThreeTest.java b/maven-core-it/it0065/subproject/src/test/java/org/apache/maven/it0001/PersonThreeTest.java new file mode 100644 index 0000000000..f1b23a1f41 --- /dev/null +++ b/maven-core-it/it0065/subproject/src/test/java/org/apache/maven/it0001/PersonThreeTest.java @@ -0,0 +1,16 @@ +package org.apache.maven.it0001; + +import junit.framework.TestCase; + +public class PersonThreeTest + extends TestCase +{ + public void testPerson() + { + Person person = new Person(); + + person.setName( "foo" ); + + assertEquals( "foo", person.getName() ); + } +} diff --git a/maven-core-it/it0065/subproject/src/test/java/org/apache/maven/it0001/PersonTwoTest.java b/maven-core-it/it0065/subproject/src/test/java/org/apache/maven/it0001/PersonTwoTest.java new file mode 100644 index 0000000000..ccec93c557 --- /dev/null +++ b/maven-core-it/it0065/subproject/src/test/java/org/apache/maven/it0001/PersonTwoTest.java @@ -0,0 +1,16 @@ +package org.apache.maven.it0001; + +import junit.framework.TestCase; + +public class PersonTwoTest + extends TestCase +{ + public void testPerson() + { + Person person = new Person(); + + person.setName( "foo" ); + + assertEquals( "foo", person.getName() ); + } +}