[pkg-java] r7710 - in trunk/maven-debian-helper: . maven-debian-helper maven-debian-helper/src/main/java/org/debian/maven maven-debian-plugin

twerner at alioth.debian.org twerner at alioth.debian.org
Fri Dec 19 14:53:44 UTC 2008


Author: twerner
Date: 2008-12-19 14:53:43 +0000 (Fri, 19 Dec 2008)
New Revision: 7710

Modified:
   trunk/maven-debian-helper/maven-debian-helper/pom.xml
   trunk/maven-debian-helper/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java
   trunk/maven-debian-helper/maven-debian-plugin/pom.xml
   trunk/maven-debian-helper/pom.xml
Log:
more refactoring

Modified: trunk/maven-debian-helper/maven-debian-helper/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-debian-helper/pom.xml	2008-12-18 17:33:40 UTC (rev 7709)
+++ trunk/maven-debian-helper/maven-debian-helper/pom.xml	2008-12-19 14:53:43 UTC (rev 7710)
@@ -5,7 +5,7 @@
   <parent>
     <groupId>org.debian.maven</groupId>
     <artifactId>maven-debian</artifactId>
-    <version>0.1</version>
+    <version>0.2</version>
   </parent>
 
   <artifactId>maven-debian-helper</artifactId>

Modified: trunk/maven-debian-helper/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java
===================================================================
--- trunk/maven-debian-helper/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java	2008-12-18 17:33:40 UTC (rev 7709)
+++ trunk/maven-debian-helper/maven-debian-helper/src/main/java/org/debian/maven/Wrapper.java	2008-12-19 14:53:43 UTC (rev 7710)
@@ -7,60 +7,74 @@
 import org.apache.maven.cli.MavenCli;
 import org.codehaus.classworlds.ClassWorld;
 
-/* This is a wrapper for Maven's main function that implements reading 2
- * property files: debian/auto.properties and debian/manual.properties.
+/* This is a wrapper for Maven's main function that reads 2 property
+ * files: debian/auto.properties and debian/manual.properties and adds
+ * their content to maven's commandline.
  */
 
 public class Wrapper
 {
-  /* Opens the filename specified by property 'key' and returns its content as
-   * a String array of items -Dkey=value.
+  /* holds system properties
    */
-  public static String[] getProperties(String key) throws IOException
+
+  private static Properties systemProperties = System.getProperties();
+
+  /* holds extra properties that are read from property files
+   */
+
+  private static Properties extraProperties = new Properties();
+
+  /* the extended command line for maven's main function
+   */
+
+  private static String[] newArgs;
+
+  /* Opens the filename specified by property 'key' and loads its
+   * properties into extraProperties
+   */
+
+  public static void updateProperties(String key) throws IOException
   {
-    Properties systemproperties = System.getProperties();
-    String filename = systemproperties.getProperty(key);
+    String filename = systemProperties.getProperty(key);
     if (filename != null)
     {
-      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 commandline. The files specified
-   * by '-Dproperties.file.auto=' and '-Dproperties.file.manual=' are read.
+  /* Fill new commandline array 'newArgs' with properties from
+   * extraProperties and the current commandline array 'args.
    */
-  public static String[] updateCommandLine(String[] args) throws IOException
+
+  public static void updateCommandLine(String[] args) throws IOException
   {
-    String[] autoArgs = getProperties("properties.file.auto");
-    String[] manualArgs = getProperties("properties.file.manual");
+    int argsSize  = args.length;
+    int extraSize = extraProperties.size();
+    
+    newArgs = new String[argsSize + extraSize];
 
-    int argsSize = args.length;
-    int autoSize = autoArgs.length;
-    int manualSize = manualArgs.length;
+    int i = 0;
+    for(Enumeration e = extraProperties.propertyNames(); e.hasMoreElements(); )
+    {
+      String key   = (String) e.nextElement();
+      String value = (String) extraProperties.get(key);
+      newArgs[i] = "-D" + key + "=" + value;
+      i++;
+    }
     
-    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;
+    System.arraycopy(args, 0, newArgs, extraSize, argsSize);
   }
 
+  /* wraps maven's main function
+   */
+
   public static int main(String[] args, ClassWorld classWorld) throws IOException
   {
-    return MavenCli.main(updateCommandLine(args), classWorld);
+    updateProperties("properties.file.auto");
+    updateProperties("properties.file.manual");
+
+    updateCommandLine(args);
+
+    return MavenCli.main(newArgs, classWorld);
   }
 }

Modified: trunk/maven-debian-helper/maven-debian-plugin/pom.xml
===================================================================
--- trunk/maven-debian-helper/maven-debian-plugin/pom.xml	2008-12-18 17:33:40 UTC (rev 7709)
+++ trunk/maven-debian-helper/maven-debian-plugin/pom.xml	2008-12-19 14:53:43 UTC (rev 7710)
@@ -5,7 +5,7 @@
   <parent>
     <artifactId>maven-debian</artifactId>
     <groupId>org.debian.maven</groupId>
-    <version>0.1</version>
+    <version>0.2</version>
   </parent>
   
   <artifactId>maven-debian-plugin</artifactId>

Modified: trunk/maven-debian-helper/pom.xml
===================================================================
--- trunk/maven-debian-helper/pom.xml	2008-12-18 17:33:40 UTC (rev 7709)
+++ trunk/maven-debian-helper/pom.xml	2008-12-19 14:53:43 UTC (rev 7710)
@@ -4,7 +4,7 @@
 
   <groupId>org.debian.maven</groupId>
   <artifactId>maven-debian</artifactId>
-  <version>0.1</version>
+  <version>0.2</version>
   <packaging>pom</packaging>
   <name>helper tools for using Maven to build Debian packages</name>
 




More information about the pkg-java-commits mailing list