Ok, I'll make sure I add a test for the profile stuff.

Hervé, I was thinking of calling a vote for releasing the ant tasks next week. Since you seem to have done most of the work on it lately, is there anything you want to get into 2.0.10 before a release?

Hervé BOUTEMY wrote:
great!

please consider adding a unit test in sample.build.xml

Regards,

Hervé

Le jeudi 30 avril 2009, [email protected] a écrit :
Author: pgier
Date: Wed Apr 29 23:18:52 2009
New Revision: 769992

URL: http://svn.apache.org/viewvc?rev=769992&view=rev
Log:
[MANTTASKS-35] Support profiles in the Pom element.  Modified patch from
Pete Muir.

Added:
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/mav
en/artifact/ant/Profile.java   (with props) Modified:
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/mav
en/artifact/ant/Pom.java
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/installation.ap
t maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/usage.apt

Modified:
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/mav
en/artifact/ant/Pom.java URL:
http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x
/src/main/java/org/apache/maven/artifact/ant/Pom.java?rev=769992&r1=769991&r
2=769992&view=diff
===========================================================================
=== ---
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/mav
en/artifact/ant/Pom.java (original) +++
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/mav
en/artifact/ant/Pom.java Wed Apr 29 23:18:52 2009 @@ -37,6 +37,7 @@
 import org.apache.maven.model.Reporting;
 import org.apache.maven.model.Scm;
 import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
+import org.apache.maven.profiles.ProfileManager;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectBuilder;
 import org.apache.maven.project.MavenProjectHelper;
@@ -52,7 +53,9 @@
 import java.io.File;
 import java.io.IOException;
 import java.io.Reader;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;

 /**
@@ -76,6 +79,8 @@
     private MavenProject mavenProject;

     private File file;
+
+    private List profiles = new ArrayList();

     /**
      * The property interceptor.
@@ -125,6 +130,16 @@
     {
         this.file = file;
     }
+
+    public List getProfiles()
+    {
+       return profiles;
+    }
+
+    public void addProfile(Profile activeProfile)
+    {
+       this.profiles.add(activeProfile);
+    }

     public Artifact getArtifact()
     {
@@ -165,7 +180,8 @@

             try
             {
-                mavenProject = builder.build( file, localRepository,
getProfileManager() ); +
+                mavenProject = builder.build( file, localRepository,
getActivatedProfiles() ); }
             catch ( ProjectBuildingException e )
             {
@@ -443,4 +459,24 @@

     }

+    private ProfileManager getActivatedProfiles()
+    {
+        ProfileManager profileManager = getProfileManager();
+
+        Iterator it = getProfiles().iterator();
+        while ( it.hasNext() )
+        {
+            Profile profile = (Profile) it.next();
+            if ( profile.getActive() == null || Boolean.parseBoolean(
profile.getActive() ) ) +            {
+                profileManager.explicitlyActivate( profile.getId() );
+            }
+            else
+            {
+                profileManager.explicitlyDeactivate( profile.getId() );
+            }
+
+        }
+        return profileManager;
+    }
 }

Added:
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/mav
en/artifact/ant/Profile.java URL:
http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x
/src/main/java/org/apache/maven/artifact/ant/Profile.java?rev=769992&view=au
to
===========================================================================
=== ---
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/mav
en/artifact/ant/Profile.java (added) +++
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/mav
en/artifact/ant/Profile.java Wed Apr 29 23:18:52 2009 @@ -0,0 +1,59 @@
+package org.apache.maven.artifact.ant;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+/**
+ * Container for activating profiles
+ */
+public class Profile
+{
+
+    /**
+     * Profile Id to activate
+     */
+    private String id;
+
+    /**
+     * If specified, the named property must be defined. Same as if on
<include /> +     */
+    private String active;
+
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public void setId( String name )
+    {
+        this.id = name;
+    }
+
+    public void setActive( String active )
+    {
+        this.active = active;
+    }
+
+    public String getActive()
+    {
+        return active;
+    }
+
+}

Propchange:
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/mav
en/artifact/ant/Profile.java
---------------------------------------------------------------------------
--- svn:eol-style = native

Propchange:
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/main/java/org/apache/mav
en/artifact/ant/Profile.java
---------------------------------------------------------------------------
--- svn:keywords = Author Date Id Revision

Modified:
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/installation.ap
t URL:
http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x
/src/site/apt/installation.apt?rev=769992&r1=769991&r2=769992&view=diff
===========================================================================
=== ---
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/installation.ap
t (original) +++
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/installation.ap
t Wed Apr 29 23:18:52 2009 @@ -58,11 +58,11 @@
   project.

 -----
-<project ... xmlns:artifact="urn:maven-artifact-ant">
+<project ... xmlns:artifact="antlib:org.apache.maven.artifact.ant">
   ...
-  <path id="maven-ant-tasks.classpath"
path="lib/maven-ant-tasks-2.0.9.jar" /> +  <path
id="maven-ant-tasks.classpath" path="lib/maven-ant-tasks-2.0.10.jar" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
-           uri="urn:maven-artifact-ant"
+           uri="antlib:org.apache.maven.artifact.ant"
            classpathref="maven-ant-tasks.classpath" />
   ...
 </project>

Modified:
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt
URL:
http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x
/src/site/apt/reference.apt?rev=769992&r1=769991&r2=769992&view=diff
===========================================================================
=== ---
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt
(original) +++
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/reference.apt
Wed Apr 29 23:18:52 2009 @@ -230,6 +230,20 @@

| <<<id>>> | The reference ID of this POM. | | No |


*------------------+-------------------------------------------------------
-+--------------+

+** <<<profile>>>
+
+  Multiple profile elements can be nested within the pom element.  By
default the profile +  will be activated.  If <<active>> is set to false,
then the profile will be explicitly +  deactivated.
+
+*------------------+------------------------------------------------------
--+--------------+ +| <<Attribute>> | <<Description>> | <<Required>> |
+*------------------+------------------------------------------------------
--+--------------+ +| <<<id>>>         | The id of the profile to be
activated/deactivated.     | Yes          |
+*------------------+------------------------------------------------------
--+--------------+ +| <<<active>>>     | Set to true or false to determine
whether the profile should be active. | No    |
+*------------------+------------------------------------------------------
--+--------------+ +
 * <<<{VersionMapper}>>> <(since 2.0.7)>

   This is a {{{http://ant.apache.org/manual/CoreTypes/mapper.html}filename
mapper}}

Modified:
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/usage.apt URL:
http://svn.apache.org/viewvc/maven/ant-tasks/branches/maven-ant-tasks-2.0.x
/src/site/apt/usage.apt?rev=769992&r1=769991&r2=769992&view=diff
===========================================================================
=== ---
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/usage.apt
(original) +++
maven/ant-tasks/branches/maven-ant-tasks-2.0.x/src/site/apt/usage.apt Wed
Apr 29 23:18:52 2009 @@ -251,6 +251,25 @@

   For more information on the elements available in the POM, see the
{{{http://maven.apache.org/maven-model/maven.html} descriptor reference}}.

+** Using profiles in the POM
+
+  POM profiles can be activated or deactivated using the nested profile
element.  For example +  to activate a profile called <<my-profile>>.
+
+-----
+    <artifact:pom id="maven.project" file="pom.xml">
+      <profile id="my-profile"/>
+    </artifact:pom>
+-----
+
+  This can also be used to deactivate a POM profile that is active by
default. +
+-----
+    <artifact:pom id="maven.project" file="pom.xml">
+      <profile id="my-default-profile" active="false"/>
+    </artifact:pom>
+-----
+
 * Installing and Deploying Your Own Artifacts to a Repository

   If you want to share your built artifacts between projects, you can use
two other tasks: <<<install>>> for



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to