mirror of https://github.com/apache/maven.git
code simplification
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1403786 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0312cb0ff8
commit
622b08ef6a
|
@ -44,16 +44,20 @@ public class JdkVersionProfileActivator
|
|||
|
||||
public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
|
||||
{
|
||||
boolean active = false;
|
||||
|
||||
Activation activation = profile.getActivation();
|
||||
|
||||
if ( activation != null )
|
||||
if ( activation == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String jdk = activation.getJdk();
|
||||
|
||||
if ( jdk != null )
|
||||
if ( jdk == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String version = context.getSystemProperties().get( "java.version" );
|
||||
|
||||
if ( version == null || version.length() <= 0 )
|
||||
|
@ -66,21 +70,17 @@ public class JdkVersionProfileActivator
|
|||
|
||||
if ( jdk.startsWith( "!" ) )
|
||||
{
|
||||
active = !version.startsWith( jdk.substring( 1 ) );
|
||||
return !version.startsWith( jdk.substring( 1 ) );
|
||||
}
|
||||
else if ( isRange( jdk ) )
|
||||
{
|
||||
active = isInRange( version, getRange( jdk ) );
|
||||
return isInRange( version, getRange( jdk ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
active = version.startsWith( jdk );
|
||||
return version.startsWith( jdk );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
private static boolean isInRange( String value, List<RangeValue> range )
|
||||
{
|
||||
|
|
|
@ -39,17 +39,21 @@ public class OperatingSystemProfileActivator
|
|||
|
||||
public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
|
||||
{
|
||||
boolean active = false;
|
||||
|
||||
Activation activation = profile.getActivation();
|
||||
|
||||
if ( activation != null )
|
||||
if ( activation == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ActivationOS os = activation.getOs();
|
||||
|
||||
if ( os != null )
|
||||
if ( os == null )
|
||||
{
|
||||
active = ensureAtLeastOneNonNull( os );
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean active = ensureAtLeastOneNonNull( os );
|
||||
|
||||
if ( active && os.getFamily() != null )
|
||||
{
|
||||
|
@ -67,8 +71,6 @@ public class OperatingSystemProfileActivator
|
|||
{
|
||||
active = determineVersionMatch( os.getVersion() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
|
@ -91,14 +93,7 @@ public class OperatingSystemProfileActivator
|
|||
|
||||
boolean result = Os.isVersion( test );
|
||||
|
||||
if ( reverse )
|
||||
{
|
||||
return !result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return reverse ? !result : result;
|
||||
}
|
||||
|
||||
private boolean determineArchMatch( String arch )
|
||||
|
@ -114,14 +109,7 @@ public class OperatingSystemProfileActivator
|
|||
|
||||
boolean result = Os.isArch( test );
|
||||
|
||||
if ( reverse )
|
||||
{
|
||||
return !result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return reverse ? !result : result;
|
||||
}
|
||||
|
||||
private boolean determineNameMatch( String name )
|
||||
|
@ -137,14 +125,7 @@ public class OperatingSystemProfileActivator
|
|||
|
||||
boolean result = Os.isName( test );
|
||||
|
||||
if ( reverse )
|
||||
{
|
||||
return !result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return reverse ? !result : result;
|
||||
}
|
||||
|
||||
private boolean determineFamilyMatch( String family )
|
||||
|
@ -160,14 +141,7 @@ public class OperatingSystemProfileActivator
|
|||
|
||||
boolean result = Os.isFamily( test );
|
||||
|
||||
if ( reverse )
|
||||
{
|
||||
return !result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
return reverse ? !result : result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,16 +42,20 @@ public class PropertyProfileActivator
|
|||
|
||||
public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems )
|
||||
{
|
||||
boolean active = false;
|
||||
|
||||
Activation activation = profile.getActivation();
|
||||
|
||||
if ( activation != null )
|
||||
if ( activation == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
ActivationProperty property = activation.getProperty();
|
||||
|
||||
if ( property != null )
|
||||
if ( property == null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
String name = property.getName();
|
||||
boolean reverseName = false;
|
||||
|
||||
|
@ -88,32 +92,14 @@ public class PropertyProfileActivator
|
|||
// we have a value, so it has to match the system value...
|
||||
boolean result = propValue.equals( sysValue );
|
||||
|
||||
if ( reverseValue )
|
||||
{
|
||||
active = !result;
|
||||
}
|
||||
else
|
||||
{
|
||||
active = result;
|
||||
}
|
||||
return reverseValue ? !result : result;
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean result = StringUtils.isNotEmpty( sysValue );
|
||||
|
||||
if ( reverseName )
|
||||
{
|
||||
active = !result;
|
||||
return reverseName ? !result : result;
|
||||
}
|
||||
else
|
||||
{
|
||||
active = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue