Fixing the legacy lifecycle mappings back to compatibility with 2.0.x in terms of classname, then mapping them back to a field in the lifecycle executor so the enforcer plugin continues to function.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@602972 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2007-12-10 17:22:33 +00:00
parent 1328959dca
commit 3e081b677a
11 changed files with 63 additions and 31 deletions

View File

@ -1,6 +1,10 @@
package org.apache.maven.compat.plugin; package org.apache.maven.compat;
import org.apache.maven.lifecycle.binding.DefaultLifecycleBindingManager;
import org.apache.maven.lifecycle.binding.LifecycleBindingManager;
import org.codehaus.plexus.PlexusContainer;
import org.apache.maven.DefaultMaven; import org.apache.maven.DefaultMaven;
import org.apache.maven.lifecycle.DefaultLifecycleExecutor;
import org.apache.maven.lifecycle.MojoBindingUtils; import org.apache.maven.lifecycle.MojoBindingUtils;
import org.apache.maven.lifecycle.LifecycleUtils; import org.apache.maven.lifecycle.LifecycleUtils;
import org.apache.maven.lifecycle.NoSuchPhaseException; import org.apache.maven.lifecycle.NoSuchPhaseException;
@ -34,10 +38,12 @@ import org.apache.maven.settings.DefaultMavenSettingsBuilder;
import org.apache.maven.settings.Settings; import org.apache.maven.settings.Settings;
import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.logging.Logger;
import java.util.List;
import java.io.IOException; import java.io.IOException;
import java.util.Iterator; import java.util.Iterator;
import java.util.Collection; import java.util.Collection;
@ -355,4 +361,30 @@ public privileged aspect Maven20xCompatAspect
return result; return result;
} }
// This is to support the maven-enforcer-plugin.
private List DefaultLifecycleExecutor.lifecycles;
private pointcut lifecycleExecutorExecute( DefaultLifecycleExecutor executor ):
execution( * DefaultLifecycleExecutor.execute( .. ) )
&& this( executor );
before( DefaultLifecycleExecutor executor ): lifecycleExecutorExecute( executor )
{
PlexusContainer container = executor.container;
DefaultLifecycleBindingManager bindingMgr;
try
{
bindingMgr = (DefaultLifecycleBindingManager) container.lookup( LifecycleBindingManager.ROLE, "default" );
}
catch ( ComponentLookupException e )
{
IllegalStateException err = new IllegalStateException( "Cannot lookup default role-hint for: " + LifecycleBindingManager.ROLE );
err.initCause( e );
throw err;
}
executor.lifecycles = bindingMgr.lifecycles;
}
} }

View File

