reapplying John's merge of all 2.0.10-RC changes to date by reverting r679244, sans artifact upgrade and user agent parts. Passes all integration tests locally, seeing if Hudson and Continuum agree

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@679263 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Leslie Porter 2008-07-24 01:56:21 +00:00
parent 24176a08a1
commit d52ffdef81
13 changed files with 206 additions and 29 deletions

View File

@ -28,6 +28,7 @@ import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.ReactorManager; import org.apache.maven.execution.ReactorManager;
import org.apache.maven.lifecycle.binding.LifecycleBindingManager;
import org.apache.maven.lifecycle.binding.MojoBindingFactory; import org.apache.maven.lifecycle.binding.MojoBindingFactory;
import org.apache.maven.lifecycle.model.MojoBinding; import org.apache.maven.lifecycle.model.MojoBinding;
import org.apache.maven.lifecycle.plan.BuildPlan; import org.apache.maven.lifecycle.plan.BuildPlan;
@ -91,6 +92,8 @@ public class DefaultLifecycleExecutor
private BuildPlanner buildPlanner; private BuildPlanner buildPlanner;
private MojoBindingFactory mojoBindingFactory; private MojoBindingFactory mojoBindingFactory;
private LifecycleBindingManager lifecycleBindingManager;
// this is needed for setting the lookup realm before we start building a project. // this is needed for setting the lookup realm before we start building a project.
private PlexusContainer container; private PlexusContainer container;
@ -959,4 +962,9 @@ public class DefaultLifecycleExecutor
{ {
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
} }
public List getLifecycles()
{
return lifecycleBindingManager.getLifecycles();
}
} }

View File

@ -19,6 +19,8 @@ package org.apache.maven.lifecycle;
* under the License. * under the License.
*/ */
import java.util.List;
import org.apache.maven.BuildFailureException; import org.apache.maven.BuildFailureException;
import org.apache.maven.execution.MavenExecutionRequest; import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MavenSession;
@ -56,4 +58,9 @@ public interface LifecycleExecutor
void execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher ) void execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher )
throws LifecycleExecutionException, BuildFailureException; throws LifecycleExecutionException, BuildFailureException;
/**
* @since 2.0.10
*/
List getLifecycles();
} }

View File

@ -64,13 +64,18 @@ public class DefaultLifecycleBindingManager
private Logger logger; private Logger logger;
// configured. Moved out of DefaultLifecycleExecutor... // configured. Moved out of DefaultLifecycleExecutor...
private List lifecycles; private List<org.apache.maven.lifecycle.binding.Lifecycle> lifecycles;
// configured. Moved out of DefaultLifecycleExecutor... // configured. Moved out of DefaultLifecycleExecutor...
private List defaultReports; private List defaultReports;
// contextualized, used for setting lookup realm before retrieving lifecycle bindings for packaging. // contextualized, used for setting lookup realm before retrieving lifecycle bindings for packaging.
private PlexusContainer container; private PlexusContainer container;
public List<org.apache.maven.lifecycle.binding.Lifecycle> getLifecycles()
{
return lifecycles;
}
/** /**
* {@inheritDoc} * {@inheritDoc}

View File

@ -82,4 +82,6 @@ public interface LifecycleBindingManager
final LifecycleBindings lifecycleBindings ) final LifecycleBindings lifecycleBindings )
throws LifecycleSpecificationException; throws LifecycleSpecificationException;
List<org.apache.maven.lifecycle.binding.Lifecycle> getLifecycles();
} }

View File

@ -1087,6 +1087,8 @@ public class DefaultMavenProjectBuilder
dPlugin.setGroupId( iPlugin.getGroupId() ); dPlugin.setGroupId( iPlugin.getGroupId() );
dPlugin.setArtifactId( iPlugin.getArtifactId() ); dPlugin.setArtifactId( iPlugin.getArtifactId() );
dPlugin.setVersion( iPlugin.getVersion() ); dPlugin.setVersion( iPlugin.getVersion() );
dPlugin.setDependencies( iPlugin.getDependencies() );
} }
} }
@ -1108,6 +1110,8 @@ public class DefaultMavenProjectBuilder
dPlugin.setGroupId( iPlugin.getGroupId() ); dPlugin.setGroupId( iPlugin.getGroupId() );
dPlugin.setArtifactId( iPlugin.getArtifactId() ); dPlugin.setArtifactId( iPlugin.getArtifactId() );
dPlugin.setVersion( iPlugin.getVersion() ); dPlugin.setVersion( iPlugin.getVersion() );
dPlugin.setDependencies( iPlugin.getDependencies() );
} }
} }
} }

View File

@ -562,6 +562,8 @@ public final class ModelUtils
public static Model cloneModel( Model model ) public static Model cloneModel( Model model )
{ {
// TODO: would be nice for the modello:java code to generate this as a copy constructor // TODO: would be nice for the modello:java code to generate this as a copy constructor
// FIXME: Fix deep cloning issues with existing plugin instances (setting
// a version when resolved will pollute the original model instance)
Model newModel = new Model(); Model newModel = new Model();
ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler(); ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
newModel.setModelVersion( model.getModelVersion() ); newModel.setModelVersion( model.getModelVersion() );

View File

@ -101,22 +101,34 @@ public class MavenMetadataSource
return artifact; return artifact;
} }
ProjectRelocation res = retrieveRelocatedProject( artifact, localRepository, remoteRepositories ); ProjectRelocation rel = retrieveRelocatedProject( artifact, localRepository, remoteRepositories );
MavenProject project = res.project;
if ( rel == null )
{
return artifact;
}
MavenProject project = rel.project;
if ( project == null || getRelocationKey( artifact ).equals( getRelocationKey( project.getArtifact() ) ) ) if ( project == null || getRelocationKey( artifact ).equals( getRelocationKey( project.getArtifact() ) ) )
{ {
return artifact; return artifact;
} }
// NOTE: Using artifact information here, since some POMs are deployed
// to central with one version in the filename, but another in the <version> string!
// Case in point: org.apache.ws.commons:XmlSchema:1.1:pom.
//
// Since relocation triggers a reconfiguration of the artifact's information
// in retrieveRelocatedProject(..), this is safe to do.
Artifact result = null; Artifact result = null;
if ( artifact.getClassifier() != null ) if ( artifact.getClassifier() != null )
{ {
result = artifactFactory.createArtifactWithClassifier( project.getGroupId(), project.getArtifactId(), project.getVersion(), artifact.getType(), artifact.getClassifier() ); result = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier() );
} }
else else
{ {
result = artifactFactory.createArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(), artifact.getScope(), artifact.getType() ); result = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope(), artifact.getType() );
} }
result.setScope( artifact.getScope() ); result.setScope( artifact.getScope() );

View File

@ -1,3 +1,5 @@
package org.apache.maven.project.interpolation;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -17,33 +19,34 @@
* under the License. * under the License.
*/ */
package org.apache.maven.project.interpolation;
import org.apache.maven.project.path.PathTranslator; import org.apache.maven.project.path.PathTranslator;
import org.codehaus.plexus.interpolation.AbstractFunctionValueSourceWrapper; import org.codehaus.plexus.interpolation.AbstractFunctionValueSourceWrapper;
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
import org.codehaus.plexus.interpolation.ValueSource; import org.codehaus.plexus.interpolation.ValueSource;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
public class PathTranslatingValueSource /**
extends AbstractFunctionValueSourceWrapper *
* @version $Id: PathTranslatingPostProcessor.java 677447 2008-07-16 22:15:57Z jdcasey $
*/
public class PathTranslatingPostProcessor
implements InterpolationPostProcessor
{ {
private final List<String> unprefixedPathKeys; private final List unprefixedPathKeys;
private final File projectDir; private final File projectDir;
private final PathTranslator pathTranslator; private final PathTranslator pathTranslator;
protected PathTranslatingValueSource( ValueSource valueSource, List<String> unprefixedPathKeys, File projectDir, PathTranslator pathTranslator ) public PathTranslatingPostProcessor( List unprefixedPathKeys, File projectDir, PathTranslator pathTranslator )
{ {
super( valueSource );
this.unprefixedPathKeys = unprefixedPathKeys; this.unprefixedPathKeys = unprefixedPathKeys;
this.projectDir = projectDir; this.projectDir = projectDir;
this.pathTranslator = pathTranslator; this.pathTranslator = pathTranslator;
} }
@Override public Object execute( String expression,
protected Object executeFunction( String expression,
Object value ) Object value )
{ {
if ( projectDir != null && value != null && unprefixedPathKeys.contains( expression ) ) if ( projectDir != null && value != null && unprefixedPathKeys.contains( expression ) )

View File

@ -88,6 +88,12 @@ public class RegexBasedModelInterpolator
throws IOException throws IOException
{ {
} }
// for testing.
protected RegexBasedModelInterpolator( PathTranslator pathTranslator )
{
this.pathTranslator = pathTranslator;
}
public Model interpolate( Model model, Map<String, ?> context ) public Model interpolate( Model model, Map<String, ?> context )
throws ModelInterpolationException throws ModelInterpolationException
@ -199,15 +205,8 @@ public class RegexBasedModelInterpolator
timestampFormat = modelProperties.getProperty( BUILD_TIMESTAMP_FORMAT_PROPERTY, timestampFormat ); timestampFormat = modelProperties.getProperty( BUILD_TIMESTAMP_FORMAT_PROPERTY, timestampFormat );
} }
ValueSource baseModelValueSource1 = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false ); ValueSource modelValueSource1 = new PrefixedObjectValueSource( PROJECT_PREFIXES, model, false );
ValueSource modelValueSource1 = new PathTranslatingValueSource( baseModelValueSource1, ValueSource modelValueSource2 = new ObjectBasedValueSource( model );
TRANSLATED_PATH_EXPRESSIONS,
projectDir, pathTranslator );
ValueSource baseModelValueSource2 = new ObjectBasedValueSource( model );
ValueSource modelValueSource2 = new PathTranslatingValueSource( baseModelValueSource2,
TRANSLATED_PATH_EXPRESSIONS,
projectDir, pathTranslator );
ValueSource basedirValueSource = new PrefixedValueSourceWrapper( new ValueSource(){ ValueSource basedirValueSource = new PrefixedValueSourceWrapper( new ValueSource(){
public Object getValue( String expression ) public Object getValue( String expression )
@ -232,6 +231,11 @@ public class RegexBasedModelInterpolator
interpolator.addValueSource( new PrefixedValueSourceWrapper( new MapBasedValueSource( modelProperties ), PROJECT_PREFIXES, true ) ); interpolator.addValueSource( new PrefixedValueSourceWrapper( new MapBasedValueSource( modelProperties ), PROJECT_PREFIXES, true ) );
interpolator.addValueSource( modelValueSource2 ); interpolator.addValueSource( modelValueSource2 );
interpolator.addValueSource( new MapBasedValueSource( config.getUserProperties() ) ); interpolator.addValueSource( new MapBasedValueSource( config.getUserProperties() ) );
PathTranslatingPostProcessor pathTranslatingPostProcessor =
new PathTranslatingPostProcessor( TRANSLATED_PATH_EXPRESSIONS, projectDir, pathTranslator );
interpolator.addPostProcessor( pathTranslatingPostProcessor );
RecursionInterceptor recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES ); RecursionInterceptor recursionInterceptor = new PrefixAwareRecursionInterceptor( PROJECT_PREFIXES );

View File

@ -115,7 +115,7 @@ under the License.
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-plugin-plugin</artifactId> <artifactId>maven-plugin-plugin</artifactId>
<version>2.3</version> <version>2.4.2</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-rar-plugin</artifactId> <artifactId>maven-rar-plugin</artifactId>
@ -131,7 +131,7 @@ under the License.
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-site-plugin</artifactId> <artifactId>maven-site-plugin</artifactId>
<version>2.0-beta-6</version> <version>2.0-beta-7</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
@ -139,7 +139,7 @@ under the License.
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version> <version>2.4.3</version>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-war-plugin</artifactId> <artifactId>maven-war-plugin</artifactId>

View File

@ -19,19 +19,25 @@ package org.apache.maven.project.interpolation;
* under the License. * under the License.
*/ */
import org.apache.maven.model.Build;
import org.apache.maven.model.Dependency; import org.apache.maven.model.Dependency;
import org.apache.maven.model.DeploymentRepository; import org.apache.maven.model.DeploymentRepository;
import org.apache.maven.model.DistributionManagement; import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.Organization; import org.apache.maven.model.Organization;
import org.apache.maven.model.Repository; import org.apache.maven.model.Repository;
import org.apache.maven.model.Resource;
import org.apache.maven.model.Scm; import org.apache.maven.model.Scm;
import org.apache.maven.project.DefaultProjectBuilderConfiguration; import org.apache.maven.project.DefaultProjectBuilderConfiguration;
import org.apache.maven.project.ProjectBuilderConfiguration; import org.apache.maven.project.ProjectBuilderConfiguration;
import org.apache.maven.project.path.DefaultPathTranslator;
import org.apache.maven.project.path.PathTranslator;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
@ -297,4 +303,83 @@ public class RegexBasedModelInterpolatorTest
assertEquals( "Expected '" + expectedVersion + "' for version expression '" + depVersionExpr + "', but was '" + result + "'", expectedVersion, result ); assertEquals( "Expected '" + expectedVersion + "' for version expression '" + depVersionExpr + "', but was '" + result + "'", expectedVersion, result );
} }
public void testShouldInterpolateSourceDirectoryReferencedFromResourceDirectoryCorrectly()
throws Exception
{
Model model = new Model();
Build build = new Build();
build.setSourceDirectory( "correct" );
Resource res = new Resource();
res.setDirectory( "${project.build.sourceDirectory}" );
build.addResource( res );
Resource res2 = new Resource();
res2.setDirectory( "${pom.build.sourceDirectory}" );
build.addResource( res2 );
Resource res3 = new Resource();
res3.setDirectory( "${build.sourceDirectory}" );
build.addResource( res3 );
model.setBuild( build );
Model out = new RegexBasedModelInterpolator().interpolate( model, context );
List outResources = out.getBuild().getResources();
Iterator resIt = outResources.iterator();
assertEquals( build.getSourceDirectory(), ( (Resource) resIt.next() ).getDirectory() );
assertEquals( build.getSourceDirectory(), ( (Resource) resIt.next() ).getDirectory() );
assertEquals( build.getSourceDirectory(), ( (Resource) resIt.next() ).getDirectory() );
}
public void testShouldInterpolateUnprefixedBasedirExpression()
throws ModelInterpolationException, IOException
{
File basedir = new File( "/test/path" );
Model model = new Model();
Dependency dep = new Dependency();
dep.setSystemPath( "${basedir}/artifact.jar" );
model.addDependency( dep );
Model result = new RegexBasedModelInterpolator().interpolate( model, basedir, new DefaultProjectBuilderConfiguration(), true );
List rDeps = result.getDependencies();
assertNotNull( rDeps );
assertEquals( 1, rDeps.size() );
assertEquals( new File( basedir, "artifact.jar" ).getAbsolutePath(), new File( ( (Dependency) rDeps.get( 0 ) )
.getSystemPath() ).getAbsolutePath() );
}
public void testTwoLevelRecursiveBasedirAlignedExpression()
throws Exception
{
Model model = new Model();
Build build = new Build();
model.setBuild( build );
build.setDirectory( "${project.basedir}/target" );
build.setOutputDirectory( "${project.build.directory}/classes" );
PathTranslator translator = new DefaultPathTranslator();
RegexBasedModelInterpolator interpolator = new RegexBasedModelInterpolator( translator );
File basedir = new File( System.getProperty( "java.io.tmpdir" ), "base" );
String value = interpolator.interpolate( "${project.build.outputDirectory}/foo", model, basedir, new DefaultProjectBuilderConfiguration(), true );
value = value.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
String check = new File( basedir, "target/classes/foo" ).getAbsolutePath();
check = check.replace( '/', File.separatorChar ).replace( '\\', File.separatorChar );
assertEquals( check, value );
}
} }

View File

@ -0,0 +1,24 @@
<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>testing</groupId>
<artifactId>plugin-level-dep</artifactId>
<packaging>jar</packaging>
<version>3.8.1</version>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${pom.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</project>

25
pom.xml
View File

@ -202,6 +202,27 @@
<artifactId>maven-bundle-plugin</artifactId> <artifactId>maven-bundle-plugin</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</plugin> </plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>clirr-maven-plugin</artifactId>
<version>2.2.1</version>
<configuration>
<!-- needed for release: default value "(,${project.version})" for 2.0.10 is 2.0.10-SNAPSHOT -->
<comparisonVersion>2.0.9</comparisonVersion>
<excludes>
<!-- TODO: These represent method ADDITIONS from 2.0.9, and should be removed after
2.0.10 is released. -->
<exclude>org/apache/maven/lifecycle/LifecycleExecutor*</exclude>
<exclude>org/apache/maven/artifact/metadata/ArtifactMetadataSource*</exclude>
<exclude>org/apache/maven/project/MavenProjectBuilder*</exclude>
<exclude>org/apache/maven/project/ProjectBuilderConfiguration*</exclude>
<exclude>org/apache/maven/project/interpolation/ModelInterpolator*</exclude>
<exclude>org/apache/maven/project/inheritance/ModelInheritanceAssembler*</exclude>
<exclude>org/apache/maven/execution/MavenExecutionRequest*</exclude>
<exclude>org/apache/maven/plugin/DefaultPluginManager*</exclude>
</excludes>
</configuration>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
@ -247,8 +268,8 @@
<junitVersion>3.8.1</junitVersion> <junitVersion>3.8.1</junitVersion>
<plexusVersion>1.0-alpha-48</plexusVersion> <plexusVersion>1.0-alpha-48</plexusVersion>
<plexusInteractivityVersion>1.0-alpha-6</plexusInteractivityVersion> <plexusInteractivityVersion>1.0-alpha-6</plexusInteractivityVersion>
<plexusInterpolationVersion>1.0</plexusInterpolationVersion> <plexusInterpolationVersion>1.1</plexusInterpolationVersion>
<plexusUtilsVersion>1.5.4</plexusUtilsVersion> <plexusUtilsVersion>1.5.5</plexusUtilsVersion>
<wagonVersion>1.0-beta-3</wagonVersion> <wagonVersion>1.0-beta-3</wagonVersion>
</properties> </properties>