mirror of https://github.com/apache/maven.git
[MNG-4201] Custom packaging break in trunk (rev 784628)
o Restored compat with 2.x, both in terms of lifecycle configuration and API for implementors of custom mappings git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@796801 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d0ca6d9490
commit
c6eb6bd219
|
@ -22,15 +22,22 @@ import java.util.Map;
|
||||||
public class DefaultLifecycleMapping
|
public class DefaultLifecycleMapping
|
||||||
implements LifecycleMapping
|
implements LifecycleMapping
|
||||||
{
|
{
|
||||||
|
|
||||||
private List<Lifecycle> lifecycles;
|
private List<Lifecycle> lifecycles;
|
||||||
|
|
||||||
private Map<String, Lifecycle> lifecycleMap;
|
private Map<String, Lifecycle> lifecycleMap;
|
||||||
|
|
||||||
public Map<String,Lifecycle> getLifecycles()
|
/** @deprecated use lifecycles instead */
|
||||||
|
private Map<String, String> phases;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the lifecycle map from the injected list of lifecycle mappings (if not already done).
|
||||||
|
*/
|
||||||
|
private void initLifecycleMap()
|
||||||
{
|
{
|
||||||
if ( lifecycleMap == null )
|
if ( lifecycleMap == null )
|
||||||
{
|
{
|
||||||
lifecycleMap = new HashMap<String,Lifecycle>();
|
lifecycleMap = new HashMap<String, Lifecycle>();
|
||||||
|
|
||||||
if ( lifecycles != null )
|
if ( lifecycles != null )
|
||||||
{
|
{
|
||||||
|
@ -39,8 +46,62 @@ public class DefaultLifecycleMapping
|
||||||
lifecycleMap.put( lifecycle.getId(), lifecycle );
|
lifecycleMap.put( lifecycle.getId(), lifecycle );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* NOTE: This is to provide a migration path for implementors of the legacy API which did not know about
|
||||||
|
* getLifecycles().
|
||||||
|
*/
|
||||||
|
|
||||||
|
String[] lifecycleIds = { "default", "clean", "site" };
|
||||||
|
|
||||||
|
for ( String lifecycleId : lifecycleIds )
|
||||||
|
{
|
||||||
|
Map<String, String> phases = getPhases( lifecycleId );
|
||||||
|
if ( phases != null )
|
||||||
|
{
|
||||||
|
Lifecycle lifecycle = new Lifecycle();
|
||||||
|
|
||||||
|
lifecycle.setId( lifecycleId );
|
||||||
|
lifecycle.setPhases( phases );
|
||||||
|
|
||||||
|
lifecycleMap.put( lifecycleId, lifecycle );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, Lifecycle> getLifecycles()
|
||||||
|
{
|
||||||
|
initLifecycleMap();
|
||||||
|
|
||||||
return lifecycleMap;
|
return lifecycleMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getOptionalMojos( String lifecycle )
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getPhases( String lifecycle )
|
||||||
|
{
|
||||||
|
initLifecycleMap();
|
||||||
|
|
||||||
|
Lifecycle lifecycleMapping = lifecycleMap.get( lifecycle );
|
||||||
|
|
||||||
|
if ( lifecycleMapping != null )
|
||||||
|
{
|
||||||
|
return lifecycleMapping.getPhases();
|
||||||
|
}
|
||||||
|
else if ( "default".equals( lifecycle ) )
|
||||||
|
{
|
||||||
|
return phases;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,18 @@ package org.apache.maven.lifecycle.mapping;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface LifecycleMapping
|
public interface LifecycleMapping
|
||||||
{
|
{
|
||||||
Map<String,Lifecycle> getLifecycles();
|
|
||||||
|
Map<String, Lifecycle> getLifecycles();
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
List<String> getOptionalMojos( String lifecycle );
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
|
Map<String, String> getPhases( String lifecycle );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue