mirror of https://github.com/apache/maven.git
Resolving: MNG-934, MNG-669
o Changed default value for usePluginRegistry to 'false' in settings.mdo o Changed default value for updateInterval to 'never' in plugin-registry.mdo o Added ActivationOS in settings.mdo, profiles.mdo, maven.mdo o Added code to the conversion utilities for Settings and Profiles to corresponding maven-model classes for ActivationOS o Added OS activator for profiles which allows architecture, name, family, and version (with '!' negation of any of these) o Added ActivationFile to settings.mdo, along with conversion code in the Settings->Model conversion utility o Added packageWithVersion configuration to the modello plugin definition in maven-settings (this is apparently required now) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@293479 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
ceb990be61
commit
def783e4cf
|
@ -2654,6 +2654,16 @@
|
|||
Specifies that this profile will be activated when a matching JDK is detected.
|
||||
]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>os</name>
|
||||
<version>4.0.0</version>
|
||||
<description><![CDATA[
|
||||
Specifies that this profile will be activated when matching OS attributes are detected.
|
||||
]]></description>
|
||||
<association>
|
||||
<type>ActivationOS</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>property</name>
|
||||
<version>4.0.0</version>
|
||||
|
@ -2700,6 +2710,40 @@
|
|||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<class>
|
||||
<name>ActivationOS</name>
|
||||
<version>4.0.0</version>
|
||||
<description><![CDATA[
|
||||
This is an activator which will detect an operating system's attributes in order to activate
|
||||
its profile.
|
||||
]]></description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>name</name>
|
||||
<version>4.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The name of the OS to be used to activate a profile</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>family</name>
|
||||
<version>4.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The general family of the OS to be used to activate a profile (e.g. 'windows')</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>arch</name>
|
||||
<version>4.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The architecture of the OS to be used to activate a profile</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>version</name>
|
||||
<version>4.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The version of the OS to be used to activate a profile</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<class>
|
||||
<name>ActivationFile</name>
|
||||
<version>4.0.0</version>
|
||||
|
|
|
@ -64,7 +64,7 @@
|
|||
<name>updateInterval</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<defaultValue>interval:1d</defaultValue>
|
||||
<defaultValue>never</defaultValue>
|
||||
<description><![CDATA[
|
||||
Specifies how often to check for plugin updates. Valid values are: never, always, interval:XXX.
|
||||
For the interval specification, XXX denotes a terse interval specification, such as 4h.
|
||||
|
|
|
@ -126,6 +126,16 @@
|
|||
Specifies that this profile will be activated when a matching JDK is detected.
|
||||
]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>os</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[
|
||||
Specifies that this profile will be activated when matching OS attributes are detected.
|
||||
]]></description>
|
||||
<association>
|
||||
<type>ActivationOS</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>property</name>
|
||||
<version>1.0.0</version>
|
||||
|
@ -328,5 +338,39 @@
|
|||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<class>
|
||||
<name>ActivationOS</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[
|
||||
This is an activator which will detect an operating system's attributes in order to activate
|
||||
its profile.
|
||||
]]></description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>name</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The name of the OS to be used to activate a profile</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>family</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The general family of the OS to be used to activate a profile (e.g. 'windows')</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>arch</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The architecture of the OS to be used to activate a profile</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>version</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The version of the OS to be used to activate a profile</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
</classes>
|
||||
</model>
|
||||
|
|
|
@ -61,6 +61,19 @@ public class ProfilesConversionUtils
|
|||
activation.setProperty( prop );
|
||||
}
|
||||
|
||||
|
||||
ActivationOS profileOs = profileActivation.getOs();
|
||||
|
||||
if ( profileOs != null )
|
||||
{
|
||||
org.apache.maven.model.ActivationOS os = new org.apache.maven.model.ActivationOS();
|
||||
|
||||
os.setArch( profileOs.getArch() );
|
||||
os.setFamily( profileOs.getFamily() );
|
||||
os.setName( profileOs.getName() );
|
||||
os.setVersion( profileOs.getVersion() );
|
||||
}
|
||||
|
||||
org.apache.maven.profiles.ActivationFile profileFile = profileActivation.getFile();
|
||||
|
||||
if ( profileFile != null )
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
package org.apache.maven.profiles.activation;
|
||||
|
||||
import org.apache.maven.model.Activation;
|
||||
import org.apache.maven.model.ActivationOS;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.codehaus.plexus.util.Os;
|
||||
|
||||
public class OperatingSystemProfileActivator
|
||||
implements ProfileActivator
|
||||
{
|
||||
|
||||
public boolean canDetermineActivation( Profile profile )
|
||||
{
|
||||
Activation activation = profile.getActivation();
|
||||
return activation != null && activation.getOs() != null;
|
||||
}
|
||||
|
||||
public boolean isActive( Profile profile )
|
||||
{
|
||||
Activation activation = profile.getActivation();
|
||||
ActivationOS os = activation.getOs();
|
||||
|
||||
boolean hasNonNull = ensureAtLeastOneNonNull( os );
|
||||
|
||||
boolean isFamily = determineFamilyMatch( os.getFamily() );
|
||||
boolean isName = determineNameMatch( os.getName() );
|
||||
boolean isArch = determineArchMatch( os.getArch() );
|
||||
boolean isVersion = determineVersionMatch( os.getVersion() );
|
||||
|
||||
return hasNonNull && isFamily && isName && isArch && isVersion;
|
||||
}
|
||||
|
||||
private boolean ensureAtLeastOneNonNull( ActivationOS os )
|
||||
{
|
||||
return os.getArch() != null || os.getFamily() != null || os.getName() != null || os.getVersion() != null;
|
||||
}
|
||||
|
||||
private boolean determineVersionMatch( String version )
|
||||
{
|
||||
String test = version;
|
||||
boolean reverse = false;
|
||||
|
||||
if ( test.startsWith( "!" ) )
|
||||
{
|
||||
reverse = true;
|
||||
test = test.substring( 1 );
|
||||
}
|
||||
|
||||
boolean result = Os.isVersion( test );
|
||||
|
||||
if ( reverse )
|
||||
{
|
||||
return !result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean determineArchMatch( String arch )
|
||||
{
|
||||
String test = arch;
|
||||
boolean reverse = false;
|
||||
|
||||
if ( test.startsWith( "!" ) )
|
||||
{
|
||||
reverse = true;
|
||||
test = test.substring( 1 );
|
||||
}
|
||||
|
||||
boolean result = Os.isArch( test );
|
||||
|
||||
if ( reverse )
|
||||
{
|
||||
return !result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean determineNameMatch( String name )
|
||||
{
|
||||
String test = name;
|
||||
boolean reverse = false;
|
||||
|
||||
if ( test.startsWith( "!" ) )
|
||||
{
|
||||
reverse = true;
|
||||
test = test.substring( 1 );
|
||||
}
|
||||
|
||||
boolean result = Os.isName( test );
|
||||
|
||||
if ( reverse )
|
||||
{
|
||||
return !result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean determineFamilyMatch( String family )
|
||||
{
|
||||
String test = family;
|
||||
boolean reverse = false;
|
||||
|
||||
if ( test.startsWith( "!" ) )
|
||||
{
|
||||
reverse = true;
|
||||
test = test.substring( 1 );
|
||||
}
|
||||
|
||||
boolean result = Os.isFamily( test );
|
||||
|
||||
if ( reverse )
|
||||
{
|
||||
return !result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -14,6 +14,9 @@
|
|||
<groupId>org.codehaus.modello</groupId>
|
||||
<artifactId>modello-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-3</version>
|
||||
<configuration>
|
||||
<packageWithVersion>false</packageWithVersion>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
<description>
|
||||
<![CDATA[Whether Maven should use the plugin-registry.xml file to manage plugin versions.]]></description>
|
||||
<type>boolean</type>
|
||||
<defaultValue>true</defaultValue>
|
||||
<defaultValue>false</defaultValue>
|
||||
</field>
|
||||
<!-- [JC] Not ready to use yet, so I'm making if unavailable for now. -->
|
||||
<!-- field>
|
||||
|
@ -592,6 +592,16 @@
|
|||
Specifies that this profile will be activated when a matching JDK is detected.
|
||||
]]></description>
|
||||
</field>
|
||||
<field>
|
||||
<name>os</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[
|
||||
Specifies that this profile will be activated when matching OS attributes are detected.
|
||||
]]></description>
|
||||
<association>
|
||||
<type>ActivationOS</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>property</name>
|
||||
<version>1.0.0</version>
|
||||
|
@ -602,6 +612,16 @@
|
|||
<type>ActivationProperty</type>
|
||||
</association>
|
||||
</field>
|
||||
<field>
|
||||
<name>file</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[
|
||||
Specifies that this profile will be activated based on existence of a file.
|
||||
]]></description>
|
||||
<association>
|
||||
<type>ActivationFile</type>
|
||||
</association>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
|
||||
|
@ -763,6 +783,63 @@
|
|||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<class>
|
||||
<name>ActivationOS</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[
|
||||
This is an activator which will detect an operating system's attributes in order to activate
|
||||
its profile.
|
||||
]]></description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>name</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The name of the OS to be used to activate a profile</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>family</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The general family of the OS to be used to activate a profile (e.g. 'windows')</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>arch</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The architecture of the OS to be used to activate a profile</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>version</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The version of the OS to be used to activate a profile</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<class>
|
||||
<name>ActivationFile</name>
|
||||
<version>1.0.0</version>
|
||||
<description><![CDATA[
|
||||
This is the file specification used to activate a profile. The missing value will be a the location
|
||||
of a file that needs to exist, and if it doesn't the profile must run. On the other hand exists will test
|
||||
for the existence of the file and if it is there will run the profile.
|
||||
]]></description>
|
||||
<fields>
|
||||
<field>
|
||||
<name>missing</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The name of the file that should be missing to activate a profile</description>
|
||||
</field>
|
||||
<field>
|
||||
<name>exists</name>
|
||||
<version>1.0.0</version>
|
||||
<type>String</type>
|
||||
<description>The name of the file that should exist to activate a profile</description>
|
||||
</field>
|
||||
</fields>
|
||||
</class>
|
||||
<!-- /BuildProfile support -->
|
||||
</classes>
|
||||
</model>
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.apache.maven.settings;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.model.ActivationFile;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -162,6 +163,30 @@ public final class SettingsUtils
|
|||
|
||||
activation.setProperty( prop );
|
||||
}
|
||||
|
||||
ActivationOS settingsOs = settingsActivation.getOs();
|
||||
|
||||
if ( settingsOs != null )
|
||||
{
|
||||
org.apache.maven.model.ActivationOS os = new org.apache.maven.model.ActivationOS();
|
||||
|
||||
os.setArch( settingsOs.getArch() );
|
||||
os.setFamily( settingsOs.getFamily() );
|
||||
os.setName( settingsOs.getName() );
|
||||
os.setVersion( settingsOs.getVersion() );
|
||||
}
|
||||
|
||||
org.apache.maven.settings.ActivationFile settingsFile = settingsActivation.getFile();
|
||||
|
||||
if ( settingsFile != null )
|
||||
{
|
||||
ActivationFile file = new ActivationFile();
|
||||
|
||||
file.setExists( settingsFile.getExists() );
|
||||
file.setMissing( settingsFile.getMissing() );
|
||||
|
||||
activation.setFile( file );
|
||||
}
|
||||
}
|
||||
|
||||
profile.setProperties( settingsProfile.getProperties() );
|
||||
|
|
Loading…
Reference in New Issue