Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge from trunk.
Browse files Browse the repository at this point in the history
  • Loading branch information
Britton Isbell committed Jul 24, 2008
1 parent c35a475 commit a88afe6
Show file tree
Hide file tree
Showing 18 changed files with 258 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
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.model.MojoBinding;
import org.apache.maven.lifecycle.plan.BuildPlan;
Expand Down Expand Up @@ -91,6 +92,8 @@ public class DefaultLifecycleExecutor
private BuildPlanner buildPlanner;

private MojoBindingFactory mojoBindingFactory;

private LifecycleBindingManager lifecycleBindingManager;

// this is needed for setting the lookup realm before we start building a project.
private PlexusContainer container;
Expand Down Expand Up @@ -959,4 +962,9 @@ public void contextualize( Context context )
{
container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
}

public List getLifecycles()
{
return lifecycleBindingManager.getLifecycles();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
* under the License.
*/

import java.util.List;

import org.apache.maven.BuildFailureException;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
Expand Down Expand Up @@ -56,4 +58,9 @@ public interface LifecycleExecutor
void execute( MavenSession session, ReactorManager rm, EventDispatcher dispatcher )
throws LifecycleExecutionException, BuildFailureException;

/**
* @since 2.0.10
*/
List getLifecycles();

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,18 @@ public class DefaultLifecycleBindingManager
private Logger logger;

// configured. Moved out of DefaultLifecycleExecutor...
private List lifecycles;
private List<org.apache.maven.lifecycle.binding.Lifecycle> lifecycles;

// configured. Moved out of DefaultLifecycleExecutor...
private List defaultReports;

// contextualized, used for setting lookup realm before retrieving lifecycle bindings for packaging.
private PlexusContainer container;

public List<org.apache.maven.lifecycle.binding.Lifecycle> getLifecycles()
{
return lifecycles;
}

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,6 @@ void resolveUnbindableMojos( final Set unbindableMojos,
final LifecycleBindings lifecycleBindings )
throws LifecycleSpecificationException;

List<org.apache.maven.lifecycle.binding.Lifecycle> getLifecycles();

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ under the License.
<httpHeaders>
<property>
<name>User-Agent</name>
<value>Apache Maven/${project.version}</value>
<value>Apache-Maven/${project.version} maven-artifact/${artifactVersion}</value>
</property>
</httpHeaders>
</configuration>
Expand All @@ -70,7 +70,7 @@ under the License.
<httpHeaders>
<property>
<name>User-Agent</name>
<value>Apache Maven/${project.version}</value>
<value>Apache-Maven/${project.version} maven-artifact/${artifactVersion}</value>
</property>
</httpHeaders>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
*/

import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.StringTokenizer;

import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.util.Os;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineUtils;

Expand All @@ -31,10 +34,13 @@ public abstract class AbstractEmbedderTestCase
{
protected MavenEmbedder maven;

private String defaultPath;

private List defaultPathList;

/**
* The file extensions used to resolve command names to executables. Each extension must have a leading period.
*/
private List commandExtensions;

protected void setUp()
throws Exception
{
Expand All @@ -43,24 +49,25 @@ protected void setUp()
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();

Configuration configuration = new DefaultConfiguration().setClassLoader( classLoader ).setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
configuration.setUserSettingsFile( MavenEmbedder.DEFAULT_USER_SETTINGS_FILE );

maven = new MavenEmbedder( configuration );

// Some help with detecting executables on the command line. We want, in some cases, to use tools that are available on the command line
// but if they are not present on the machine we don't want tests to fail. Case in point would be using SVN via the SCM plugin. We'll
// run it if we can, pass through gracefully otherwise.

defaultPath = CommandLineUtils.getSystemEnvVars().getProperty( "PATH" );
Properties env = CommandLineUtils.getSystemEnvVars( !Os.isFamily( Os.FAMILY_WINDOWS ) );

String defaultPath = env.getProperty( "PATH" );

if ( defaultPath == null )
{
defaultPathList = Collections.EMPTY_LIST;
}
else
{
String separator = System.getProperty( "path.separator" );

StringTokenizer tokenizer = new StringTokenizer( defaultPath, separator );
StringTokenizer tokenizer = new StringTokenizer( defaultPath, File.pathSeparator );

defaultPathList = new LinkedList();

Expand All @@ -71,6 +78,17 @@ protected void setUp()
defaultPathList.add( element );
}
}

String pathExt = env.getProperty( "PATHEXT" );

if ( pathExt == null )
{
commandExtensions = Collections.EMPTY_LIST;
}
else
{
commandExtensions = Arrays.asList( pathExt.split( "\\" + File.pathSeparatorChar + "+" ) );
}
}

protected void tearDown()
Expand Down Expand Up @@ -117,12 +135,22 @@ public File findExecutable( String executable, List path )
return null;
}