@ -63,7 +63,7 @@ public class DefaultLifecycleBindingManager
private Logger logger; private Logger logger;
// configured. Moved out of DefaultLifecycleExecutor... // configured. Moved out of DefaultLifecycleExecutor...
private List legacyLifecycles; private List lifecycles;
// configured. Moved out of DefaultLifecycleExecutor... // configured. Moved out of DefaultLifecycleExecutor...
private List defaultReports; private List defaultReports;
@ -128,7 +128,7 @@ public class DefaultLifecycleBindingManager
*/ */
public LifecycleBindings getDefaultBindings( final MavenProject project ) throws LifecycleSpecificationException public LifecycleBindings getDefaultBindings( final MavenProject project ) throws LifecycleSpecificationException
{ {
LifecycleBindings bindings = legacyLifecycleMappingParser.parseDefaultMappings( legacyLifecycles ); LifecycleBindings bindings = legacyLifecycleMappingParser.parseDefaultMappings( lifecycles );
BindingUtils.injectProjectConfiguration( bindings, project ); BindingUtils.injectProjectConfiguration( bindings, project );
@ -325,7 +325,7 @@ public class DefaultLifecycleBindingManager
if ( lifecycleOverlay == null ) if ( lifecycleOverlay == null )
{ {
throw new LifecycleLoaderException( "LegacyLifecycle '" + lifecycleId + "' not found in plugin" ); throw new LifecycleLoaderException( "Lifecycle '" + lifecycleId + "' not found in plugin" );
} }
LifecycleBindings bindings = new LifecycleBindings(); LifecycleBindings bindings = new LifecycleBindings();

View File

@ -39,7 +39,7 @@ public class LegacyLifecycleMappingParser
for ( Iterator it = lifecycles.iterator(); it.hasNext(); ) for ( Iterator it = lifecycles.iterator(); it.hasNext(); )
{ {
LegacyLifecycle lifecycle = (LegacyLifecycle) it.next(); Lifecycle lifecycle = (Lifecycle) it.next();
if ( "clean".equals( lifecycle.getId() ) ) if ( "clean".equals( lifecycle.getId() ) )
{ {

View File

@ -24,9 +24,9 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* Class LegacyLifecycle. * Class Lifecycle.
*/ */
public class LegacyLifecycle public class Lifecycle
{ {
/** /**
* Field id * Field id
@ -58,7 +58,7 @@ public class LegacyLifecycle
*/ */
public String getId() public String getId()
{ {
return this.id; return id;
} //-- String getId() } //-- String getId()
/** /**
@ -66,12 +66,12 @@ public class LegacyLifecycle
*/ */
public List getPhases() public List getPhases()
{ {
if ( this.phases == null ) if ( phases == null )
{ {
this.phases = new ArrayList(); phases = new ArrayList();
} }
return this.phases; return phases;
} //-- java.util.List getPhases() } //-- java.util.List getPhases()
/** /**

View File

@ -25,7 +25,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* LegacyLifecycle mapping for a POM. * Lifecycle mapping for a POM.
* *
* @author <a href="mailto:brett@apache.org">Brett Porter</a> * @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$ * @version $Id$

View File

@ -24,7 +24,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* Class LegacyLifecycle. * Class Lifecycle.
*/ */
public class Lifecycle public class Lifecycle
{ {

View File

@ -1262,7 +1262,7 @@ public class DefaultPluginManager
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// LegacyLifecycle // Lifecycle
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
public void contextualize( Context context ) public void contextualize( Context context )

View File

@ -725,8 +725,8 @@ under the License.
</requirement> </requirement>
</requirements> </requirements>
<configuration> <configuration>
<legacyLifecycles> <lifecycles>
<legacyLifecycle> <lifecycle>
<id>default</id> <id>default</id>
<!-- START SNIPPET: lifecycle --> <!-- START SNIPPET: lifecycle -->
<phases> <phases>
@ -755,8 +755,8 @@ under the License.
<phase>deploy</phase> <phase>deploy</phase>
</phases> </phases>
<!-- END SNIPPET: lifecycle --> <!-- END SNIPPET: lifecycle -->
</legacyLifecycle> </lifecycle>
<legacyLifecycle> <lifecycle>
<id>clean</id> <id>clean</id>
<phases> <phases>
<phase>pre-clean</phase> <phase>pre-clean</phase>
@ -766,8 +766,8 @@ under the License.
<default-phases> <default-phases>
<clean>org.apache.maven.plugins:maven-clean-plugin:clean</clean> <clean>org.apache.maven.plugins:maven-clean-plugin:clean</clean>
</default-phases> </default-phases>
</legacyLifecycle> </lifecycle>
<legacyLifecycle> <lifecycle>
<id>site</id> <id>site</id>
<phases> <phases>
<phase>pre-site</phase> <phase>pre-site</phase>
@ -779,8 +779,8 @@ under the License.
<site>org.apache.maven.plugins:maven-site-plugin:site</site> <site>org.apache.maven.plugins:maven-site-plugin:site</site>
<site-deploy>org.apache.maven.plugins:maven-site-plugin:deploy</site-deploy> <site-deploy>org.apache.maven.plugins:maven-site-plugin:deploy</site-deploy>
</default-phases> </default-phases>
</legacyLifecycle> </lifecycle>
</legacyLifecycles> </lifecycles>
<!-- START SNIPPET: default-reports --> <!-- START SNIPPET: default-reports -->
<defaultReports> <defaultReports>
<report>org.apache.maven.plugins:maven-project-info-reports-plugin</report> <report>org.apache.maven.plugins:maven-project-info-reports-plugin</report>

View File

@ -483,7 +483,7 @@ public class MavenEmbedder
// Execution of phases/goals // Execution of phases/goals
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// LegacyLifecycle information // Lifecycle information
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
public List getLifecyclePhases() public List getLifecyclePhases()
@ -517,7 +517,7 @@ public class MavenEmbedder
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// LegacyLifecycle // Lifecycle
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
private MavenExecutionRequest request; private MavenExecutionRequest request;
@ -629,7 +629,7 @@ public class MavenEmbedder
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// LegacyLifecycle // Lifecycle
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
private void handleExtensions( List extensions ) private void handleExtensions( List extensions )

View File

@ -640,7 +640,7 @@ public class DefaultMavenExecutionRequestPopulator
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// LegacyLifecycle // Lifecycle
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
public void contextualize( Context context ) public void contextualize( Context context )

View File

@ -266,7 +266,7 @@ public class MavenEmbedderTest
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// LegacyLifecycle phases // Lifecycle phases
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
public void testRetrievingLifecyclePhases() public void testRetrievingLifecyclePhases()