[pkg-java] r7650 - in trunk/maven-debian-helper: cdbs src/main/java/org/debian/maven src/main/resources/org/apache/maven/project

twerner at alioth.debian.org twerner at alioth.debian.org
Fri Dec 12 08:23:28 UTC 2008


Author: twerner
Date: 2008-12-12 08:23:28 +0000 (Fri, 12 Dec 2008)
New Revision: 7650

Modified:
   trunk/maven-debian-helper/cdbs/maven-vars.mk
   trunk/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java
   trunk/maven-debian-helper/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
Log:
fix the Wrapper class


Modified: trunk/maven-debian-helper/cdbs/maven-vars.mk
===================================================================
--- trunk/maven-debian-helper/cdbs/maven-vars.mk	2008-12-11 22:13:55 UTC (rev 7649)
+++ trunk/maven-debian-helper/cdbs/maven-vars.mk	2008-12-12 08:23:28 UTC (rev 7650)
@@ -64,12 +64,15 @@
 # the property file.
 DEB_MAVEN_PROPERTYFILE = $(shell test -f $(CURDIR)/debian/maven.properties && echo $(CURDIR)/debian/maven.properties)
 
+DEB_MAVEN_EXTRAPROPS = $(shell test -n "$(DEB_MAVEN_PROPERTYFILE)" && echo -Dproperties.file.manual=$(DEB_MAVEN_PROPERTYFILE))
+#DEB_MAVEN_EXTRAPROPS = -Dproperties.file.auto=$(CURDIR)/debian/auto.properties
+
 # You can specify additional JVM arguments in MAVEN_OPTS and Maven
 # command-line arguments in MAVEN_ARGS. You can additionally define
 # MAVEN_ARGS_<package> for each individual package.
 DEB_MAVEN_INVOKE = cd $(DEB_BUILDDIR) && $(JAVACMD) -classpath $(DEB_CLASSPATH) \
 		 $(MAVEN_OPTS) -Dclassworlds.conf=/etc/maven2/m2-debian.conf \
-		 -Dmaven.home=$(MAVEN_HOME) \
+		 -Dmaven.home=$(MAVEN_HOME) $(DEB_MAVEN_EXTRAPROPS) \
 		 org.codehaus.classworlds.Launcher $(DEB_MAVEN_ARGS) \
 		 -s/etc/maven2/settings-debian.xml \
 		 $(if $(MAVEN_ARGS_$(cdbs_curpkg)),$(MAVEN_ARGS_$(cdbs_curpkg)),$(MAVEN_ARGS))

Modified: trunk/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java
===================================================================
--- trunk/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java	2008-12-11 22:13:55 UTC (rev 7649)
+++ trunk/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java	2008-12-12 08:23:28 UTC (rev 7650)
@@ -2,6 +2,7 @@
 
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.util.Enumeration;
 import java.util.Properties;
 import org.apache.maven.cli.MavenCli;
 import org.codehaus.classworlds.ClassWorld;
@@ -9,31 +10,53 @@
 public class Wrapper
 {
   /* Opens the filename specified by property 'key' and adds its content to
-   * the properties.
+   * args as -Dkey=value.
    */
-  public static void loadProperties(Properties properties, String key) throws IOException
+  public static String[] getProperties(String key) throws IOException
   {
-    String filename = properties.getProperty(key);
+    Properties systemproperties = System.getProperties();
+    String filename = systemproperties.getProperty(key);
     if (filename != null)
     {
-      properties.load(new FileInputStream(filename));
+      Properties extraProperties = new Properties();
+      extraProperties.load(new FileInputStream(filename));
+      String[] extraArgs = new String[extraProperties.size()];
+      int i = 0;
+      for(Enumeration e = extraProperties.propertyNames(); e.hasMoreElements(); )
+      {
+	String k = (String) e.nextElement();
+	String v = (String) extraProperties.get(k);
+	extraArgs[i] = "-D" + k + "=" + v;
+	i++;
+      }
+      return extraArgs;
     }
+    return new String[0];
   }
 
-  /* Add more properties to the system properties. The files specified
+  /* Add more properties to the commandline. The files specified
    * by 'properties.file.auto' and 'properties.file.manual' are read.
    */
-  public static void updateSystemProperties() throws IOException
+  public static String[] updateCommandLine(String[] args) throws IOException
   {
-    Properties systemproperties = System.getProperties();
-    loadProperties(systemproperties, "properties.file.auto");
-    loadProperties(systemproperties, "properties.file.manual");
-    System.setProperties(systemproperties);
+    String[] autoArgs = getProperties("properties.file.auto");
+    String[] manualArgs = getProperties("properties.file.manual");
+
+    int argsSize = args.length;
+    int autoSize = autoArgs.length;
+    int manualSize = manualArgs.length;
+    
+    String[] newArgs = new String[argsSize + autoSize + manualSize];
+    
+    System.arraycopy(autoArgs, 0, newArgs, 0, autoSize);
+    System.arraycopy(manualArgs, 0, newArgs, autoSize, manualSize);
+    System.arraycopy(args, 0, newArgs, autoSize + manualSize, argsSize);
+    
+    return newArgs;
   }
 
   public static void main(String[] args, ClassWorld classWorld) throws IOException
   {
-    updateSystemProperties();
-    MavenCli.main(args, classWorld);
+    MavenCli.main(updateCommandLine(args), classWorld);
   }
 }

Modified: trunk/maven-debian-helper/src/main/resources/org/apache/maven/project/pom-4.0.0.xml
===================================================================
--- trunk/maven-debian-helper/src/main/resources/org/apache/maven/project/pom-4.0.0.xml	2008-12-11 22:13:55 UTC (rev 7649)
+++ trunk/maven-debian-helper/src/main/resources/org/apache/maven/project/pom-4.0.0.xml	2008-12-12 08:23:28 UTC (rev 7650)
@@ -51,7 +51,7 @@
 
   <properties>
     <org.apache.maven.plugins.maven-resources-plugin.version>
-      2.3
+      2.2
     </org.apache.maven.plugins.maven-resources-plugin.version>
   </properties>
 




More information about the pkg-java-commits mailing list