// TODO: Need to resolve it with defaults extension of system
// ie. if executable is 'mvn', we must search 'mvn.bat'
for ( Iterator it = path.iterator(); it.hasNext(); )
{
String s = (String) it.next();

for ( Iterator ite = commandExtensions.iterator(); ite.hasNext(); )
{
String ext = (String) ite.next();

f = new File( s, executable + ext );

if ( f.isFile() )
{
return f;
}
}

f = new File( s, executable );

if ( f.isFile() )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ protected void setUp()
Configuration configuration = new DefaultConfiguration()
.setClassLoader( classLoader )
.setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
configuration.setUserSettingsFile( MavenEmbedder.DEFAULT_USER_SETTINGS_FILE );

maven = new MavenEmbedder( configuration );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import java.io.File;
import java.util.Arrays;
import java.util.Iterator;

public class MavenEmbedderCrappySettingsConfigurationTest
extends PlexusTestCase
Expand All @@ -40,7 +41,7 @@ public void testEmbedderWillStillStartupWhenTheSettingsConfigurationIsCrap()
{
// START SNIPPET: simple-embedder-example

File projectDirectory = new File( getBasedir(), "src/examples/simple-project" );
File projectDirectory = getTestFile( "src/examples/simple-project" );

File user = new File( projectDirectory, "invalid-settings.xml" );

Expand All @@ -58,9 +59,17 @@ public void testEmbedderWillStillStartupWhenTheSettingsConfigurationIsCrap()

MavenExecutionRequest request = new DefaultMavenExecutionRequest()
.setBaseDirectory( projectDirectory )
.setGoals( Arrays.asList( new String[]{"clean", "install"} ) );
.setGoals( Arrays.asList( new String[]{"validate"} ) );

MavenExecutionResult result = embedder.execute( request );

for ( Iterator i = result.getExceptions().iterator(); i.hasNext(); )
{
Exception e = (Exception) i.next();
e.printStackTrace();
}

assertFalse( result.hasExceptions() );

assertNotNull( result.getProject() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public void setUp()

Configuration configuration = new DefaultConfiguration().setClassLoader( classLoader )
.setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );

configuration.setUserSettingsFile( MavenEmbedder.DEFAULT_USER_SETTINGS_FILE );

maven = new MavenEmbedder( configuration );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1071,6 +1071,8 @@ private void mergeDeterministicBuildElements( Build interpolatedBuild,
dPlugin.setGroupId( iPlugin.getGroupId() );
dPlugin.setArtifactId( iPlugin.getArtifactId() );
dPlugin.setVersion( iPlugin.getVersion() );

dPlugin.setDependencies( iPlugin.getDependencies() );
}
}

Expand All @@ -1092,6 +1094,8 @@ private void mergeDeterministicBuildElements( Build interpolatedBuild,
dPlugin.setGroupId( iPlugin.getGroupId() );
dPlugin.setArtifactId( iPlugin.getArtifactId() );
dPlugin.setVersion( iPlugin.getVersion() );

dPlugin.setDependencies( iPlugin.getDependencies() );
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,8 @@ private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent
public static Model cloneModel( Model model )
{
// 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();
ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
newModel.setModelVersion( model.getModelVersion() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,34 @@ public Artifact retrieveRelocatedArtifact( Artifact artifact,
return artifact;
}

ProjectRelocation res = retrieveRelocatedProject( artifact, localRepository, remoteRepositories );
MavenProject project = res.project;

ProjectRelocation rel = retrieveRelocatedProject( artifact, localRepository, remoteRepositories );

if ( rel == null )
{
return artifact;
}

MavenProject project = rel.project;
if ( project == null || getRelocationKey( artifact ).equals( getRelocationKey( project.getArtifact() ) ) )
{
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;
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
{
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() );
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package org.apache.maven.project.interpolation;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -17,33 +19,34 @@
* under the License.
*/

package org.apache.maven.project.interpolation;

import org.apache.maven.project.path.PathTranslator;
import org.codehaus.plexus.interpolation.AbstractFunctionValueSourceWrapper;
import org.codehaus.plexus.interpolation.InterpolationPostProcessor;
import org.codehaus.plexus.interpolation.ValueSource;

import java.io.File;
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 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.projectDir = projectDir;
this.pathTranslator = pathTranslator;
}

@Override
protected Object executeFunction( String expression,
public Object execute( String expression,
Object value )
{
if ( projectDir != null && value != null && unprefixedPathKeys.contains( expression ) )
Expand Down
Loading

0 comments on commit a88afe6

Please sign in to comment.