mirror of https://github.com/apache/maven.git
PR: MNG-1509
Submitted By: Bernd Bohmann Reviewed By: John Casey Applied patches. These patches added the OS activator to the component descriptor, fixed the activation implementation for it, and finally added a unit test for OS activation. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@355387 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2e89dadbce
commit
4e955c058a
|
@ -36,14 +36,25 @@ public class OperatingSystemProfileActivator
|
||||||
Activation activation = profile.getActivation();
|
Activation activation = profile.getActivation();
|
||||||
ActivationOS os = activation.getOs();
|
ActivationOS os = activation.getOs();
|
||||||
|
|
||||||
boolean hasNonNull = ensureAtLeastOneNonNull( os );
|
boolean result = ensureAtLeastOneNonNull( os );
|
||||||
|
|
||||||
boolean isFamily = determineFamilyMatch( os.getFamily() );
|
if ( result && os.getFamily() != null )
|
||||||
boolean isName = determineNameMatch( os.getName() );
|
{
|
||||||
boolean isArch = determineArchMatch( os.getArch() );
|
result = determineFamilyMatch( os.getFamily() );
|
||||||
boolean isVersion = determineVersionMatch( os.getVersion() );
|
}
|
||||||
|
if ( result && os.getName() != null )
|
||||||
return hasNonNull && isFamily && isName && isArch && isVersion;
|
{
|
||||||
|
result = determineNameMatch( os.getName() );
|
||||||
|
}
|
||||||
|
if ( result && os.getArch() != null )
|
||||||
|
{
|
||||||
|
result = determineArchMatch( os.getArch() );
|
||||||
|
}
|
||||||
|
if ( result && os.getVersion() != null )
|
||||||
|
{
|
||||||
|
result = determineVersionMatch( os.getVersion() );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean ensureAtLeastOneNonNull( ActivationOS os )
|
private boolean ensureAtLeastOneNonNull( ActivationOS os )
|
||||||
|
|
|
@ -115,6 +115,16 @@
|
||||||
<role-hint>system-property</role-hint>
|
<role-hint>system-property</role-hint>
|
||||||
<implementation>org.apache.maven.profiles.activation.SystemPropertyProfileActivator</implementation>
|
<implementation>org.apache.maven.profiles.activation.SystemPropertyProfileActivator</implementation>
|
||||||
</component>
|
</component>
|
||||||
|
<!--
|
||||||
|
|
|
||||||
|
|
|
||||||
|
|
|
||||||
|
-->
|
||||||
|
<component>
|
||||||
|
<role>org.apache.maven.profiles.activation.ProfileActivator</role>
|
||||||
|
<role-hint>os</role-hint>
|
||||||
|
<implementation>org.apache.maven.profiles.activation.OperatingSystemProfileActivator</implementation>
|
||||||
|
</component>
|
||||||
<!--
|
<!--
|
||||||
|
|
|
|
||||||
|
|
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.apache.maven.profiles;
|
||||||
import org.apache.maven.model.Activation;
|
import org.apache.maven.model.Activation;
|
||||||
import org.apache.maven.model.ActivationProperty;
|
import org.apache.maven.model.ActivationProperty;
|
||||||
import org.apache.maven.model.Profile;
|
import org.apache.maven.model.Profile;
|
||||||
|
import org.apache.maven.model.ActivationOS;
|
||||||
import org.apache.maven.profiles.activation.ProfileActivationException;
|
import org.apache.maven.profiles.activation.ProfileActivationException;
|
||||||
import org.codehaus.plexus.PlexusTestCase;
|
import org.codehaus.plexus.PlexusTestCase;
|
||||||
|
|
||||||
|
@ -156,4 +157,29 @@ public class DefaultProfileManagerTest
|
||||||
assertEquals( 0, active.size() );
|
assertEquals( 0, active.size() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testOsActivationProfile() throws ProfileActivationException
|
||||||
|
{
|
||||||
|
Profile osActivated = new Profile();
|
||||||
|
osActivated.setId("os-profile");
|
||||||
|
|
||||||
|
Activation osActivation = new Activation();
|
||||||
|
|
||||||
|
ActivationOS activationOS = new ActivationOS();
|
||||||
|
|
||||||
|
activationOS.setName("!dddd");
|
||||||
|
|
||||||
|
osActivation.setOs(activationOS);
|
||||||
|
|
||||||
|
osActivated.setActivation(osActivation);
|
||||||
|
|
||||||
|
ProfileManager profileManager = new DefaultProfileManager(getContainer());
|
||||||
|
|
||||||
|
profileManager.addProfile(osActivated);
|
||||||
|
|
||||||
|
List active = profileManager.getActiveProfiles();
|
||||||
|
|
||||||
|
assertNotNull( active );
|
||||||
|
assertEquals( 1, active.size() );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue