mirror of https://github.com/apache/maven.git
o aligning the plugin parameter expression evaluator with the new test code
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@760975 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e3061a4bda
commit
f0d253b643
|
@ -44,7 +44,6 @@ import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
|||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.execution.RuntimeInformation;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.apache.maven.monitor.logging.DefaultLog;
|
||||
|
@ -56,7 +55,6 @@ import org.apache.maven.project.MavenProject;
|
|||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.apache.maven.repository.RepositorySystem;
|
||||
import org.apache.maven.repository.VersionNotFoundException;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
|
@ -91,8 +89,8 @@ public class DefaultPluginManager
|
|||
@Requirement
|
||||
protected ArtifactFilterManager coreArtifactFilterManager;
|
||||
|
||||
@Requirement
|
||||
protected PathTranslator pathTranslator;
|
||||
//@Requirement
|
||||
//protected PathTranslator pathTranslator;
|
||||
|
||||
@Requirement
|
||||
protected MavenPluginCollector pluginCollector;
|
||||
|
@ -351,16 +349,18 @@ public class DefaultPluginManager
|
|||
logger.warn( "Mojo: " + mojoDescriptor.getGoal() + " is deprecated.\n" + mojoDescriptor.getDeprecated() );
|
||||
}
|
||||
|
||||
/*
|
||||
Model model = project.getModel();
|
||||
pathTranslator.alignToBaseDirectory( model, project.getBasedir() );
|
||||
project.setBuild( model.getBuild() );
|
||||
*/
|
||||
|
||||
if ( mojoDescriptor.isDependencyResolutionRequired() != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
// mojoDescriptor.isDependencyResolutionRequired() is actually the scope of the dependency resolution required, not a boolean ... yah.
|
||||
downloadDependencies( session, mojoDescriptor.isDependencyResolutionRequired() );
|
||||
downloadProjectDependencies( session, mojoDescriptor.isDependencyResolutionRequired() );
|
||||
}
|
||||
catch ( ArtifactResolutionException e )
|
||||
{
|
||||
|
@ -550,11 +550,7 @@ public class DefaultPluginManager
|
|||
|
||||
PlexusConfiguration mergedConfiguration = mergeMojoConfiguration( pomConfiguration, mojoDescriptor );
|
||||
|
||||
// TODO: plexus changes to make this more like the component descriptor so this can be used instead
|
||||
// PlexusConfiguration mergedConfiguration = mergeConfiguration( pomConfiguration,
|
||||
// mojoDescriptor.getConfiguration() );
|
||||
|
||||
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution, pathTranslator, logger, session.getExecutionProperties() );
|
||||
ExpressionEvaluator expressionEvaluator = new PluginParameterExpressionEvaluator( session, mojoExecution );
|
||||
|
||||
PlexusConfiguration extractedMojoConfiguration = extractMojoConfiguration( mergedConfiguration, mojoDescriptor );
|
||||
|
||||
|
@ -1092,17 +1088,54 @@ public class DefaultPluginManager
|
|||
// Artifact downloading
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
private void downloadDependencies( MavenSession session, String scope )
|
||||
//TODO: This needs to be moved out of here, and there needs to be some interplay between the lifecycle executor and the plugin manager.
|
||||
private void downloadProjectDependencies( MavenSession session, String scope )
|
||||
throws ArtifactResolutionException, ArtifactNotFoundException, InvalidDependencyVersionException
|
||||
{
|
||||
resolveTransitiveDependencies( session, scope );
|
||||
{
|
||||
MavenProject project = session.getCurrentProject();
|
||||
|
||||
// TODO: such a call in MavenMetadataSource too - packaging not really the intention of type
|
||||
Artifact artifact = repositorySystem.createArtifact( project.getGroupId(), project.getArtifactId(), project.getVersion(), null, project.getPackaging() );
|
||||
|
||||
// TODO: we don't need to resolve over and over again, as long as we are sure that the parameters are the same
|
||||
// check this with yourkit as a hot spot.
|
||||
// Don't recreate if already created - for effeciency, and because clover plugin adds to it
|
||||
if ( project.getDependencyArtifacts() == null )
|
||||
{
|
||||
// NOTE: Don't worry about covering this case with the error-reporter bindings...it's already handled by the project error reporter.
|
||||
try
|
||||
{
|
||||
project.setDependencyArtifacts( repositorySystem.createArtifacts( project.getDependencies(), null, null, project ) );
|
||||
}
|
||||
catch ( VersionNotFoundException e )
|
||||
{
|
||||
throw new InvalidDependencyVersionException( e.getProjectId(), e.getDependency(), e.getPomFile(), e.getCauseException() );
|
||||
}
|
||||
}
|
||||
|
||||
ArtifactFilter filter = new ScopeArtifactFilter( scope );
|
||||
|
||||
ArtifactResolutionRequest request = new ArtifactResolutionRequest()
|
||||
.setArtifact( artifact )
|
||||
.setResolveRoot( false )
|
||||
.setArtifactDependencies( project.getDependencyArtifacts() )
|
||||
.setLocalRepository( session.getLocalRepository() )
|
||||
.setRemoteRepostories( project.getRemoteArtifactRepositories() )
|
||||
.setManagedVersionMap( project.getManagedVersionMap() )
|
||||
.setFilter( filter );
|
||||
|
||||
ArtifactResolutionResult result = repositorySystem.resolve( request );
|
||||
|
||||
resolutionErrorHandler.throwErrors( request, result );
|
||||
|
||||
project.setArtifacts( result.getArtifacts() );
|
||||
|
||||
ArtifactRepository localRepository = session.getLocalRepository();
|
||||
List<ArtifactRepository> remoteArtifactRepositories = session.getCurrentProject().getRemoteArtifactRepositories();
|
||||
|
||||
for ( Artifact artifact : session.getCurrentProject().getArtifacts() )
|
||||
for ( Artifact projectArtifact : session.getCurrentProject().getArtifacts() )
|
||||
{
|
||||
repositorySystem.resolve( new ArtifactResolutionRequest( artifact, localRepository, remoteArtifactRepositories ) );
|
||||
repositorySystem.resolve( new ArtifactResolutionRequest( projectArtifact, localRepository, remoteArtifactRepositories ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,46 +26,32 @@ import org.apache.maven.execution.MavenSession;
|
|||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
|
||||
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.util.introspection.ReflectionValueExtractor;
|
||||
|
||||
/**
|
||||
* @author Jason van Zyl
|
||||
* @version $Id$
|
||||
* @todo belong in MavenSession, so it only gets created once?
|
||||
*/
|
||||
public class PluginParameterExpressionEvaluator
|
||||
implements ExpressionEvaluator
|
||||
{
|
||||
private final PathTranslator pathTranslator;
|
||||
private MavenSession session;
|
||||
|
||||
private final MavenSession context;
|
||||
private MojoExecution mojoExecution;
|
||||
|
||||
private final Logger logger;
|
||||
private MavenProject project;
|
||||
|
||||
private final MojoExecution mojoExecution;
|
||||
private String basedir;
|
||||
|
||||
private final MavenProject project;
|
||||
|
||||
private final String basedir;
|
||||
|
||||
private final Properties properties;
|
||||
|
||||
public PluginParameterExpressionEvaluator( MavenSession context,
|
||||
MojoExecution mojoExecution,
|
||||
PathTranslator pathTranslator,
|
||||
Logger logger,
|
||||
Properties properties )
|
||||
private Properties properties;
|
||||
|
||||
public PluginParameterExpressionEvaluator( MavenSession session, MojoExecution mojoExecution )
|
||||
{
|
||||
this.context = context;
|
||||
this.session = session;
|
||||
this.mojoExecution = mojoExecution;
|
||||
this.pathTranslator = pathTranslator;
|
||||
this.logger = logger;
|
||||
this.properties = properties;
|
||||
project = context.getCurrentProject();
|
||||
this.properties = session.getExecutionProperties();
|
||||
project = session.getCurrentProject();
|
||||
|
||||
String basedir = null;
|
||||
|
||||
|
@ -80,50 +66,9 @@ public class PluginParameterExpressionEvaluator
|
|||
}
|
||||
}
|
||||
|
||||
if ( ( basedir == null ) && ( context != null ) )
|
||||
if ( ( basedir == null ) && ( session != null ) )
|
||||
{
|
||||
basedir = context.getExecutionRootDirectory();
|
||||
}
|
||||
|
||||
if ( basedir == null )
|
||||
{
|
||||
basedir = System.getProperty( "user.dir" );
|
||||
}
|
||||
|
||||
this.basedir = basedir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link PluginParameterExpressionEvaluator#PluginParameterExpressionEvaluator(MavenSession, MojoExecution, PathTranslator, LifecycleExecutionContext, Logger, Properties)}
|
||||
* instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public PluginParameterExpressionEvaluator( MavenSession context,
|
||||
MojoExecution mojoExecution,
|
||||
PathTranslator pathTranslator,
|
||||
Logger logger,
|
||||
MavenProject project,
|
||||
Properties properties )
|
||||
{
|
||||
this.context = context;
|
||||
this.mojoExecution = mojoExecution;
|
||||
this.pathTranslator = pathTranslator;
|
||||
this.logger = logger;
|
||||
this.properties = properties;
|
||||
|
||||
this.project = project;
|
||||
|
||||
String basedir = null;
|
||||
|
||||
if ( project != null )
|
||||
{
|
||||
File projectFile = project.getFile();
|
||||
|
||||
// this should always be the case for non-super POM instances...
|
||||
if ( projectFile != null )
|
||||
{
|
||||
basedir = projectFile.getParentFile().getAbsolutePath();
|
||||
}
|
||||
basedir = session.getExecutionRootDirectory();
|
||||
}
|
||||
|
||||
if ( basedir == null )
|
||||
|
@ -193,15 +138,15 @@ public class PluginParameterExpressionEvaluator
|
|||
|
||||
if ( "localRepository".equals( expression ) )
|
||||
{
|
||||
value = context.getLocalRepository();
|
||||
value = session.getLocalRepository();
|
||||
}
|
||||
else if ( "session".equals( expression ) )
|
||||
{
|
||||
value = context;
|
||||
value = session;
|
||||
}
|
||||
else if ( "reactorProjects".equals( expression ) )
|
||||
{
|
||||
value = context.getSortedProjects();
|
||||
value = session.getSortedProjects();
|
||||
}
|
||||
else if ("mojoExecution".equals(expression))
|
||||
{
|
||||
|
@ -299,7 +244,7 @@ public class PluginParameterExpressionEvaluator
|
|||
}
|
||||
else if ( "settings".equals( expression ) )
|
||||
{
|
||||
value = context.getSettings();
|
||||
value = session.getSettings();
|
||||
}
|
||||
else if ( expression.startsWith( "settings" ) )
|
||||
{
|
||||
|
@ -310,12 +255,12 @@ public class PluginParameterExpressionEvaluator
|
|||
if ( pathSeparator > 0 )
|
||||
{
|
||||
String pathExpression = expression.substring( 1, pathSeparator );
|
||||
value = ReflectionValueExtractor.evaluate( pathExpression, context.getSettings() );
|
||||
value = ReflectionValueExtractor.evaluate( pathExpression, session.getSettings() );
|
||||
value = value + expression.substring( pathSeparator );
|
||||
}
|
||||
else
|
||||
{
|
||||
value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), context.getSettings() );
|
||||
value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), session.getSettings() );
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
|
@ -337,10 +282,6 @@ public class PluginParameterExpressionEvaluator
|
|||
{
|
||||
value = basedir + expression.substring( pathSeparator );
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.error( "Got expression '" + expression + "' that was not recognised" );
|
||||
}
|
||||
}
|
||||
|
||||
if ( value == null )
|
||||
|
@ -399,22 +340,6 @@ public class PluginParameterExpressionEvaluator
|
|||
|
||||
public File alignToBaseDirectory( File file )
|
||||
{
|
||||
File basedir;
|
||||
|
||||
if ( ( project != null ) && ( project.getFile() != null ) )
|
||||
{
|
||||
basedir = project.getFile().getParentFile();
|
||||
}
|
||||
else if ( ( context != null ) && ( context.getExecutionRootDirectory() != null ) )
|
||||
{
|
||||
basedir = new File( context.getExecutionRootDirectory() ).getAbsoluteFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
basedir = new File( "." ).getAbsoluteFile().getParentFile();
|
||||
}
|
||||
|
||||
return new File( pathTranslator.alignToBaseDirectory( file.getPath(), basedir ) );
|
||||
return file;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import org.apache.maven.artifact.repository.ArtifactRepository;
|
|||
import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.plugin.MavenPluginCollector;
|
||||
import org.apache.maven.plugin.MavenPluginDiscoverer;
|
||||
import org.apache.maven.project.DefaultProjectBuilderConfiguration;
|
||||
|
@ -20,7 +21,7 @@ import org.codehaus.plexus.PlexusTestCase;
|
|||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
public abstract class AbstractCoreMavenComponentTest
|
||||
public abstract class AbstractCoreMavenComponentTestCase
|
||||
extends PlexusTestCase
|
||||
{
|
||||
@Requirement
|
||||
|
@ -34,11 +35,11 @@ public abstract class AbstractCoreMavenComponentTest
|
|||
{
|
||||
super.setUp();
|
||||
repositorySystem = lookup( RepositorySystem.class );
|
||||
projectBuilder = lookup( MavenProjectBuilder.class );
|
||||
projectBuilder = lookup( MavenProjectBuilder.class );
|
||||
}
|
||||
|
||||
abstract protected String getProjectsDirectory();
|
||||
|
||||
|
||||
protected File getProject( String name )
|
||||
throws Exception
|
||||
{
|
||||
|
@ -96,11 +97,28 @@ public abstract class AbstractCoreMavenComponentTest
|
|||
.setLocalRepository( request.getLocalRepository() )
|
||||
.setRemoteRepositories( request.getRemoteRepositories() );
|
||||
|
||||
// We just need to use the configuration, and get the POM from that.
|
||||
MavenProject project = projectBuilder.build( pom, configuration );
|
||||
MavenProject project = null;
|
||||
|
||||
if ( pom != null )
|
||||
{
|
||||
project = projectBuilder.build( pom, configuration );
|
||||
}
|
||||
else
|
||||
{
|
||||
project = createStubMavenProject();
|
||||
}
|
||||
|
||||
MavenSession session = new MavenSession( getContainer(), request, project );
|
||||
|
||||
return session;
|
||||
}
|
||||
|
||||
protected MavenProject createStubMavenProject()
|
||||
{
|
||||
Model model = new Model();
|
||||
model.setGroupId( "org.apache.maven.test" );
|
||||
model.setArtifactId( "maven-test" );
|
||||
model.setVersion( "1.0" );
|
||||
return new MavenProject( model );
|
||||
}
|
||||
}
|
|
@ -7,7 +7,7 @@ import org.apache.maven.execution.MavenExecutionResult;
|
|||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
||||
public class MavenTest
|
||||
extends AbstractCoreMavenComponentTest
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
@Requirement
|
||||
private Maven maven;
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.apache.maven.lifecycle;
|
|||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.AbstractCoreMavenComponentTest;
|
||||
import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.plugin.MojoExecution;
|
||||
import org.apache.maven.plugin.PluginManager;
|
||||
|
@ -12,7 +12,7 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
|||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
||||
public class LifecycleExecutorTest
|
||||
extends AbstractCoreMavenComponentTest
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
@Requirement
|
||||
private DefaultLifecycleExecutor lifecycleExecutor;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package org.apache.maven.plugin;
|
||||
|
||||
import org.apache.maven.AbstractCoreMavenComponentTest;
|
||||
import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
|
@ -8,7 +8,7 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
|||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
|
||||
public class PluginManagerTest
|
||||
extends AbstractCoreMavenComponentTest
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
@Requirement
|
||||
private PluginManager pluginManager;
|
||||
|
@ -153,6 +153,8 @@ public class PluginManagerTest
|
|||
|
||||
// test interpolation of basedir values in mojo configuration
|
||||
|
||||
// test a build where projects use different versions of the same plugin
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// Testing help
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -27,6 +27,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.ArtifactUtils;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
|
@ -38,22 +39,15 @@ import org.apache.maven.execution.DefaultMavenExecutionRequest;
|
|||
import org.apache.maven.execution.DuplicateProjectException;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.execution.ReactorManager;
|
||||
import org.apache.maven.model.Build;
|
||||
import org.apache.maven.model.Model;
|
||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||
import org.apache.maven.plugin.descriptor.PluginDescriptor;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.path.PathTranslator;
|
||||
import org.codehaus.plexus.MutablePlexusContainer;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
|
||||
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
|
||||
import org.codehaus.plexus.logging.Logger;
|
||||
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
||||
import org.codehaus.plexus.util.dag.CycleDetectedException;
|
||||
import org.easymock.MockControl;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -62,33 +56,27 @@ import org.easymock.MockControl;
|
|||
* 06:06:21 jdcasey Exp $
|
||||
*/
|
||||
public class PluginParameterExpressionEvaluatorTest
|
||||
extends PlexusTestCase
|
||||
extends AbstractCoreMavenComponentTestCase
|
||||
{
|
||||
private static final String FS = System.getProperty( "file.separator" );
|
||||
|
||||
private ArtifactFactory factory;
|
||||
|
||||
private PathTranslator pathTranslator;
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
factory = lookup( ArtifactFactory.class );
|
||||
pathTranslator = lookup( PathTranslator.class );
|
||||
factory = lookup( ArtifactFactory.class );
|
||||
}
|
||||
|
||||
|
||||
public void testPluginDescriptorExpressionReference()
|
||||
throws ExpressionEvaluationException, CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
MojoExecution exec = newMojoExecution();
|
||||
|
||||
MavenSession session = newMavenSession();
|
||||
|
||||
Logger logger = new ConsoleLogger( Logger.LEVEL_INFO, "test" );
|
||||
|
||||
Object result = new PluginParameterExpressionEvaluator( session, exec, pathTranslator,
|
||||
logger, new Properties() ).evaluate( "${plugin}" );
|
||||
Object result = new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin}" );
|
||||
|
||||
System.out.println( "Result: " + result );
|
||||
|
||||
|
@ -98,7 +86,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
}
|
||||
|
||||
public void testPluginArtifactsExpressionReference()
|
||||
throws ExpressionEvaluationException, CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
MojoExecution exec = newMojoExecution();
|
||||
|
||||
|
@ -116,10 +104,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
|
||||
MavenSession session = newMavenSession();
|
||||
|
||||
Logger logger = new ConsoleLogger( Logger.LEVEL_INFO, "test" );
|
||||
|
||||
List depResults = (List) new PluginParameterExpressionEvaluator( session, exec, pathTranslator,
|
||||
logger, new Properties() ).evaluate( "${plugin.artifacts}" );
|
||||
List depResults = (List) new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin.artifacts}" );
|
||||
|
||||
System.out.println( "Result: " + depResults );
|
||||
|
||||
|
@ -129,7 +114,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
}
|
||||
|
||||
public void testPluginArtifactMapExpressionReference()
|
||||
throws ExpressionEvaluationException, CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
MojoExecution exec = newMojoExecution();
|
||||
|
||||
|
@ -147,11 +132,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
|
||||
MavenSession session = newMavenSession();
|
||||
|
||||
Logger logger = new ConsoleLogger( Logger.LEVEL_INFO, "test" );
|
||||
|
||||
Map depResults = (Map) new PluginParameterExpressionEvaluator( session, exec,
|
||||
pathTranslator, logger,
|
||||
new Properties() ).evaluate( "${plugin.artifactMap}" );
|
||||
Map depResults = (Map) new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin.artifactMap}" );
|
||||
|
||||
System.out.println( "Result: " + depResults );
|
||||
|
||||
|
@ -163,16 +144,13 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
}
|
||||
|
||||
public void testPluginArtifactIdExpressionReference()
|
||||
throws ExpressionEvaluationException, CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
MojoExecution exec = newMojoExecution();
|
||||
|
||||
MavenSession session = newMavenSession();
|
||||
|
||||
Logger logger = new ConsoleLogger( Logger.LEVEL_INFO, "test" );
|
||||
|
||||
Object result = new PluginParameterExpressionEvaluator( session, exec, pathTranslator,
|
||||
logger, new Properties() ).evaluate( "${plugin.artifactId}" );
|
||||
Object result = new PluginParameterExpressionEvaluator( session, exec ).evaluate( "${plugin.artifactId}" );
|
||||
|
||||
System.out.println( "Result: " + result );
|
||||
|
||||
|
@ -339,11 +317,11 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
assertEquals( "value", value );
|
||||
}
|
||||
|
||||
private static MavenSession createSession( PlexusContainer container, ArtifactRepository repo )
|
||||
private static MavenSession createSession( PlexusContainer container, ArtifactRepository repo, Properties properties )
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
{
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
|
||||
.setProperties( new Properties() )
|
||||
.setProperties( properties )
|
||||
.setGoals( Collections.EMPTY_LIST )
|
||||
.setBaseDirectory( new File( "" ) )
|
||||
.setLocalRepository( repo );
|
||||
|
@ -416,7 +394,8 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
ArtifactRepository repo = new DefaultArtifactRepository( "local", "target/repo", repoLayout );
|
||||
|
||||
MutablePlexusContainer container = (MutablePlexusContainer) getContainer();
|
||||
MavenSession session = createSession( container, repo );
|
||||
MavenSession session = createSession( container, repo, executionProperties );
|
||||
session.setCurrentProject( project );
|
||||
|
||||
MojoDescriptor mojo = new MojoDescriptor();
|
||||
mojo.setPluginDescriptor( pluginDescriptor );
|
||||
|
@ -424,7 +403,7 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
|
||||
MojoExecution mojoExecution = new MojoExecution( mojo );
|
||||
|
||||
return new PluginParameterExpressionEvaluator( session, mojoExecution, null, container.getLogger(), project, executionProperties );
|
||||
return new PluginParameterExpressionEvaluator( session, mojoExecution );
|
||||
}
|
||||
|
||||
protected Artifact createArtifact( String groupId,
|
||||
|
@ -454,19 +433,15 @@ public class PluginParameterExpressionEvaluatorTest
|
|||
}
|
||||
|
||||
private MavenSession newMavenSession()
|
||||
throws CycleDetectedException, DuplicateProjectException
|
||||
throws Exception
|
||||
{
|
||||
Model model = new Model();
|
||||
model.setGroupId( "group" );
|
||||
model.setArtifactId( "artifact" );
|
||||
model.setVersion( "1" );
|
||||
return createMavenSession( null );
|
||||
}
|
||||
|
||||
MavenProject project = new MavenProject( model );
|
||||
ReactorManager rm = new ReactorManager( Collections.singletonList( project ), ReactorManager.FAIL_FAST );
|
||||
MockControl mockMavenExecutionRequest = MockControl.createControl( MavenExecutionRequest.class );
|
||||
MavenExecutionRequest req = (MavenExecutionRequest) mockMavenExecutionRequest.getMock();
|
||||
MavenSession session = new MavenSession( req );
|
||||
|
||||
return session;
|
||||
@Override
|
||||
protected String getProjectsDirectory()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you 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.
|
||||
-->
|
||||
|
||||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.project.MavenProjectBuilder</role>
|
||||
<implementation>org.apache.maven.project.DefaultMavenProjectBuilder</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.validation.ModelValidator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.project.path.PathTranslator</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.factory.ArtifactFactory</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.resolver.ArtifactResolver</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
Loading…
Reference in New Issue