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:
John Dennis Casey 2006-04-05 17:43:35 +00:00
parent df10b7e556
commit f810fd2ef2
32 changed files with 673 additions and 31 deletions

View File

@ -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
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

View File

@ -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
it0101
it0100

View File

@ -1 +1 @@
-DgroupId=org.someproject "-DartifactId=test project"
-Dtest.property="Test Property"

View File

@ -1 +0,0 @@
test project/pom.xml

View File

@ -1 +1 @@
archetype:create
test

View File

@ -1,6 +1,13 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven.it0098</groupId>
<artifactId>it0098-archetype-orchestration-test</artifactId>
<artifactId>it0098</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
</dependency>
</dependencies>
</project>

View File

@ -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" ) );
}
}

View File

@ -1 +0,0 @@
failOnErrorOutput=false

View File

@ -0,0 +1 @@
package

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -0,0 +1 @@
test

View File

@ -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>

View File

@ -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!" );
}
}

View File

@ -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 );
}
}

View File

@ -152,7 +152,9 @@ public class DefaultMavenProjectBuilder
private ModelValidator validator;
private Map projectCache = new HashMap();
private Map rawProjectCache = new HashMap();
private Map processedProjectCache = new HashMap();
// TODO: make it a component
private MavenXpp3Reader modelReader;
@ -213,7 +215,7 @@ public class DefaultMavenProjectBuilder
{
String cacheKey = createCacheKey( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() );
MavenProject project = (MavenProject) projectCache.get( cacheKey );
MavenProject project = (MavenProject) processedProjectCache.get( cacheKey );
if ( project != null )
{
@ -685,6 +687,8 @@ public class DefaultMavenProjectBuilder
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()
MavenProject previousProject = superProject;
@ -741,7 +745,7 @@ public class DefaultMavenProjectBuilder
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
// this only happens if we are building from a source file
@ -762,6 +766,21 @@ public class DefaultMavenProjectBuilder
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;
}
@ -1010,6 +1029,16 @@ public class DefaultMavenProjectBuilder
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();
// if we can't find a cached model matching the parent spec, then let's try to look on disk using

View File

@ -173,29 +173,70 @@ public class MavenProject
{
this.dependencyArtifacts = Collections.unmodifiableSet( project.dependencyArtifacts );
}
if ( project.artifacts != null )
{
this.artifacts = Collections.unmodifiableSet( project.artifacts );
}
if ( project.pluginArtifacts != null )
{
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;
if ( project.remoteArtifactRepositories != null )
{
this.remoteArtifactRepositories = Collections.unmodifiableList( project.remoteArtifactRepositories );
this.pluginArtifactRepositories = Collections.unmodifiableList( project.pluginArtifactRepositories );
this.collectedProjects = Collections.unmodifiableList( project.collectedProjects );
this.activeProfiles = Collections.unmodifiableList( project.activeProfiles );
}
if ( project.pluginArtifactRepositories != null )
{
this.pluginArtifactRepositories = Collections.unmodifiableList( project.pluginArtifactRepositories );
}
if ( project.collectedProjects != null )
{
this.collectedProjects = Collections.unmodifiableList( project.collectedProjects );
}
if ( project.activeProfiles != null )
{
this.activeProfiles = Collections.unmodifiableList( project.activeProfiles );
}
if ( project.getAttachedArtifacts() != null )
{
// clone properties modifyable by plugins in a forked lifecycle
this.attachedArtifacts = new ArrayList( project.getAttachedArtifacts() );
}
// no need for execution project
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 );
@ -206,8 +247,11 @@ public class MavenProject
this.executionRoot = project.executionRoot;
if ( project.artifact != null )
{
this.artifact = ArtifactUtils.copyArtifact( project.artifact );
}
}
// TODO: Find a way to use <relativePath/> here...it's tricky, because the moduleProject
// usually doesn't have a file associated with it yet.
@ -802,7 +846,14 @@ public class MavenProject
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 )
@ -840,7 +891,14 @@ public class MavenProject
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()

View File

@ -20,11 +20,35 @@ import java.io.File;
import java.io.IOException;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
public class MavenProjectTest
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()
{
MavenProject project = new MavenProject();

View File

@ -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() );
}
}

View File

@ -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() );
}
}

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -156,6 +156,9 @@
<dependency>
<groupId>org.codehaus.plexus</groupId>
<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>
</dependency>
<dependency>

38
src/assemble/src.xml Normal file
View File

@ -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>