mirror of https://github.com/apache/maven.git
add integration test for parent.getBasedir()
could be used for other such tests in future git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@280305 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ded92e5e2a
commit
400a15c700
|
@ -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
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
it0065
|
||||
it0064
|
||||
it0063
|
||||
it0062
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
subproject/target/child-basedir
|
||||
target/parent-basedir
|
|
@ -0,0 +1 @@
|
|||
install
|
|
@ -0,0 +1,34 @@
|
|||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.maven.it</groupId>
|
||||
<artifactId>maven-core-it0065</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<artifactId>maven-it0065-plugin</artifactId>
|
||||
<packaging>maven-plugin</packaging>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>2.0-beta-1-SNAPSHOT</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<name>Test Repository</name>
|
||||
<url>file:/tmp/testRepo</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</project>
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<model>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.it</groupId>
|
||||
<artifactId>maven-core-it0065</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<type>jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<modules>
|
||||
<module>plugin</module>
|
||||
<module>subproject</module>
|
||||
</modules>
|
||||
</model>
|
|
@ -0,0 +1,28 @@
|
|||
<model>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache.maven.it</groupId>
|
||||
<artifactId>maven-core-it0065</artifactId>
|
||||
<version>1.0</version>
|
||||
</parent>
|
||||
<artifactId>maven-core-it0065-subproject</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.0</version>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.it</groupId>
|
||||
<artifactId>maven-it0065-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>test-basedir</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</model>
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
name = jason
|
|
@ -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() );
|
||||
}
|
||||
}
|
|
@ -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() );
|
||||
}
|
||||
}
|
|
@ -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() );
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue