mirror of https://github.com/apache/maven.git
MNG-5805: Restore binary compatibility
Signed-off-by: Jason van Zyl <jason@tesla.io>
This commit is contained in:
parent
15223116a6
commit
3677220f6e
|
@ -68,10 +68,16 @@ public class Lifecycle
|
|||
return this.phases;
|
||||
}
|
||||
|
||||
public Map<String, LifecyclePhase> getDefaultPhases()
|
||||
public Map<String, LifecyclePhase> getDefaultLifecyclePhases()
|
||||
{
|
||||
return defaultPhases;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Map<String, String> getDefaultPhases()
|
||||
{
|
||||
return LifecyclePhase.toLegacyMap( getDefaultLifecyclePhases() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
|
|
|
@ -104,11 +104,11 @@ public class DefaultLifecyclePluginAnalyzer
|
|||
|
||||
if ( lifecycleConfiguration != null )
|
||||
{
|
||||
phaseToGoalMapping = lifecycleConfiguration.getPhases();
|
||||
phaseToGoalMapping = lifecycleConfiguration.getLifecyclePhases();
|
||||
}
|
||||
else if ( lifecycle.getDefaultPhases() != null )
|
||||
else if ( lifecycle.getDefaultLifecyclePhases() != null )
|
||||
{
|
||||
phaseToGoalMapping = lifecycle.getDefaultPhases();
|
||||
phaseToGoalMapping = lifecycle.getDefaultLifecyclePhases();
|
||||
}
|
||||
|
||||
if ( phaseToGoalMapping != null )
|
||||
|
|
|
@ -61,13 +61,13 @@ public class DefaultLifecycleMapping
|
|||
|
||||
for ( String lifecycleId : lifecycleIds )
|
||||
{
|
||||
Map<String, LifecyclePhase> phases = getPhases( lifecycleId );
|
||||
Map<String, LifecyclePhase> phases = getLifecyclePhases( lifecycleId );
|
||||
if ( phases != null )
|
||||
{
|
||||
Lifecycle lifecycle = new Lifecycle();
|
||||
|
||||
lifecycle.setId( lifecycleId );
|
||||
lifecycle.setPhases( phases );
|
||||
lifecycle.setLifecyclePhases( phases );
|
||||
|
||||
lifecycleMap.put( lifecycleId, lifecycle );
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class DefaultLifecycleMapping
|
|||
return null;
|
||||
}
|
||||
|
||||
public Map<String, LifecyclePhase> getPhases( String lifecycle )
|
||||
private Map<String, LifecyclePhase> getLifecyclePhases( String lifecycle )
|
||||
{
|
||||
initLifecycleMap();
|
||||
|
||||
|
@ -96,7 +96,7 @@ public class DefaultLifecycleMapping
|
|||
|
||||
if ( lifecycleMapping != null )
|
||||
{
|
||||
return lifecycleMapping.getPhases();
|
||||
return lifecycleMapping.getLifecyclePhases();
|
||||
}
|
||||
else if ( "default".equals( lifecycle ) )
|
||||
{
|
||||
|
@ -107,5 +107,11 @@ public class DefaultLifecycleMapping
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Map<String, String> getPhases( String lifecycle )
|
||||
{
|
||||
return LifecyclePhase.toLegacyMap( getLifecyclePhases( lifecycle ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,9 +19,12 @@ package org.apache.maven.lifecycle.mapping;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* Class Lifecycle.
|
||||
*/
|
||||
|
@ -35,7 +38,7 @@ public class Lifecycle
|
|||
/**
|
||||
* Field phases
|
||||
*/
|
||||
private Map<String, LifecyclePhase> phases;
|
||||
private Map<String, LifecyclePhase> lifecyclePhases;
|
||||
|
||||
/*
|
||||
* NOTE: This exists merely for backward-compat with legacy-style lifecycle definitions and allows configuration
|
||||
|
@ -53,13 +56,13 @@ public class Lifecycle
|
|||
}
|
||||
|
||||
/**
|
||||
* Method getPhases
|
||||
* Method getLifecyclePhases
|
||||
*/
|
||||
public Map<String, LifecyclePhase> getPhases()
|
||||
public Map<String, LifecyclePhase> getLifecyclePhases()
|
||||
{
|
||||
return this.phases;
|
||||
return this.lifecyclePhases;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Method setId
|
||||
*
|
||||
|
@ -71,13 +74,40 @@ public class Lifecycle
|
|||
}
|
||||
|
||||
/**
|
||||
* Method setPhases
|
||||
* Method setLifecyclePhases
|
||||
*
|
||||
* @param phases
|
||||
*/
|
||||
public void setLifecyclePhases( Map<String, LifecyclePhase> lifecyclePhases )
|
||||
{
|
||||
this.lifecyclePhases = lifecyclePhases;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Map<String, String> getPhases()
|
||||
{
|
||||
Map<String, LifecyclePhase> lphases = getLifecyclePhases();
|
||||
if ( lphases == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( lphases.isEmpty() )
|
||||
{
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
Map<String, String> phases = new LinkedHashMap<>();
|
||||
for ( Map.Entry<String, LifecyclePhase> e: lphases.entrySet() )
|
||||
{
|
||||
phases.put( e.getKey(), e.getValue().toString() );
|
||||
}
|
||||
return phases;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setPhases( Map<String, LifecyclePhase> phases )
|
||||
{
|
||||
this.phases = phases;
|
||||
} //-- void setPhases(java.util.List)
|
||||
|
||||
setLifecyclePhases( phases );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,6 +34,6 @@ public interface LifecycleMapping
|
|||
List<String> getOptionalMojos( String lifecycle );
|
||||
|
||||
@Deprecated
|
||||
Map<String, LifecyclePhase> getPhases( String lifecycle );
|
||||
Map<String, String> getPhases( String lifecycle );
|
||||
|
||||
}
|
||||
|
|
|
@ -20,7 +20,10 @@ package org.apache.maven.lifecycle.mapping;
|
|||
*/
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
|
@ -61,4 +64,46 @@ public class LifecyclePhase
|
|||
mojos.add( lifecycleMojo );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
boolean first = true;
|
||||
for ( LifecycleMojo mojo: getMojos() )
|
||||
{
|
||||
if ( first )
|
||||
{
|
||||
first = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append( "," );
|
||||
}
|
||||
sb.append( mojo.getGoal() );
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Map<String, String> toLegacyMap( Map<String, LifecyclePhase> lifecyclePhases )
|
||||
{
|
||||
if ( lifecyclePhases == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( lifecyclePhases.isEmpty() )
|
||||
{
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
Map<String, String> phases = new LinkedHashMap<>();
|
||||
for ( Map.Entry<String, LifecyclePhase> e: lifecyclePhases.entrySet() )
|
||||
{
|
||||
phases.put( e.getKey(), e.getValue().toString() );
|
||||
}
|
||||
return phases;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue