You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by pg...@apache.org on 2009/04/30 01:19:45 UTC

svn commit: r769994 - in /maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant: Pom.java Profile.java

Author: pgier
Date: Wed Apr 29 23:19:44 2009
New Revision: 769994

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

Added:
    maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Profile.java   (with props)
Modified:
    maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java

Modified: maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java?rev=769994&r1=769993&r2=769994&view=diff
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java (original)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Pom.java Wed Apr 29 23:19:44 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/trunk/src/main/java/org/apache/maven/artifact/ant/Profile.java
URL: http://svn.apache.org/viewvc/maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Profile.java?rev=769994&view=auto
==============================================================================
--- maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Profile.java (added)
+++ maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Profile.java Wed Apr 29 23:19:44 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/trunk/src/main/java/org/apache/maven/artifact/ant/Profile.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/ant-tasks/trunk/src/main/java/org/apache/maven/artifact/ant/Profile.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision