You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ga...@apache.org on 2010/01/08 17:09:23 UTC

svn commit: r897244 - in /geronimo/server/trunk: framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java framework/configs/pom.xml plugins/pom.xml

Author: gawor
Date: Fri Jan  8 16:08:58 2010
New Revision: 897244

URL: http://svn.apache.org/viewvc?rev=897244&view=rev
Log:
support setting of arbitrary system properties for package goal of car-maven-plugin

Modified:
    geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java
    geronimo/server/trunk/framework/configs/pom.xml
    geronimo/server/trunk/plugins/pom.xml

Modified: geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java?rev=897244&r1=897243&r2=897244&view=diff
==============================================================================
--- geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java (original)
+++ geronimo/server/trunk/framework/buildsupport/car-maven-plugin/src/main/java/org/apache/geronimo/mavenplugins/car/PackageMojo.java Fri Jan  8 16:08:58 2010
@@ -22,9 +22,11 @@
 import java.io.File;
 import java.net.URI;
 import java.util.Arrays;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.Collections;
 import java.util.Dictionary;
@@ -182,14 +184,21 @@
      */
     protected String pluginMetadataFileName = null;
     private BundleContext bundleContext;
+    
+    /**
+     * System properties.
+     * 
+     * @parameter 
+     */
+    protected Map<String, String> systemProperties;
 
     //
     // Mojo
     //
 
     public void execute() throws MojoExecutionException, MojoFailureException {
+        Map<String, String> oldSystemProperties = setSystemProperties();
         try {
-            System.setProperty("geronimo.build.car", "true");
 // We need to make sure to clean up any previous work first or this operation will fail
             FileUtils.forceDelete(targetRepository);
             FileUtils.forceMkdir(targetRepository);
@@ -235,9 +244,39 @@
             }
         } catch (Exception e) {
             throw new MojoExecutionException("could not package plugin", e);
+        } finally {
+            unsetSystemProperties(oldSystemProperties);
         }
     }
 
+    private Map<String, String> setSystemProperties() {
+        if (systemProperties == null) {
+            return Collections.emptyMap();
+        } else {
+            getLog().debug("Setting system properties: " + systemProperties);
+            Map<String, String> previousSystemProperties = new HashMap<String, String>();
+            for (Map.Entry<String, String> entry : systemProperties.entrySet()) {
+                String key = entry.getKey();
+                String value = entry.getValue();
+                String oldValue = System.setProperty(key, value);
+                previousSystemProperties.put(key, oldValue);
+            }       
+            return previousSystemProperties;
+        }
+    }
+    
+    private void unsetSystemProperties(Map<String, String> previousSystemProperties) {
+        for (Map.Entry<String, String> entry : previousSystemProperties.entrySet()) {
+            String key = entry.getKey();
+            String value = entry.getValue();
+            if (value == null) {
+                System.clearProperty(key);
+            } else {
+                System.setProperty(key, value);
+            }
+        }        
+    }
+    
     private File getArtifactInRepositoryDir() {
         //
         // HACK: Generate the filename in the repo... really should delegate this to the repo impl

Modified: geronimo/server/trunk/framework/configs/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/configs/pom.xml?rev=897244&r1=897243&r2=897244&view=diff
==============================================================================
--- geronimo/server/trunk/framework/configs/pom.xml (original)
+++ geronimo/server/trunk/framework/configs/pom.xml Fri Jan  8 16:08:58 2010
@@ -65,6 +65,9 @@
                 <!-- Install as extention to allow 'car' packaging to be used. -->
                 <extensions>true</extensions>
                 <configuration>
+                    <systemProperties> 
+                        <geronimo.build.car>true</geronimo.build.car>
+                    </systemProperties>
                     <archive>
                         <!-- Do not include META-INF/maven to avoid long file problems on windows -->
                         <addMavenDescriptor>false</addMavenDescriptor>

Modified: geronimo/server/trunk/plugins/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/pom.xml?rev=897244&r1=897243&r2=897244&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/pom.xml (original)
+++ geronimo/server/trunk/plugins/pom.xml Fri Jan  8 16:08:58 2010
@@ -64,6 +64,10 @@
                 <!-- Install as extention to allow 'car' packaging to be used. -->
                 <extensions>true</extensions>
                 <configuration>
+                    <systemProperties> 
+                        <geronimo.build.car>true</geronimo.build.car>
+                        <openejb.log.factory>org.apache.openejb.util.PaxLogStreamFactory</openejb.log.factory>
+                    </systemProperties>
                     <archive>
                         <!-- Do not include META-INF/maven to avoid long file problems on windows -->
                         <addMavenDescriptor>false</addMavenDescriptor>