mirror of https://github.com/apache/maven.git
git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@757141 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
70785ffebf
commit
ac8db28f3b
|
@ -30,7 +30,6 @@ import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
|
|||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
import org.apache.maven.execution.ReactorManager;
|
||||
import org.apache.maven.lifecycle.mapping.LifecycleMapping;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
import org.apache.maven.model.ReportPlugin;
|
||||
|
@ -54,7 +53,6 @@ import org.apache.maven.plugin.lifecycle.Phase;
|
|||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.reporting.MavenReport;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
@ -80,6 +78,9 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
private Map phaseToLifecycleMap;
|
||||
|
||||
@Requirement
|
||||
private Map<String,LifecycleMapping> lifecycleMappings;
|
||||
|
||||
public List<String> getLifecyclePhases()
|
||||
{
|
||||
for ( Lifecycle lifecycle : lifecycles )
|
||||
|
@ -976,8 +977,6 @@ public class DefaultLifecycleExecutor
|
|||
{
|
||||
Map mappings = findMappingsForLifecycle( session, project, lifecycle );
|
||||
|
||||
List optionalMojos = findOptionalMojosForLifecycle( session, project, lifecycle );
|
||||
|
||||
Map lifecycleMappings = new HashMap();
|
||||
|
||||
for ( Iterator i = lifecycle.getPhases().iterator(); i.hasNext(); )
|
||||
|
@ -1030,18 +1029,9 @@ public class DefaultLifecycleExecutor
|
|||
|
||||
if ( mappings == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging );
|
||||
mappings = m.getPhases( lifecycle.getId() );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
if ( defaultMappings == null )
|
||||
{
|
||||
throw new LifecycleExecutionException( "Cannot find lifecycle mapping for packaging: \'" + packaging + "\'.", e );
|
||||
}
|
||||
}
|
||||
m = lifecycleMappings.get( packaging );
|
||||
|
||||
mappings = m.getPhases( lifecycle.getId() );
|
||||
}
|
||||
|
||||
if ( mappings == null )
|
||||
|
@ -1059,35 +1049,6 @@ public class DefaultLifecycleExecutor
|
|||
return mappings;
|
||||
}
|
||||
|
||||
private List findOptionalMojosForLifecycle( MavenSession session, MavenProject project, Lifecycle lifecycle )
|
||||
throws LifecycleExecutionException, PluginNotFoundException
|
||||
{
|
||||
String packaging = project.getPackaging();
|
||||
List optionalMojos = null;
|
||||
|
||||
LifecycleMapping m;
|
||||
|
||||
if ( optionalMojos == null )
|
||||
{
|
||||
try
|
||||
{
|
||||
m = (LifecycleMapping) session.lookup( LifecycleMapping.ROLE, packaging );
|
||||
optionalMojos = m.getOptionalMojos( lifecycle.getId() );
|
||||
}
|
||||
catch ( ComponentLookupException e )
|
||||
{
|
||||
getLogger().debug( "Error looking up lifecycle mapping to retrieve optional mojos. Lifecycle ID: " + lifecycle.getId() + ". Error: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( optionalMojos == null )
|
||||
{
|
||||
optionalMojos = Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
return optionalMojos;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take each mojo contained with a plugin, look to see whether it contributes to a phase in the
|
||||
* lifecycle and if it does place it at the end of the list of goals to execute for that given
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package org.apache.maven.lifecycle;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DefaultLifecycleMapping
|
||||
implements LifecycleMapping
|
||||
{
|
||||
private List<Lifecycle> lifecycles;
|
||||
|
||||
private Map<String,Lifecycle> lifecycleMap;
|
||||
|
||||
public Map getPhases( String lifecycleId )
|
||||
{
|
||||
if ( lifecycleMap == null )
|
||||
{
|
||||
lifecycleMap = new HashMap();
|
||||
|
||||
if ( lifecycles != null )
|
||||
{
|
||||
for ( Lifecycle lifecycle : lifecycles )
|
||||
{
|
||||
lifecycleMap.put( lifecycle.getId(), lifecycle );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Lifecycle lifecycle = (Lifecycle) lifecycleMap.get( lifecycleId );
|
||||
|
||||
Map<String,String> mappings = new HashMap<String,String>();
|
||||
|
||||
for( String phase : lifecycle.getPhases() )
|
||||
{
|
||||
mappings.put( phase, phase );
|
||||
}
|
||||
|
||||
return mappings;
|
||||
}
|
||||
}
|
|
@ -36,13 +36,13 @@ public class Lifecycle
|
|||
/**
|
||||
* Field phases
|
||||
*/
|
||||
private List phases;
|
||||
private List<String> phases;
|
||||
|
||||
/**
|
||||
* default phases.
|
||||
*/
|
||||
private Map defaultPhases;
|
||||
|
||||
|
||||
/**
|
||||
* Method addPhase
|
||||
*
|
||||
|
@ -64,11 +64,11 @@ public class Lifecycle
|
|||
/**
|
||||
* Method getPhases
|
||||
*/
|
||||
public List getPhases()
|
||||
public List<String> getPhases()
|
||||
{
|
||||
if ( this.phases == null )
|
||||
{
|
||||
this.phases = new ArrayList();
|
||||
this.phases = new ArrayList<String>();
|
||||
}
|
||||
|
||||
return this.phases;
|
||||
|
@ -97,5 +97,5 @@ public class Lifecycle
|
|||
public Map getDefaultPhases()
|
||||
{
|
||||
return defaultPhases;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.apache.maven.lifecycle.mapping;
|
||||
package org.apache.maven.lifecycle;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -19,7 +19,6 @@ package org.apache.maven.lifecycle.mapping;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -29,8 +28,6 @@ import java.util.Map;
|
|||
public interface LifecycleMapping
|
||||
{
|
||||
String ROLE = LifecycleMapping.class.getName();
|
||||
|
||||
List getOptionalMojos( String lifecycle );
|
||||
|
||||
|
||||
Map getPhases( String lifecycle );
|
||||
}
|
|
@ -1,103 +0,0 @@
|
|||
package org.apache.maven.lifecycle.mapping;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Lifecycle mapping for a POM.
|
||||
*
|
||||
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DefaultLifecycleMapping
|
||||
implements LifecycleMapping
|
||||
{
|
||||
private List lifecycles;
|
||||
|
||||
private Map lifecycleMap;
|
||||
|
||||
/** @deprecated use lifecycles instead */
|
||||
private Map phases;
|
||||
|
||||
public List getOptionalMojos( String lifecycle )
|
||||
{
|
||||
if ( lifecycleMap == null )
|
||||
{
|
||||
lifecycleMap = new HashMap();
|
||||
|
||||
if ( lifecycles != null )
|
||||
{
|
||||
for ( Iterator i = lifecycles.iterator(); i.hasNext(); )
|
||||
{
|
||||
Lifecycle l = (Lifecycle) i.next();
|
||||
lifecycleMap.put( l.getId(), l );
|
||||
}
|
||||
}
|
||||
}
|
||||
Lifecycle l = (Lifecycle) lifecycleMap.get( lifecycle );
|
||||
|
||||
if ( l != null )
|
||||
{
|
||||
return l.getOptionalMojos();
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Map getPhases( String lifecycle )
|
||||
{
|
||||
if ( lifecycleMap == null )
|
||||
{
|
||||
lifecycleMap = new HashMap();
|
||||
|
||||
if ( lifecycles != null )
|
||||
{
|
||||
for ( Iterator i = lifecycles.iterator(); i.hasNext(); )
|
||||
{
|
||||
Lifecycle l = (Lifecycle) i.next();
|
||||
lifecycleMap.put( l.getId(), l );
|
||||
}
|
||||
}
|
||||
}
|
||||
Lifecycle l = (Lifecycle) lifecycleMap.get( lifecycle );
|
||||
|
||||
Map mappings = null;
|
||||
if ( l == null )
|
||||
{
|
||||
if ( "default".equals( lifecycle ) )
|
||||
{
|
||||
mappings = phases;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mappings = l.getPhases();
|
||||
}
|
||||
|
||||
return mappings;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
package org.apache.maven.lifecycle.mapping;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Class Lifecycle.
|
||||
*/
|
||||
public class Lifecycle
|
||||
{
|
||||
/**
|
||||
* Field id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Field phases
|
||||
*/
|
||||
private Map phases;
|
||||
|
||||
private List optionalMojos = new ArrayList();
|
||||
|
||||
/**
|
||||
* Method getId
|
||||
*/
|
||||
public String getId()
|
||||
{
|
||||
return this.id;
|
||||
} //-- String getId()
|
||||
|
||||
/**
|
||||
* Method getPhases
|
||||
*/
|
||||
public Map getPhases()
|
||||
{
|
||||
return this.phases;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setId
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setId( String id )
|
||||
{
|
||||
this.id = id;
|
||||
} //-- void setId(String)
|
||||
|
||||
public void addOptionalMojo( String optionalMojo )
|
||||
{
|
||||
this.optionalMojos.add( optionalMojo );
|
||||
}
|
||||
|
||||
public void setOptionalMojos( List optionalMojos )
|
||||
{
|
||||
this.optionalMojos = optionalMojos;
|
||||
}
|
||||
|
||||
public List getOptionalMojos()
|
||||
{
|
||||
return this.optionalMojos;
|
||||
}
|
||||
}
|
|
@ -162,30 +162,19 @@ public class DefaultPluginManager
|
|||
{
|
||||
return pluginDescriptor;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
String pluginVersion = plugin.getVersion();
|
||||
|
||||
logger.debug( "Resolving plugin: " + plugin.getKey() + " with version: " + pluginVersion );
|
||||
|
||||
if ( ( pluginVersion == null ) || Artifact.LATEST_VERSION.equals( pluginVersion ) || Artifact.RELEASE_VERSION.equals( pluginVersion ) )
|
||||
{
|
||||
logger.debug( "Resolving version for plugin: " + plugin.getKey() );
|
||||
|
||||
pluginVersion = resolvePluginVersion( plugin.getGroupId(), plugin.getArtifactId(), project, session );
|
||||
|
||||
plugin.setVersion( pluginVersion );
|
||||
|
||||
logger.debug( "Resolved to version: " + pluginVersion );
|
||||
}
|
||||
|
||||
resolvePluginVersion( plugin, project, session );
|
||||
|
||||
addPlugin( plugin, project, session );
|
||||
|
||||
// This does not appear to be caching anything really.
|
||||
pluginDescriptor = pluginCollector.getPluginDescriptor( plugin );
|
||||
|
||||
project.addPlugin( plugin );
|
||||
|
||||
System.out.println( "AAA loading plugin " + pluginDescriptor.getArtifactId() + ":" + pluginDescriptor.getVersion() );
|
||||
System.out.println( "BBB realm: " + pluginDescriptor.getClassRealm() );
|
||||
|
||||
return pluginDescriptor;
|
||||
}
|
||||
|
@ -732,6 +721,7 @@ public class DefaultPluginManager
|
|||
PluginDescriptor pluginDescriptor = mojoDescriptor.getPluginDescriptor();
|
||||
|
||||
ClassRealm pluginRealm = pluginDescriptor.getClassRealm();
|
||||
System.out.println( "XXX Looking for class realm " + pluginDescriptor.getArtifactId() + ":" + pluginDescriptor.getVersion() );
|
||||
|
||||
// We are forcing the use of the plugin realm for all lookups that might occur during
|
||||
// the lifecycle that is part of the lookup. Here we are specifically trying to keep
|
||||
|
@ -1489,20 +1479,29 @@ public class DefaultPluginManager
|
|||
return ModelMarshaller.unmarshalModelPropertiesToXml( modelProperties, ProjectUri.baseUri );
|
||||
}
|
||||
|
||||
public String resolvePluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
|
||||
public void resolvePluginVersion( Plugin plugin, MavenProject project, MavenSession session )
|
||||
throws PluginVersionResolutionException, InvalidPluginException, PluginVersionNotFoundException
|
||||
{
|
||||
String version = null;
|
||||
{
|
||||
String version = plugin.getVersion();
|
||||
|
||||
if ( version != null && !Artifact.RELEASE_VERSION.equals( version ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String groupId = plugin.getGroupId();
|
||||
|
||||
String artifactId = plugin.getArtifactId();
|
||||
|
||||
if ( project.getBuildPlugins() != null )
|
||||
{
|
||||
for ( Iterator it = project.getBuildPlugins().iterator(); it.hasNext() && ( version == null ); )
|
||||
{
|
||||
Plugin plugin = (Plugin) it.next();
|
||||
Plugin p = (Plugin) it.next();
|
||||
|
||||
if ( groupId.equals( plugin.getGroupId() ) && artifactId.equals( plugin.getArtifactId() ) )
|
||||
if ( groupId.equals( p.getGroupId() ) && artifactId.equals( p.getArtifactId() ) )
|
||||
{
|
||||
version = plugin.getVersion();
|
||||
version = p.getVersion();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1522,7 +1521,7 @@ public class DefaultPluginManager
|
|||
throw new PluginVersionNotFoundException( groupId, artifactId );
|
||||
}
|
||||
|
||||
return version;
|
||||
plugin.setVersion( version );
|
||||
}
|
||||
|
||||
public String resolveReportPluginVersion( String groupId, String artifactId, MavenProject project, MavenSession session )
|
||||
|
@ -1616,6 +1615,7 @@ public class DefaultPluginManager
|
|||
|
||||
ArtifactRepository localRepository = session.getLocalRepository();
|
||||
|
||||
// We need the POM for the actually plugin project so we can look at the prerequisite element.
|
||||
MavenProject pluginProject = buildPluginProject( plugin, localRepository, project.getRemoteArtifactRepositories() );
|
||||
|
||||
Artifact pluginArtifact = repositorySystem.createPluginArtifact( plugin );
|
||||
|
@ -1819,5 +1819,5 @@ public class DefaultPluginManager
|
|||
{
|
||||
throw new PluginLoaderException( plugin, "Failed to load plugin. Reason: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,22 +25,18 @@ problem.
|
|||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
|
||||
<role>org.apache.maven.lifecycle.LifecycleMapping</role>
|
||||
<role-hint>pom</role-hint>
|
||||
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
|
||||
<implementation>org.apache.maven.lifecycle.DefaultLifecycleMapping</implementation>
|
||||
<configuration>
|
||||
<lifecycles>
|
||||
<lifecycle>
|
||||
<id>default</id>
|
||||
<!-- START SNIPPET: pom-lifecycle -->
|
||||
<phases>
|
||||
<package>org.apache.maven.plugins:maven-site-plugin:attach-descriptor</package>
|
||||
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
|
||||
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
|
||||
</phases>
|
||||
<optional-mojos>
|
||||
<optional-mojo>org.apache.maven.plugins:maven-site-plugin:attach-descriptor</optional-mojo>
|
||||
</optional-mojos>
|
||||
<!-- END SNIPPET: pom-lifecycle -->
|
||||
</lifecycle>
|
||||
</lifecycles>
|
||||
|
@ -62,9 +58,9 @@ problem.
|
|||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
|
||||
<role>org.apache.maven.lifecycle.LifecycleMapping</role>
|
||||
<role-hint>jar</role-hint>
|
||||
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
|
||||
<implementation>org.apache.maven.lifecycle.DefaultLifecycleMapping</implementation>
|
||||
<configuration>
|
||||
<lifecycles>
|
||||
<lifecycle>
|
||||
|
@ -73,9 +69,7 @@ problem.
|
|||
<phases>
|
||||
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
|
||||
<compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
|
||||
<process-test-resources>
|
||||
org.apache.maven.plugins:maven-resources-plugin:testResources
|
||||
</process-test-resources>
|
||||
<process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
|
||||
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
|
||||
<test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
|
||||
<package>
|
||||
|
@ -106,10 +100,10 @@ problem.
|
|||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping
|
||||
<role>org.apache.maven.lifecycle.LifecycleMapping
|
||||
</role>
|
||||
<role-hint>ejb</role-hint>
|
||||
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping
|
||||
<implementation>org.apache.maven.lifecycle.DefaultLifecycleMapping
|
||||
</implementation>
|
||||
<configuration>
|
||||
<lifecycles>
|
||||
|
@ -168,9 +162,9 @@ problem.
|
|||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
|
||||
<role>org.apache.maven.lifecycle.LifecycleMapping</role>
|
||||
<role-hint>ejb3</role-hint>
|
||||
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
|
||||
<implementation>org.apache.maven.lifecycle.DefaultLifecycleMapping</implementation>
|
||||
<configuration>
|
||||
<!-- START SNIPPET: ejb3-lifecycle -->
|
||||
<phases>
|
||||
|
@ -223,9 +217,9 @@ problem.
|
|||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
|
||||
<role>org.apache.maven.lifecycle.LifecycleMapping</role>
|
||||
<role-hint>maven-plugin</role-hint>
|
||||
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
|
||||
<implementation>org.apache.maven.lifecycle.DefaultLifecycleMapping</implementation>
|
||||
<configuration>
|
||||
<lifecycles>
|
||||
<lifecycle>
|
||||
|
@ -308,9 +302,9 @@ problem.
|
|||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
|
||||
<role>org.apache.maven.lifecycle.LifecycleMapping</role>
|
||||
<role-hint>war</role-hint>
|
||||
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
|
||||
<implementation>org.apache.maven.lifecycle.DefaultLifecycleMapping</implementation>
|
||||
<configuration>
|
||||
<lifecycles>
|
||||
<lifecycle>
|
||||
|
@ -350,9 +344,9 @@ problem.
|
|||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
|
||||
<role>org.apache.maven.lifecycle.LifecycleMapping</role>
|
||||
<role-hint>ear</role-hint>
|
||||
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
|
||||
<implementation>org.apache.maven.lifecycle.DefaultLifecycleMapping</implementation>
|
||||
<configuration>
|
||||
<lifecycles>
|
||||
<lifecycle>
|
||||
|
@ -389,9 +383,9 @@ problem.
|
|||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
|
||||
<role>org.apache.maven.lifecycle.LifecycleMapping</role>
|
||||
<role-hint>rar</role-hint>
|
||||
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
|
||||
<implementation>org.apache.maven.lifecycle.DefaultLifecycleMapping</implementation>
|
||||
<configuration>
|
||||
<lifecycles>
|
||||
<lifecycle>
|
||||
|
@ -431,9 +425,9 @@ problem.
|
|||
</configuration>
|
||||
</component>
|
||||
<component>
|
||||
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
|
||||
<role>org.apache.maven.lifecycle.LifecycleMapping</role>
|
||||
<role-hint>par</role-hint>
|
||||
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
|
||||
<implementation>org.apache.maven.lifecycle.DefaultLifecycleMapping</implementation>
|
||||
<configuration>
|
||||
<!-- START SNIPPET: par-lifecycle -->
|
||||
<phases>
|
||||
|
|
|
@ -37,6 +37,10 @@ use a configuration source to pull in the lifecycle information.
|
|||
<requirement>
|
||||
<role>org.apache.maven.plugin.PluginManager</role>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.apache.maven.lifecycle.LifecycleMapping</role>
|
||||
<field-name>lifecycleMappings</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
<configuration>
|
||||
<lifecycles>
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package org.apache.maven.lifecycle;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||
|
@ -9,7 +11,12 @@ 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.execution.ReactorManager;
|
||||
import org.apache.maven.model.Repository;
|
||||
import org.apache.maven.monitor.event.DefaultEventMonitor;
|
||||
import org.apache.maven.monitor.event.DeprecationEventDispatcher;
|
||||
import org.apache.maven.monitor.event.EventDispatcher;
|
||||
import org.apache.maven.monitor.event.MavenEvents;
|
||||
import org.apache.maven.plugin.MavenPluginCollector;
|
||||
import org.apache.maven.plugin.MavenPluginDiscoverer;
|
||||
import org.apache.maven.plugin.MojoExecution;
|
||||
|
@ -24,6 +31,7 @@ import org.apache.maven.repository.RepositorySystem;
|
|||
import org.codehaus.plexus.ContainerConfiguration;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.logging.console.ConsoleLogger;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
public class LifecycleExecutorTest
|
||||
|
@ -41,6 +49,9 @@ public class LifecycleExecutorTest
|
|||
@Requirement
|
||||
private DefaultLifecycleExecutor lifecycleExecutor;
|
||||
|
||||
File pom;
|
||||
File targetPom;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -48,6 +59,13 @@ public class LifecycleExecutorTest
|
|||
repositorySystem = lookup( RepositorySystem.class );
|
||||
pluginManager = lookup( PluginManager.class );
|
||||
lifecycleExecutor = (DefaultLifecycleExecutor) lookup( LifecycleExecutor.class );
|
||||
targetPom = new File( getBasedir(), "target/lifecycle-executor/pom-plugin.xml" );
|
||||
|
||||
if ( !targetPom.exists() )
|
||||
{
|
||||
pom = new File( getBasedir(), "src/test/pom.xml" );
|
||||
FileUtils.copyFile( pom, targetPom );
|
||||
}
|
||||
}
|
||||
|
||||
public void testLifecyclePhases()
|
||||
|
@ -55,7 +73,7 @@ public class LifecycleExecutorTest
|
|||
assertNotNull( lifecycleExecutor.getLifecyclePhases() );
|
||||
}
|
||||
|
||||
public void testRemoteResourcesPlugin()
|
||||
public void testStandardLifecycle()
|
||||
throws Exception
|
||||
{
|
||||
// - find the plugin [extension point: any client may wish to do whatever they choose]
|
||||
|
@ -63,10 +81,55 @@ public class LifecycleExecutorTest
|
|||
// - configure the plugin [extension point]
|
||||
// - execute the plugin
|
||||
|
||||
// Our test POM and this is actually the Maven POM so not the best idea.
|
||||
File pom = new File( getBasedir(), "src/test/pom.xml" );
|
||||
File targetPom = new File( getBasedir(), "target/lifecycle-executor/pom-plugin.xml" );
|
||||
FileUtils.copyFile( pom, targetPom );
|
||||
if ( !targetPom.getParentFile().exists() )
|
||||
{
|
||||
targetPom.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
ArtifactRepository localRepository = getLocalRepository();
|
||||
|
||||
Repository repository = new Repository();
|
||||
repository.setUrl( "http://repo1.maven.org/maven2" );
|
||||
repository.setId( "central" );
|
||||
|
||||
ProjectBuilderConfiguration configuration = new DefaultProjectBuilderConfiguration()
|
||||
.setLocalRepository( localRepository )
|
||||
.setRemoteRepositories( Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ) );
|
||||
|
||||
MavenProject project = projectBuilder.build( targetPom, configuration );
|
||||
assertEquals( "maven", project.getArtifactId() );
|
||||
assertEquals( "3.0-SNAPSHOT", project.getVersion() );
|
||||
|
||||
MavenExecutionRequest request = new DefaultMavenExecutionRequest()
|
||||
.setProjectPresent( true )
|
||||
.setPluginGroups( Arrays.asList( new String[] { "org.apache.maven.plugins" } ) )
|
||||
.setLocalRepository( localRepository )
|
||||
.setRemoteRepositories( Arrays.asList( repositorySystem.buildArtifactRepository( repository ) ) )
|
||||
.setGoals( Arrays.asList( new String[] { "package" } ) )
|
||||
.addEventMonitor( new DefaultEventMonitor( new ConsoleLogger( 0, "" ) ) )
|
||||
.setProperties( new Properties() );
|
||||
|
||||
List projects = new ArrayList();
|
||||
projects.add( project );
|
||||
|
||||
ReactorManager reactorManager = new ReactorManager( projects, request.getReactorFailureBehavior() );
|
||||
|
||||
MavenSession session = new MavenSession( getContainer(), request, reactorManager );
|
||||
//!!jvz This is not really quite right, take a look at how this actually works.
|
||||
session.setCurrentProject( project );
|
||||
|
||||
EventDispatcher dispatcher = new DeprecationEventDispatcher( MavenEvents.DEPRECATIONS, request.getEventMonitors() );
|
||||
|
||||
lifecycleExecutor.execute( session, reactorManager, dispatcher );
|
||||
}
|
||||
|
||||
public void testRemoteResourcesPlugin()
|
||||
throws Exception
|
||||
{
|
||||
// - find the plugin [extension point: any client may wish to do whatever they choose]
|
||||
// - load the plugin into a classloader [extension point: we want to take them from a repository, some may take from disk or whatever]
|
||||
// - configure the plugin [extension point]
|
||||
// - execute the plugin
|
||||
|
||||
if ( !targetPom.getParentFile().exists() )
|
||||
{
|
||||
|
@ -119,11 +182,6 @@ public class LifecycleExecutorTest
|
|||
// - configure the plugin [extension point]
|
||||
// - execute the plugin
|
||||
|
||||
// Our test POM and this is actually the Maven POM so not the best idea.
|
||||
File pom = new File( getBasedir(), "src/test/pom.xml" );
|
||||
File targetPom = new File( getBasedir(), "target/lifecycle-executor/pom-plugin.xml" );
|
||||
FileUtils.copyFile( pom, targetPom );
|
||||
|
||||
if ( !targetPom.getParentFile().exists() )
|
||||
{
|
||||
targetPom.getParentFile().mkdirs();
|
||||
|
|
|
@ -124,8 +124,6 @@ public class MavenProject
|
|||
|
||||
private List<String> scriptSourceRoots = new ArrayList<String>();
|
||||
|
||||
private List<ArtifactRepository> pluginArtifactRepositories;
|
||||
|
||||
private ArtifactRepository releaseArtifactRepository;
|
||||
|
||||
private ArtifactRepository snapshotArtifactRepository;
|
||||
|
@ -166,7 +164,6 @@ public class MavenProject
|
|||
private ProjectBuilderConfiguration projectBuilderConfiguration;
|
||||
|
||||
private RepositorySystem repositorySystem;
|
||||
//
|
||||
|
||||
private File parentFile;
|
||||
|
||||
|
@ -1350,7 +1347,6 @@ public class MavenProject
|
|||
|
||||
public void setPluginArtifactRepositories( List<ArtifactRepository> pluginArtifactRepositories )
|
||||
{
|
||||
this.pluginArtifactRepositories = pluginArtifactRepositories;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue