Author: jdcasey
Date: Tue Jun 7 15:36:44 2005
New Revision: 189464
URL: http://svn.apache.org/viewcvs?rev=189464&view=rev
Log:
o pom-level profiles are working now
Added:
maven/components/trunk/maven-core-it/it0021/
maven/components/trunk/maven-core-it/it0021/expected-results.txt (with
props)
maven/components/trunk/maven-core-it/it0021/goals.txt (with props)
maven/components/trunk/maven-core-it/it0021/pom.xml (with props)
maven/components/trunk/maven-core-it/it0021/prebuild-hook.txt (with props)
maven/components/trunk/maven-core-it/it0021/src/
maven/components/trunk/maven-core-it/it0021/src/main/
maven/components/trunk/maven-core-it/it0021/src/main/java/
maven/components/trunk/maven-core-it/it0021/src/main/java/org/
maven/components/trunk/maven-core-it/it0021/src/main/java/org/apache/
maven/components/trunk/maven-core-it/it0021/src/main/java/org/apache/maven/
maven/components/trunk/maven-core-it/it0021/src/main/java/org/apache/maven/it0021/
maven/components/trunk/maven-core-it/it0021/src/main/java/org/apache/maven/it0021/Person.java
(with props)
maven/components/trunk/maven-core-it/it0021/system.properties (with props)
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ActivationConstants.java
(with props)
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ExplicitListingProfileActivator.java
(with props)
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/JdkPrefixProfileActivator.java
(with props)
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivationCalculator.java
(with props)
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivator.java
(with props)
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/SystemPropertyProfileActivator.java
(with props)
Modified:
maven/components/trunk/maven-core-it/README.txt
maven/components/trunk/maven-core-it/integration-tests.txt
maven/components/trunk/maven-model/maven.mdo
maven/components/trunk/maven-profile/profiles.mdo
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java
maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
maven/components/trunk/maven-settings/settings.mdo
Modified: maven/components/trunk/maven-core-it/README.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/README.txt?rev=189464&r1=189463&r2=189464&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/README.txt (original)
+++ maven/components/trunk/maven-core-it/README.txt Tue Jun 7 15:36:44 2005
@@ -67,6 +67,9 @@
it0020: Test beanshell mojo support.
+it0021: Test pom-level profile inclusion (this one is activated by system
+ property).
+
-------------------------------------------------------------------------------
- generated sources
Modified: maven/components/trunk/maven-core-it/integration-tests.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/integration-tests.txt?rev=189464&r1=189463&r2=189464&view=diff
==============================================================================
--- maven/components/trunk/maven-core-it/integration-tests.txt (original)
+++ maven/components/trunk/maven-core-it/integration-tests.txt Tue Jun 7
15:36:44 2005
@@ -19,3 +19,4 @@
it0018
it0019
it0020
+it0021
Added: maven/components/trunk/maven-core-it/it0021/expected-results.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0021/expected-results.txt?rev=189464&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0021/expected-results.txt (added)
+++ maven/components/trunk/maven-core-it/it0021/expected-results.txt Tue Jun 7
15:36:44 2005
@@ -0,0 +1 @@
+${artifact:org.apache.maven:maven-core-it-support:1.0:jar}
Propchange: maven/components/trunk/maven-core-it/it0021/expected-results.txt
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added: maven/components/trunk/maven-core-it/it0021/goals.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0021/goals.txt?rev=189464&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0021/goals.txt (added)
+++ maven/components/trunk/maven-core-it/it0021/goals.txt Tue Jun 7 15:36:44
2005
@@ -0,0 +1 @@
+compile
\ No newline at end of file
Propchange: maven/components/trunk/maven-core-it/it0021/goals.txt
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added: maven/components/trunk/maven-core-it/it0021/pom.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0021/pom.xml?rev=189464&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0021/pom.xml (added)
+++ maven/components/trunk/maven-core-it/it0021/pom.xml Tue Jun 7 15:36:44 2005
@@ -0,0 +1,28 @@
+<model>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-it0021-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <version>1.0-SNAPSHOT</version>
+
+ <profiles>
+ <profile>
+ <id>test-profile</id>
+
+ <activation>
+ <property>
+ <name>includeProfile</name>
+ </property>
+ </activation>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core-it-support</artifactId>
+ <version>1.0</version>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+
+</model>
\ No newline at end of file
Propchange: maven/components/trunk/maven-core-it/it0021/pom.xml
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Propchange: maven/components/trunk/maven-core-it/it0021/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: maven/components/trunk/maven-core-it/it0021/prebuild-hook.txt
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0021/prebuild-hook.txt?rev=189464&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0021/prebuild-hook.txt (added)
+++ maven/components/trunk/maven-core-it/it0021/prebuild-hook.txt Tue Jun 7
15:36:44 2005
@@ -0,0 +1 @@
+rm ${artifact:org.apache.maven:maven-core-it-support:1.0:jar}
Propchange: maven/components/trunk/maven-core-it/it0021/prebuild-hook.txt
------------------------------------------------------------------------------
svn:executable = *
Propchange: maven/components/trunk/maven-core-it/it0021/prebuild-hook.txt
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added:
maven/components/trunk/maven-core-it/it0021/src/main/java/org/apache/maven/it0021/Person.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0021/src/main/java/org/apache/maven/it0021/Person.java?rev=189464&view=auto
==============================================================================
---
maven/components/trunk/maven-core-it/it0021/src/main/java/org/apache/maven/it0021/Person.java
(added)
+++
maven/components/trunk/maven-core-it/it0021/src/main/java/org/apache/maven/it0021/Person.java
Tue Jun 7 15:36:44 2005
@@ -0,0 +1,16 @@
+package org.apache.maven.it0021;
+
+public class Person
+{
+ private String name;
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+}
Propchange:
maven/components/trunk/maven-core-it/it0021/src/main/java/org/apache/maven/it0021/Person.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added: maven/components/trunk/maven-core-it/it0021/system.properties
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-core-it/it0021/system.properties?rev=189464&view=auto
==============================================================================
--- maven/components/trunk/maven-core-it/it0021/system.properties (added)
+++ maven/components/trunk/maven-core-it/it0021/system.properties Tue Jun 7
15:36:44 2005
@@ -0,0 +1 @@
+includeProfile=true
Propchange: maven/components/trunk/maven-core-it/it0021/system.properties
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Modified: maven/components/trunk/maven-model/maven.mdo
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-model/maven.mdo?rev=189464&r1=189463&r2=189464&view=diff
==============================================================================
--- maven/components/trunk/maven-model/maven.mdo (original)
+++ maven/components/trunk/maven-model/maven.mdo Tue Jun 7 15:36:44 2005
@@ -2342,10 +2342,36 @@
<field>
<name>property</name>
<version>4.0.0</version>
- <type>String</type>
<description><![CDATA[
Specifies that this profile will be activated when this System
property is specified.
]]></description>
+ <association>
+ <type>ActivationProperty</type>
+ </association>
+ </field>
+ </fields>
+ </class>
+ <class>
+ <name>ActivationProperty</name>
+ <version>4.0.0</version>
+ <description><![CDATA[
+ This is the property specification used to activate a profile. If the
value field is empty,
+ then the existence of the named property will activate the profile,
otherwise it does a case-sensitive
+ match against the property value as well.
+ ]]></description>
+ <fields>
+ <field>
+ <name>name</name>
+ <version>4.0.0</version>
+ <type>String</type>
+ <required>true</required>
+ <description>The name of the property to be used to activate a
profile</description>
+ </field>
+ <field>
+ <name>value</name>
+ <version>4.0.0</version>
+ <type>String</type>
+ <description>The value of the property to be used to activate a
profile</description>
</field>
</fields>
</class>
Modified: maven/components/trunk/maven-profile/profiles.mdo
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-profile/profiles.mdo?rev=189464&r1=189463&r2=189464&view=diff
==============================================================================
--- maven/components/trunk/maven-profile/profiles.mdo (original)
+++ maven/components/trunk/maven-profile/profiles.mdo Tue Jun 7 15:36:44 2005
@@ -119,10 +119,12 @@
<field>
<name>property</name>
<version>1.0.0</version>
- <type>String</type>
<description><![CDATA[
Specifies that this profile will be activated when this System
property is specified.
]]></description>
+ <association>
+ <type>ActivationProperty</type>
+ </association>
</field>
</fields>
</class>
@@ -196,6 +198,30 @@
]]></code>
</codeSegment>
</codeSegments>
+ </class>
+ <class>
+ <name>ActivationProperty</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ This is the property specification used to activate a profile. If the
value field is empty,
+ then the existence of the named property will activate the profile,
otherwise it does a case-sensitive
+ match against the property value as well.
+ ]]></description>
+ <fields>
+ <field>
+ <name>name</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <required>true</required>
+ <description>The name of the property to be used to activate a
profile</description>
+ </field>
+ <field>
+ <name>value</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>The value of the property to be used to activate a
profile</description>
+ </field>
+ </fields>
</class>
</classes>
</model>
Added:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ActivationConstants.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ActivationConstants.java?rev=189464&view=auto
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ActivationConstants.java
(added)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ActivationConstants.java
Tue Jun 7 15:36:44 2005
@@ -0,0 +1,28 @@
+package org.apache.maven.profile.activation;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public final class ActivationConstants
+{
+
+ public static final String ACTIVE_PROFILE_IDS =
"org.apache.maven.ActiveProfileIds";
+
+ private ActivationConstants()
+ {
+ }
+
+}
Propchange:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ActivationConstants.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ExplicitListingProfileActivator.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ExplicitListingProfileActivator.java?rev=189464&view=auto
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ExplicitListingProfileActivator.java
(added)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ExplicitListingProfileActivator.java
Tue Jun 7 15:36:44 2005
@@ -0,0 +1,56 @@
+package org.apache.maven.profile.activation;
+
+import org.apache.maven.model.Profile;
+
+import java.util.StringTokenizer;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class ExplicitListingProfileActivator
+ implements ProfileActivator
+{
+
+ public boolean canDetermineActivation( Profile profile )
+ {
+ return profile.getActivation() == null;
+ }
+
+ public boolean isActive( Profile profile )
+ {
+ String activeProfiles = System.getProperty(
ActivationConstants.ACTIVE_PROFILE_IDS );
+
+ if ( activeProfiles != null )
+ {
+ String profileId = profile.getId();
+
+ StringTokenizer profileTokens = new StringTokenizer(
activeProfiles, "," );
+
+ while ( profileTokens.hasMoreTokens() )
+ {
+ String currentToken = profileTokens.nextToken().trim();
+
+ if ( profileId.equals( currentToken ) )
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+}
Propchange:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ExplicitListingProfileActivator.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/JdkPrefixProfileActivator.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/JdkPrefixProfileActivator.java?rev=189464&view=auto
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/JdkPrefixProfileActivator.java
(added)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/JdkPrefixProfileActivator.java
Tue Jun 7 15:36:44 2005
@@ -0,0 +1,44 @@
+package org.apache.maven.profile.activation;
+
+import org.apache.maven.model.Activation;
+import org.apache.maven.model.Profile;
+import org.codehaus.plexus.util.StringUtils;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class JdkPrefixProfileActivator
+ implements ProfileActivator
+{
+
+ private static final String JDK_VERSION = System.getProperty(
"java.version" );
+
+ public boolean isActive( Profile profile )
+ {
+ Activation activation = profile.getActivation();
+
+ String jdk = activation.getJdk();
+
+ // null case is covered by canDetermineActivation(), so we can do a
straight startsWith() here.
+ return JDK_VERSION.startsWith( jdk );
+ }
+
+ public boolean canDetermineActivation( Profile profile )
+ {
+ return profile.getActivation() != null && StringUtils.isNotEmpty(
profile.getActivation().getJdk() );
+ }
+
+}
Propchange:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/JdkPrefixProfileActivator.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivationCalculator.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivationCalculator.java?rev=189464&view=auto
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivationCalculator.java
(added)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivationCalculator.java
Tue Jun 7 15:36:44 2005
@@ -0,0 +1,105 @@
+package org.apache.maven.profile.activation;
+
+import org.apache.maven.model.Activation;
+import org.apache.maven.model.Profile;
+import org.apache.maven.project.ProjectBuildingException;
+import org.codehaus.plexus.PlexusConstants;
+import org.codehaus.plexus.PlexusContainer;
+import
org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
+import
org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.context.Context;
+import org.codehaus.plexus.context.ContextException;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class ProfileActivationCalculator
+ extends AbstractLogEnabled
+ implements Contextualizable
+{
+
+ public static final String ROLE =
ProfileActivationCalculator.class.getName();
+
+ private PlexusContainer container;
+
+ public List calculateActiveProfiles( List profiles )
+ throws ProjectBuildingException
+ {
+ List activators = null;
+ try
+ {
+ activators = container.lookupList( ProfileActivator.ROLE );
+
+ List active = new ArrayList( profiles.size() );
+
+ for ( Iterator it = profiles.iterator(); it.hasNext(); )
+ {
+ Profile profile = (Profile) it.next();
+
+ boolean isActive = true;
+
+ Activation activation = profile.getActivation();
+
+ activatorLoop: for ( Iterator activatorIterator =
activators.iterator(); activatorIterator.hasNext(); )
+ {
+ ProfileActivator activator = (ProfileActivator)
activatorIterator.next();
+
+ if ( activator.canDetermineActivation( profile ) )
+ {
+ if ( activator.isActive( profile ) )
+ {
+ active.add( profile );
+ }
+ else
+ {
+ break activatorLoop;
+ }
+ }
+ }
+ }
+
+ return active;
+ }
+ catch ( ComponentLookupException e )
+ {
+ throw new ProjectBuildingException( "Cannot retrieve list of
profile activators.", e );
+ }
+ finally
+ {
+ try
+ {
+ container.releaseAll( activators );
+ }
+ catch ( ComponentLifecycleException e )
+ {
+ getLogger().debug( "Error releasing profile activators -
ignoring.", e );
+ }
+ }
+ }
+
+ public void contextualize( Context context )
+ throws ContextException
+ {
+ this.container = (PlexusContainer) context.get(
PlexusConstants.PLEXUS_KEY );
+ }
+
+}
Propchange:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivationCalculator.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivator.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivator.java?rev=189464&view=auto
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivator.java
(added)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivator.java
Tue Jun 7 15:36:44 2005
@@ -0,0 +1,30 @@
+package org.apache.maven.profile.activation;
+
+import org.apache.maven.model.Profile;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public interface ProfileActivator
+{
+
+ static final String ROLE = ProfileActivator.class.getName();
+
+ boolean canDetermineActivation( Profile profile );
+
+ boolean isActive( Profile profile );
+
+}
Propchange:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/ProfileActivator.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Added:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/SystemPropertyProfileActivator.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/SystemPropertyProfileActivator.java?rev=189464&view=auto
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/SystemPropertyProfileActivator.java
(added)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/SystemPropertyProfileActivator.java
Tue Jun 7 15:36:44 2005
@@ -0,0 +1,58 @@
+package org.apache.maven.profile.activation;
+
+import org.apache.maven.model.Activation;
+import org.apache.maven.model.ActivationProperty;
+import org.apache.maven.model.Profile;
+import org.codehaus.plexus.util.StringUtils;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+public class SystemPropertyProfileActivator
+ implements ProfileActivator
+{
+
+ public boolean canDetermineActivation( Profile profile )
+ {
+ return profile.getActivation() != null &&
profile.getActivation().getProperty() != null;
+ }
+
+ public boolean isActive( Profile profile )
+ {
+ Activation activation = profile.getActivation();
+
+ ActivationProperty property = activation.getProperty();
+
+ if ( property != null )
+ {
+ String sysValue = System.getProperty( property.getName() );
+
+ String propValue = property.getValue();
+ if ( StringUtils.isNotEmpty( propValue ) )
+ {
+ // we have a value, so it has to match the system value...
+ return propValue.equals( sysValue );
+ }
+ else
+ {
+ return StringUtils.isNotEmpty( sysValue );
+ }
+ }
+
+ return false;
+ }
+
+}
Propchange:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/profile/activation/SystemPropertyProfileActivator.java
------------------------------------------------------------------------------
svn:keywords = "Date Rev Author"
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=189464&r1=189463&r2=189464&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
(original)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
Tue Jun 7 15:36:44 2005
@@ -27,13 +27,14 @@
import org.apache.maven.artifact.resolver.ArtifactResolver;
import org.apache.maven.artifact.transform.ReleaseArtifactTransformation;
import org.apache.maven.model.Build;
-import org.apache.maven.model.Dependency;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model;
import org.apache.maven.model.Parent;
import org.apache.maven.model.Plugin;
+import org.apache.maven.model.Profile;
import org.apache.maven.model.Repository;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.profile.activation.ProfileActivationCalculator;
import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
import org.apache.maven.project.injection.ModelDefaultsInjector;
import org.apache.maven.project.interpolation.ModelInterpolationException;
@@ -98,6 +99,8 @@
private ModelInterpolator modelInterpolator;
private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+ private ProfileActivationCalculator profileActivationCalculator;
private final Map modelCache = new HashMap();
@@ -262,6 +265,15 @@
if ( cachedModel == null )
{
modelCache.put( key, model );
+ }
+
+ // TODO: Add profiles support here?
+ List activePomProfiles =
profileActivationCalculator.calculateActiveProfiles( model.getProfiles() );
+ for ( Iterator it = activePomProfiles.iterator(); it.hasNext(); )
+ {
+ Profile profile = (Profile) it.next();
+
+ modelInheritanceAssembler.mergeProfileWithModel( cachedModel,
profile );
}
model = modelInterpolator.interpolate( model );
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java?rev=189464&r1=189463&r2=189464&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
(original)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/DefaultModelInheritanceAssembler.java
Tue Jun 7 15:36:44 2005
@@ -17,11 +17,14 @@
*/
import org.apache.maven.model.Build;
+import org.apache.maven.model.BuildBase;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DependencyManagement;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.model.Model;
+import org.apache.maven.model.ModelBase;
import org.apache.maven.model.Plugin;
+import org.apache.maven.model.Profile;
import org.apache.maven.model.Repository;
import org.apache.maven.model.Scm;
import org.apache.maven.model.Site;
@@ -44,6 +47,12 @@
{
public void assembleModelInheritance( Model child, Model parent )
{
+ // cannot inherit from null parent.
+ if ( parent == null )
+ {
+ return;
+ }
+
// Group id
if ( child.getGroupId() == null )
{
@@ -56,7 +65,7 @@
{
// The parent version may have resolved to something different, so
we take what we asked for...
// instead of - child.setVersion( parent.getVersion() );
-
+
if ( child.getParent() != null )
{
child.setVersion( child.getParent().getVersion() );
@@ -134,8 +143,24 @@
}
// Build
- assembleBuildInheritance( child, parent );
+ assembleBuildInheritance( child, parent.getBuild() );
+
+ assembleModelBaseInheritance( child, parent );
+ }
+
+ public void mergeProfileWithModel( Model model, Profile profile )
+ {
+ assembleModelBaseInheritance( model, profile );
+
+ Build modelBuild = model.getBuild();
+
+ BuildBase profileBuild = profile.getBuild();
+
+ assembleBuildBaseInheritance( modelBuild, profileBuild );
+ }
+ private void assembleModelBaseInheritance( ModelBase child, ModelBase
parent )
+ {
// Dependencies :: aggregate
List dependencies = parent.getDependencies();
@@ -175,7 +200,7 @@
child.addPluginRepository( repository );
}
}
-
+
// Reports :: aggregate
if ( child.getReports() != null && parent.getReports() != null )
{
@@ -201,8 +226,8 @@
assembleDependencyManagementInheritance( child, parent );
}
-
- private void assembleDependencyManagementInheritance( Model child, Model
parent )
+
+ private void assembleDependencyManagementInheritance( ModelBase child,
ModelBase parent )
{
DependencyManagement parentDepMgmt = parent.getDependencyManagement();
@@ -237,10 +262,15 @@
}
}
- private void assembleBuildInheritance( Model child, Model parent )
+ private void assembleBuildInheritance( Model child, Build parentBuild )
{
+ // cannot inherit from null parent...
+ if ( parentBuild == null )
+ {
+ return;
+ }
+
Build childBuild = child.getBuild();
- Build parentBuild = parent.getBuild();
if ( parentBuild != null )
{
@@ -253,11 +283,6 @@
// values
// that have not been set by the child.
- if ( childBuild.getDefaultGoal() == null )
- {
- childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
- }
-
if ( childBuild.getDirectory() == null )
{
childBuild.setDirectory( parentBuild.getDirectory() );
@@ -288,31 +313,47 @@
childBuild.setTestOutputDirectory(
parentBuild.getTestOutputDirectory() );
}
- if ( childBuild.getFinalName() == null )
- {
- childBuild.setFinalName( parentBuild.getFinalName() );
- }
+ assembleBuildBaseInheritance( childBuild, parentBuild );
+ }
+ }
- List resources = childBuild.getResources();
- if ( resources == null || resources.isEmpty() )
- {
- childBuild.setResources( parentBuild.getResources() );
- }
+ private void assembleBuildBaseInheritance( BuildBase childBuild, BuildBase
parentBuild )
+ {
+ // if the parent build is null, obviously we cannot inherit from it...
+ if ( parentBuild == null )
+ {
+ return;
+ }
- resources = childBuild.getTestResources();
- if ( resources == null || resources.isEmpty() )
- {
- childBuild.setTestResources( parentBuild.getTestResources() );
- }
+ if ( childBuild.getDefaultGoal() == null )
+ {
+ childBuild.setDefaultGoal( parentBuild.getDefaultGoal() );
+ }
- // Plugins are aggregated if Plugin.inherit != false
- ModelUtils.mergePluginLists( childBuild, parentBuild, true );
-
- // Plugin management :: aggregate
- if( childBuild != null && parentBuild != null )
- {
- ModelUtils.mergePluginLists( childBuild.getPluginManagement(),
parentBuild.getPluginManagement(), false );
- }
+ if ( childBuild.getFinalName() == null )
+ {
+ childBuild.setFinalName( parentBuild.getFinalName() );
+ }
+
+ List resources = childBuild.getResources();
+ if ( resources == null || resources.isEmpty() )
+ {
+ childBuild.setResources( parentBuild.getResources() );
+ }
+
+ resources = childBuild.getTestResources();
+ if ( resources == null || resources.isEmpty() )
+ {
+ childBuild.setTestResources( parentBuild.getTestResources() );
+ }
+
+ // Plugins are aggregated if Plugin.inherit != false
+ ModelUtils.mergePluginLists( childBuild, parentBuild, true );
+
+ // Plugin management :: aggregate
+ if ( childBuild != null && parentBuild != null )
+ {
+ ModelUtils.mergePluginLists( childBuild.getPluginManagement(),
parentBuild.getPluginManagement(), false );
}
}
@@ -336,10 +377,11 @@
childScm.setConnection( appendPath( parentScm.getConnection(),
child.getArtifactId() ) );
}
- if ( StringUtils.isEmpty( childScm.getDeveloperConnection() ) &&
- !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
+ if ( StringUtils.isEmpty( childScm.getDeveloperConnection() )
+ && !StringUtils.isEmpty( parentScm.getDeveloperConnection() ) )
{
- childScm.setDeveloperConnection( appendPath(
parentScm.getDeveloperConnection(), child.getArtifactId() ) );
+ childScm
+ .setDeveloperConnection( appendPath(
parentScm.getDeveloperConnection(), child.getArtifactId() ) );
}
if ( StringUtils.isEmpty( childScm.getUrl() ) &&
!StringUtils.isEmpty( parentScm.getUrl() ) )
Modified:
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java?rev=189464&r1=189463&r2=189464&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java
(original)
+++
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/inheritance/ModelInheritanceAssembler.java
Tue Jun 7 15:36:44 2005
@@ -17,6 +17,7 @@
*/
import org.apache.maven.model.Model;
+import org.apache.maven.model.Profile;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a>
@@ -27,4 +28,6 @@
String ROLE = ModelInheritanceAssembler.class.getName();
void assembleModelInheritance( Model child, Model parent );
+
+ void mergeProfileWithModel( Model model, Profile profile );
}
Modified:
maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml?rev=189464&r1=189463&r2=189464&view=diff
==============================================================================
---
maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
(original)
+++
maven/components/trunk/maven-project/src/main/resources/META-INF/plexus/components.xml
Tue Jun 7 15:36:44 2005
@@ -51,7 +51,49 @@
<requirement>
<role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
</requirement>
+ <requirement>
+
<role>org.apache.maven.profile.activation.ProfileActivationCalculator</role>
+ </requirement>
</requirements>
+ </component>
+ <!--
+ |
+ |
+ |
+ -->
+ <component>
+
<role>org.apache.maven.profile.activation.ProfileActivationCalculator</role>
+
<implementation>org.apache.maven.profile.activation.ProfileActivationCalculator</implementation>
+ </component>
+ <!--
+ |
+ |
+ |
+ -->
+ <component>
+ <role>org.apache.maven.profile.activation.ProfileActivator</role>
+ <role-hint>jdk-prefix</role-hint>
+
<implementation>org.apache.maven.profile.activation.JdkPrefixProfileActivator</implementation>
+ </component>
+ <!--
+ |
+ |
+ |
+ -->
+ <component>
+ <role>org.apache.maven.profile.activation.ProfileActivator</role>
+ <role-hint>system-property</role-hint>
+
<implementation>org.apache.maven.profile.activation.SystemPropertyProfileActivator</implementation>
+ </component>
+ <!--
+ |
+ |
+ |
+ -->
+ <component>
+ <role>org.apache.maven.profile.activation.ProfileActivator</role>
+ <role-hint>explicit-listing</role-hint>
+
<implementation>org.apache.maven.profile.activation.ExplicitListingProfileActivator</implementation>
</component>
<!--
|
Modified: maven/components/trunk/maven-settings/settings.mdo
URL:
http://svn.apache.org/viewcvs/maven/components/trunk/maven-settings/settings.mdo?rev=189464&r1=189463&r2=189464&view=diff
==============================================================================
--- maven/components/trunk/maven-settings/settings.mdo (original)
+++ maven/components/trunk/maven-settings/settings.mdo Tue Jun 7 15:36:44 2005
@@ -438,10 +438,12 @@
<field>
<name>property</name>
<version>1.0.0</version>
- <type>String</type>
<description><![CDATA[
Specifies that this profile will be activated when this System
property is specified.
]]></description>
+ <association>
+ <type>ActivationProperty</type>
+ </association>
</field>
</fields>
</class>
@@ -515,6 +517,30 @@
]]></code>
</codeSegment>
</codeSegments>
+ </class>
+ <class>
+ <name>ActivationProperty</name>
+ <version>1.0.0</version>
+ <description><![CDATA[
+ This is the property specification used to activate a profile. If the
value field is empty,
+ then the existence of the named property will activate the profile,
otherwise it does a case-sensitive
+ match against the property value as well.
+ ]]></description>
+ <fields>
+ <field>
+ <name>name</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <required>true</required>
+ <description>The name of the property to be used to activate a
profile</description>
+ </field>
+ <field>
+ <name>value</name>
+ <version>1.0.0</version>
+ <type>String</type>
+ <description>The value of the property to be used to activate a
profile</description>
+ </field>
+ </fields>
</class>
<!-- /BuildProfile support -->
</classes>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]