mirror of https://github.com/apache/maven.git
Merging from 2.0.x branch, revIds:
- 391163:391165 - 391167 - 391176 - 391202 - 391326 - 391328:391329 - 391398 - 391402 - 391404 These are the changes for the 2.0.4 RC's. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@391687 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
df10b7e556
commit
f810fd2ef2
|
@ -277,6 +277,14 @@ it0101: Test that properties defined in an active profile in the user's
|
||||||
it0102: Test that <activeByDefault/> calculations for profile activation only
|
it0102: Test that <activeByDefault/> calculations for profile activation only
|
||||||
use profiles defined in the POM. [MNG-2136]
|
use profiles defined in the POM. [MNG-2136]
|
||||||
|
|
||||||
|
it0103: Verify that multimodule builds where one project references another as
|
||||||
|
a parent can build, even if that parent is not correctly referenced by
|
||||||
|
<relativePath/> and is not in the local repository. [MNG-2196]
|
||||||
|
|
||||||
|
it0104: Verify that plugin configurations are resolved correctly, particularly
|
||||||
|
when they contain ${project.build.directory} in the string value of a
|
||||||
|
Map.Entry.
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
- generated sources
|
- generated sources
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
#it0104 Commenting out, not fixed until post-2.0.4, due to dependency on new plexus-container-default version.
|
||||||
|
it0103
|
||||||
it0102
|
it0102
|
||||||
it0101
|
it0101
|
||||||
it0100
|
it0100
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
-DgroupId=org.someproject "-DartifactId=test project"
|
-Dtest.property="Test Property"
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
test project/pom.xml
|
|
|
@ -1 +1 @@
|
||||||
archetype:create
|
test
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
<project>
|
<project>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.apache.maven.it0098</groupId>
|
<groupId>org.apache.maven.it0098</groupId>
|
||||||
<artifactId>it0098-archetype-orchestration-test</artifactId>
|
<artifactId>it0098</artifactId>
|
||||||
<version>1</version>
|
<version>1</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package org.apache.maven.it.it0098;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
public class QuotedCLIPropertyTest
|
||||||
|
extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
public void testPropertyValue()
|
||||||
|
{
|
||||||
|
assertEquals( "Test Property", System.getProperty( "test.property" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1 +0,0 @@
|
||||||
failOnErrorOutput=false
|
|
|
@ -0,0 +1 @@
|
||||||
|
package
|
|
@ -0,0 +1,12 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.maven.it0103</groupId>
|
||||||
|
<artifactId>level1</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
</parent>
|
||||||
|
<groupId>org.apache.maven.it0103</groupId>
|
||||||
|
<artifactId>level3</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,14 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.maven.it0103</groupId>
|
||||||
|
<artifactId>level1</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>level2</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>level3</module>
|
||||||
|
</modules>
|
||||||
|
</project>
|
|
@ -0,0 +1,14 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.apache.maven.it0103</groupId>
|
||||||
|
<artifactId>root</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>level1</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>level2</module>
|
||||||
|
</modules>
|
||||||
|
</project>
|
|
@ -0,0 +1,11 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>org.apache.maven.it0103</groupId>
|
||||||
|
<artifactId>root</artifactId>
|
||||||
|
<version>1</version>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>level1</module>
|
||||||
|
</modules>
|
||||||
|
</project>
|
|
@ -0,0 +1 @@
|
||||||
|
test
|
|
@ -0,0 +1,36 @@
|
||||||
|
<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.it</groupId>
|
||||||
|
<artifactId>it0104</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>Maven Quick Start Archetype</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>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<!-- pluginManagement -->
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<systemProperties>
|
||||||
|
<property>
|
||||||
|
<name>target.dir</name>
|
||||||
|
<value>${project.build.directory}</value>
|
||||||
|
</property>
|
||||||
|
</systemProperties>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<!-- /pluginManagement -->
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,13 @@
|
||||||
|
package org.apache.maven.it;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hello world!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
System.out.println( "Hello World!" );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package org.apache.maven.it;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unit test for simple App.
|
||||||
|
*/
|
||||||
|
public class AppTest
|
||||||
|
extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Rigourous Test :-)
|
||||||
|
*/
|
||||||
|
public void testApp()
|
||||||
|
{
|
||||||
|
|
||||||
|
String targetDir = System.getProperty( "target.dir" );
|
||||||
|
|
||||||
|
System.out.println( "Got 'target.dir' of: '" + targetDir + "'" );
|
||||||
|
|
||||||
|
assertNotNull( "System property 'target.dir' is not present.", targetDir );
|
||||||
|
assertTrue( "System property 'target.dir' was not resolved correctly.", targetDir.indexOf( "${" ) < 0 );
|
||||||
|
}
|
||||||
|
}
|
|
@ -152,7 +152,9 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
private ModelValidator validator;
|
private ModelValidator validator;
|
||||||
|
|
||||||
private Map projectCache = new HashMap();
|
private Map rawProjectCache = new HashMap();
|
||||||
|
|
||||||
|
private Map processedProjectCache = new HashMap();
|
||||||
|
|
||||||
// TODO: make it a component
|
// TODO: make it a component
|
||||||
private MavenXpp3Reader modelReader;
|
private MavenXpp3Reader modelReader;
|
||||||
|
@ -213,7 +215,7 @@ public class DefaultMavenProjectBuilder
|
||||||
{
|
{
|
||||||
String cacheKey = createCacheKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
|
String cacheKey = createCacheKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
|
||||||
|
|
||||||
MavenProject project = (MavenProject) projectCache.get( cacheKey );
|
MavenProject project = (MavenProject) processedProjectCache.get( cacheKey );
|
||||||
|
|
||||||
if ( project != null )
|
if ( project != null )
|
||||||
{
|
{
|
||||||
|
@ -685,6 +687,8 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
project.setOriginalModel( originalModel );
|
project.setOriginalModel( originalModel );
|
||||||
|
|
||||||
|
rawProjectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ), new MavenProject( project ) );
|
||||||
|
|
||||||
// we don't have to force the collision exception for superModel here, it's already been done in getSuperModel()
|
// we don't have to force the collision exception for superModel here, it's already been done in getSuperModel()
|
||||||
MavenProject previousProject = superProject;
|
MavenProject previousProject = superProject;
|
||||||
|
|
||||||
|
@ -741,7 +745,7 @@ public class DefaultMavenProjectBuilder
|
||||||
throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
|
throw new InvalidProjectModelException( projectId, pomLocation, e.getMessage(), e );
|
||||||
}
|
}
|
||||||
|
|
||||||
projectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project );
|
processedProjectCache.put( createCacheKey( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project );
|
||||||
|
|
||||||
// jvz:note
|
// jvz:note
|
||||||
// this only happens if we are building from a source file
|
// this only happens if we are building from a source file
|
||||||
|
@ -762,6 +766,21 @@ public class DefaultMavenProjectBuilder
|
||||||
project.setFile( projectDescriptor );
|
project.setFile( projectDescriptor );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MavenProject rawParent = project.getParent();
|
||||||
|
|
||||||
|
if ( rawParent != null )
|
||||||
|
{
|
||||||
|
String cacheKey = createCacheKey( rawParent.getGroupId(), rawParent.getArtifactId(), rawParent.getVersion() );
|
||||||
|
|
||||||
|
MavenProject processedParent = (MavenProject) processedProjectCache.get( cacheKey );
|
||||||
|
|
||||||
|
// yeah, this null check might be a bit paranoid, but better safe than sorry...
|
||||||
|
if ( processedParent != null )
|
||||||
|
{
|
||||||
|
project.setParent( processedParent );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return project;
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1010,6 +1029,16 @@ public class DefaultMavenProjectBuilder
|
||||||
|
|
||||||
model = null;
|
model = null;
|
||||||
|
|
||||||
|
String parentKey = createCacheKey( parentModel.getGroupId(), parentModel.getArtifactId(), parentModel.getVersion() );
|
||||||
|
MavenProject parentProject = (MavenProject) rawProjectCache.get( parentKey );
|
||||||
|
|
||||||
|
if ( parentProject != null )
|
||||||
|
{
|
||||||
|
model = ModelUtils.cloneModel( parentProject.getModel() );
|
||||||
|
|
||||||
|
parentDescriptor = parentProject.getFile();
|
||||||
|
}
|
||||||
|
|
||||||
String parentRelativePath = parentModel.getRelativePath();
|
String parentRelativePath = parentModel.getRelativePath();
|
||||||
|
|
||||||
// if we can't find a cached model matching the parent spec, then let's try to look on disk using
|
// if we can't find a cached model matching the parent spec, then let's try to look on disk using
|
||||||
|
|
|
@ -173,29 +173,70 @@ public class MavenProject
|
||||||
{
|
{
|
||||||
this.dependencyArtifacts = Collections.unmodifiableSet( project.dependencyArtifacts );
|
this.dependencyArtifacts = Collections.unmodifiableSet( project.dependencyArtifacts );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( project.artifacts != null )
|
if ( project.artifacts != null )
|
||||||
{
|
{
|
||||||
this.artifacts = Collections.unmodifiableSet( project.artifacts );
|
this.artifacts = Collections.unmodifiableSet( project.artifacts );
|
||||||
}
|
}
|
||||||
this.pluginArtifacts = Collections.unmodifiableSet( project.pluginArtifacts );
|
|
||||||
this.reportArtifacts = Collections.unmodifiableSet( project.reportArtifacts );
|
if ( project.pluginArtifacts != null )
|
||||||
this.extensionArtifacts = Collections.unmodifiableSet( project.extensionArtifacts );
|
{
|
||||||
|
this.pluginArtifacts = Collections.unmodifiableSet( project.pluginArtifacts );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( project.reportArtifacts != null )
|
||||||
|
{
|
||||||
|
this.reportArtifacts = Collections.unmodifiableSet( project.reportArtifacts );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( project.extensionArtifacts != null )
|
||||||
|
{
|
||||||
|
this.extensionArtifacts = Collections.unmodifiableSet( project.extensionArtifacts );
|
||||||
|
}
|
||||||
|
|
||||||
this.parentArtifact = project.parentArtifact;
|
this.parentArtifact = project.parentArtifact;
|
||||||
|
|
||||||
this.remoteArtifactRepositories = Collections.unmodifiableList( project.remoteArtifactRepositories );
|
if ( project.remoteArtifactRepositories != null )
|
||||||
this.pluginArtifactRepositories = Collections.unmodifiableList( project.pluginArtifactRepositories );
|
{
|
||||||
this.collectedProjects = Collections.unmodifiableList( project.collectedProjects );
|
this.remoteArtifactRepositories = Collections.unmodifiableList( project.remoteArtifactRepositories );
|
||||||
this.activeProfiles = Collections.unmodifiableList( project.activeProfiles );
|
}
|
||||||
|
|
||||||
// clone properties modifyable by plugins in a forked lifecycle
|
if ( project.pluginArtifactRepositories != null )
|
||||||
this.attachedArtifacts = new ArrayList( project.getAttachedArtifacts() );
|
{
|
||||||
|
this.pluginArtifactRepositories = Collections.unmodifiableList( project.pluginArtifactRepositories );
|
||||||
|
}
|
||||||
|
|
||||||
// no need for execution project
|
if ( project.collectedProjects != null )
|
||||||
|
{
|
||||||
|
this.collectedProjects = Collections.unmodifiableList( project.collectedProjects );
|
||||||
|
}
|
||||||
|
|
||||||
// clone source roots
|
if ( project.activeProfiles != null )
|
||||||
this.compileSourceRoots = new ArrayList( project.compileSourceRoots );
|
{
|
||||||
this.testCompileSourceRoots = new ArrayList( project.testCompileSourceRoots );
|
this.activeProfiles = Collections.unmodifiableList( project.activeProfiles );
|
||||||
this.scriptSourceRoots = new ArrayList( project.scriptSourceRoots );
|
}
|
||||||
|
|
||||||
|
if ( project.getAttachedArtifacts() != null )
|
||||||
|
{
|
||||||
|
// clone properties modifyable by plugins in a forked lifecycle
|
||||||
|
this.attachedArtifacts = new ArrayList( project.getAttachedArtifacts() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( project.compileSourceRoots != null )
|
||||||
|
{
|
||||||
|
// clone source roots
|
||||||
|
this.compileSourceRoots = new ArrayList( project.compileSourceRoots );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( project.testCompileSourceRoots != null )
|
||||||
|
{
|
||||||
|
this.testCompileSourceRoots = new ArrayList( project.testCompileSourceRoots );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( project.scriptSourceRoots != null )
|
||||||
|
{
|
||||||
|
this.scriptSourceRoots = new ArrayList( project.scriptSourceRoots );
|
||||||
|
}
|
||||||
|
|
||||||
this.model = ModelUtils.cloneModel( project.model );
|
this.model = ModelUtils.cloneModel( project.model );
|
||||||
|
|
||||||
|
@ -206,7 +247,10 @@ public class MavenProject
|
||||||
|
|
||||||
this.executionRoot = project.executionRoot;
|
this.executionRoot = project.executionRoot;
|
||||||
|
|
||||||
this.artifact = ArtifactUtils.copyArtifact( project.artifact );
|
if ( project.artifact != null )
|
||||||
|
{
|
||||||
|
this.artifact = ArtifactUtils.copyArtifact( project.artifact );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Find a way to use <relativePath/> here...it's tricky, because the moduleProject
|
// TODO: Find a way to use <relativePath/> here...it's tricky, because the moduleProject
|
||||||
|
@ -802,7 +846,14 @@ public class MavenProject
|
||||||
|
|
||||||
public String getGroupId()
|
public String getGroupId()
|
||||||
{
|
{
|
||||||
return model.getGroupId();
|
String groupId = model.getGroupId();
|
||||||
|
|
||||||
|
if ( groupId == null && model.getParent() != null )
|
||||||
|
{
|
||||||
|
groupId = model.getParent().getGroupId();
|
||||||
|
}
|
||||||
|
|
||||||
|
return groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArtifactId( String artifactId )
|
public void setArtifactId( String artifactId )
|
||||||
|
@ -840,7 +891,14 @@ public class MavenProject
|
||||||
|
|
||||||
public String getVersion()
|
public String getVersion()
|
||||||
{
|
{
|
||||||
return model.getVersion();
|
String version = model.getVersion();
|
||||||
|
|
||||||
|
if ( version == null && model.getParent() != null )
|
||||||
|
{
|
||||||
|
version = model.getParent().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
|
return version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPackaging()
|
public String getPackaging()
|
||||||
|
|
|
@ -20,11 +20,35 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.maven.model.Model;
|
import org.apache.maven.model.Model;
|
||||||
|
import org.apache.maven.model.Parent;
|
||||||
|
|
||||||
public class MavenProjectTest
|
public class MavenProjectTest
|
||||||
extends AbstractMavenProjectTestCase
|
extends AbstractMavenProjectTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public void testIdentityProtoInheritance()
|
||||||
|
{
|
||||||
|
Parent parent = new Parent();
|
||||||
|
|
||||||
|
parent.setGroupId( "test-group" );
|
||||||
|
parent.setVersion( "1000" );
|
||||||
|
parent.setArtifactId( "test-artifact" );
|
||||||
|
|
||||||
|
Model model = new Model();
|
||||||
|
|
||||||
|
model.setParent( parent );
|
||||||
|
model.setArtifactId( "real-artifact" );
|
||||||
|
|
||||||
|
MavenProject project = new MavenProject( model );
|
||||||
|
|
||||||
|
assertEquals( "groupId proto-inheritance failed.", "test-group", project.getGroupId() );
|
||||||
|
assertEquals( "artifactId is masked.", "real-artifact", project.getArtifactId() );
|
||||||
|
assertEquals( "version proto-inheritance failed.", "1000", project.getVersion() );
|
||||||
|
|
||||||
|
// draw the NPE.
|
||||||
|
project.getId();
|
||||||
|
}
|
||||||
|
|
||||||
public void testEmptyConstructor()
|
public void testEmptyConstructor()
|
||||||
{
|
{
|
||||||
MavenProject project = new MavenProject();
|
MavenProject project = new MavenProject();
|
||||||
|
|
|
@ -0,0 +1,120 @@
|
||||||
|
package org.apache.maven.project.inheritance.t02;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 java.util.List;
|
||||||
|
|
||||||
|
import org.apache.maven.model.Build;
|
||||||
|
import org.apache.maven.model.MailingList;
|
||||||
|
import org.apache.maven.model.Plugin;
|
||||||
|
import org.apache.maven.project.MavenProject;
|
||||||
|
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A test which demonstrates maven's recursive inheritance where
|
||||||
|
* a distinct value is taken from each parent contributing to the
|
||||||
|
* the final model of the project being assembled. There is no
|
||||||
|
* overriding going on amongst the models being used in this test:
|
||||||
|
* each model in the lineage is providing a value that is not present
|
||||||
|
* anywhere else in the lineage. We are just making sure that values
|
||||||
|
* down in the lineage are bubbling up where they should.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class ProjectInheritanceTest
|
||||||
|
extends AbstractProjectInheritanceTestCase
|
||||||
|
{
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// p4 inherits from p3
|
||||||
|
// p3 inherits from p2
|
||||||
|
// p2 inherits from p1
|
||||||
|
// p1 inherits from p0
|
||||||
|
// p0 inhertis from super model
|
||||||
|
//
|
||||||
|
// or we can show it graphically as:
|
||||||
|
//
|
||||||
|
// p4 ---> p3 ---> p2 ---> p1 ---> p0 --> super model
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
public void testProjectInheritance()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
File localRepo = getLocalRepositoryPath();
|
||||||
|
File pom0 = new File( localRepo, "p0/pom.xml" );
|
||||||
|
File pom1 = new File( pom0.getParentFile(), "p1/pom.xml" );
|
||||||
|
File pom2 = new File( pom1.getParentFile(), "p2/pom.xml" );
|
||||||
|
File pom3 = new File( pom2.getParentFile(), "p3/pom.xml" );
|
||||||
|
File pom4 = new File( pom3.getParentFile(), "p4/pom.xml" );
|
||||||
|
File pom5 = new File( pom4.getParentFile(), "p5/pom.xml" );
|
||||||
|
|
||||||
|
System.out.println( "Location of project-4's POM: " + pom4.getPath() );
|
||||||
|
|
||||||
|
// load everything...
|
||||||
|
MavenProject project0 = getProject( pom0 );
|
||||||
|
MavenProject project1 = getProject( pom1 );
|
||||||
|
MavenProject project2 = getProject( pom2 );
|
||||||
|
MavenProject project3 = getProject( pom3 );
|
||||||
|
MavenProject project4 = getProject( pom4 );
|
||||||
|
MavenProject project5 = getProject( pom5 );
|
||||||
|
|
||||||
|
assertEquals( "p4", project4.getName() );
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Value inherited from p3
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
assertEquals( "2000", project4.getInceptionYear() );
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Value taken from p2
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
assertEquals( "mailing-list", ( (MailingList) project4.getMailingLists().get( 0 ) ).getName() );
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Value taken from p1
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
assertEquals( "scm-url/p2/p3/p4", project4.getScm().getUrl() );
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Value taken from p4
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
assertEquals( "Codehaus", project4.getOrganization().getName() );
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
// Value taken from super model
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
assertEquals( "4.0.0", project4.getModelVersion() );
|
||||||
|
|
||||||
|
Build build = project4.getBuild();
|
||||||
|
List plugins = build.getPlugins();
|
||||||
|
|
||||||
|
assertEquals( 1, plugins.size() );
|
||||||
|
|
||||||
|
Plugin plugin = (Plugin) plugins.get( 0 );
|
||||||
|
List executions = plugin.getExecutions();
|
||||||
|
|
||||||
|
assertEquals( 1, executions.size() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,72 @@
|
||||||
|
package org.apache.maven.project.inheritance.t03;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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 java.util.List;
|
||||||
|
|
||||||
|
import org.apache.maven.model.Build;
|
||||||
|
import org.apache.maven.model.MailingList;
|
||||||
|
import org.apache.maven.model.Plugin;
|
||||||
|
import org.apache.maven.model.PluginExecution;
|
||||||
|
import org.apache.maven.project.MavenProject;
|
||||||
|
import org.apache.maven.project.inheritance.AbstractProjectInheritanceTestCase;
|
||||||
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A test which demonstrates maven's recursive inheritance where
|
||||||
|
* a distinct value is taken from each parent contributing to the
|
||||||
|
* the final model of the project being assembled. There is no
|
||||||
|
* overriding going on amongst the models being used in this test:
|
||||||
|
* each model in the lineage is providing a value that is not present
|
||||||
|
* anywhere else in the lineage. We are just making sure that values
|
||||||
|
* down in the lineage are bubbling up where they should.
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class ProjectInheritanceTest
|
||||||
|
extends AbstractProjectInheritanceTestCase
|
||||||
|
{
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// p1 inherits from p0
|
||||||
|
// p0 inhertis from super model
|
||||||
|
//
|
||||||
|
// or we can show it graphically as:
|
||||||
|
//
|
||||||
|
// p1 ---> p0 --> super model
|
||||||
|
//
|
||||||
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
|
public void testProjectInheritance()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
File localRepo = getLocalRepositoryPath();
|
||||||
|
File pom0 = new File( localRepo, "p0/pom.xml" );
|
||||||
|
|
||||||
|
File pom0Basedir = pom0.getParentFile();
|
||||||
|
|
||||||
|
File pom1 = new File( pom0Basedir, "p1/pom.xml" );
|
||||||
|
|
||||||
|
// load everything...
|
||||||
|
MavenProject project0 = getProject( pom0 );
|
||||||
|
MavenProject project1 = getProject( pom1 );
|
||||||
|
|
||||||
|
assertEquals( pom0Basedir, project1.getParent().getBasedir() );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<project>
|
||||||
|
<parent>
|
||||||
|
<artifactId>p3</artifactId>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>p5</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>p5</name>
|
||||||
|
<version>1.0</version>
|
||||||
|
</project>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<project>
|
||||||
|
<parent>
|
||||||
|
<artifactId>p3</artifactId>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>p4</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<name>p4</name>
|
||||||
|
<version>1.0</version>
|
||||||
|
</project>
|
|
@ -0,0 +1,14 @@
|
||||||
|
<project>
|
||||||
|
<parent>
|
||||||
|
<artifactId>p2</artifactId>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>p3</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>p3</name>
|
||||||
|
<version>1.0</version>
|
||||||
|
<inceptionYear>2000</inceptionYear>
|
||||||
|
</project>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<project>
|
||||||
|
<parent>
|
||||||
|
<artifactId>p1</artifactId>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>p2</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>p2</name>
|
||||||
|
<version>1.0</version>
|
||||||
|
<mailingLists>
|
||||||
|
<mailingList>
|
||||||
|
<name>mailing-list</name>
|
||||||
|
</mailingList>
|
||||||
|
</mailingLists>
|
||||||
|
</project>
|
|
@ -0,0 +1,32 @@
|
||||||
|
<project>
|
||||||
|
<parent>
|
||||||
|
<artifactId>p0</artifactId>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>p1</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>p1</name>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scm>
|
||||||
|
<url>scm-url</url>
|
||||||
|
</scm>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>test</id>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,11 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>p0</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>p0</name>
|
||||||
|
<version>1.0</version>
|
||||||
|
<organization>
|
||||||
|
<name>Codehaus</name>
|
||||||
|
</organization>
|
||||||
|
</project>
|
|
@ -0,0 +1,26 @@
|
||||||
|
<project>
|
||||||
|
<parent>
|
||||||
|
<artifactId>p0</artifactId>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>p1</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>p1</name>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scm>
|
||||||
|
<url>scm-url</url>
|
||||||
|
</scm>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<tasks><echo>${project.parent.basedir}</echo></tasks>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,11 @@
|
||||||
|
<project>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>maven</groupId>
|
||||||
|
<artifactId>p0</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>p0</name>
|
||||||
|
<version>1.0</version>
|
||||||
|
<organization>
|
||||||
|
<name>Codehaus</name>
|
||||||
|
</organization>
|
||||||
|
</project>
|
3
pom.xml
3
pom.xml
|
@ -156,6 +156,9 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.codehaus.plexus</groupId>
|
<groupId>org.codehaus.plexus</groupId>
|
||||||
<artifactId>plexus-container-default</artifactId>
|
<artifactId>plexus-container-default</artifactId>
|
||||||
|
<!-- We need to upgrade this to 1.0-alpha-10-SNAPSHOT for >= 2.0.5, to correct MNG-2201
|
||||||
|
<version>1.0-alpha-10-SNAPSHOT</version>
|
||||||
|
-->
|
||||||
<version>1.0-alpha-9</version>
|
<version>1.0-alpha-9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
<assembly>
|
||||||
|
<id>src</id>
|
||||||
|
<formats>
|
||||||
|
<format>tar.gz</format>
|
||||||
|
<format>tar.bz2</format>
|
||||||
|
<format>zip</format>
|
||||||
|
</formats>
|
||||||
|
<includeBaseDirectory>true</includeBaseDirectory>
|
||||||
|
<!-- fileSets>
|
||||||
|
<fileSet>
|
||||||
|
<excludes>
|
||||||
|
<exclude>**/target</exclude>
|
||||||
|
</excludes>
|
||||||
|
</fileSet>
|
||||||
|
</fileSets -->
|
||||||
|
<modules>
|
||||||
|
<module>maven-archiver</module>
|
||||||
|
<module>maven-artifact</module>
|
||||||
|
<module>maven-artifact-manager</module>
|
||||||
|
<module>maven-artifact-test</module>
|
||||||
|
<module>maven-core</module>
|
||||||
|
<module>maven-error-diagnostics</module>
|
||||||
|
<module>maven-model</module>
|
||||||
|
<module>maven-model-converter</module>
|
||||||
|
<module>maven-monitor</module>
|
||||||
|
<module>maven-plugin-api</module>
|
||||||
|
<module>maven-plugin-descriptor</module>
|
||||||
|
<module>maven-plugin-parameter-documenter</module>
|
||||||
|
<module>maven-plugin-registry</module>
|
||||||
|
<module>maven-plugin-tools</module>
|
||||||
|
<module>maven-profile</module>
|
||||||
|
<module>maven-project</module>
|
||||||
|
<module>maven-reporting</module>
|
||||||
|
<module>maven-repository-metadata</module>
|
||||||
|
<module>maven-script</module>
|
||||||
|
<module>maven-settings</module>
|
||||||
|
</modules>
|
||||||
|
</assembly>
|
Loading…
Reference in New Issue