Author: drazzib
Date: 2011-09-01 00:06:53 +0000 (Thu, 01 Sep 2011)
New Revision: 14650

Modified:
   trunk/maven-debian-helper/debian/changelog
   
trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
Log:
* SysInstallMojo: Support "finalName" attribute to override
  expected artifact (conform to Maven standards).
* SysInstallMojo: Read usj-name, usj-version and no-usj-versionless.
  Closes: #629621.

Modified: trunk/maven-debian-helper/debian/changelog
===================================================================
--- trunk/maven-debian-helper/debian/changelog  2011-08-31 20:32:40 UTC (rev 
14649)
+++ trunk/maven-debian-helper/debian/changelog  2011-09-01 00:06:53 UTC (rev 
14650)
@@ -1,3 +1,12 @@
+maven-debian-helper (1.4.5) UNRELEASED; urgency=low
+
+  * SysInstallMojo: Support "finalName" attribute to override
+    expected artifact (conform to Maven standards).
+  * SysInstallMojo: Read usj-name, usj-version and no-usj-versionless.
+    Closes: #629621.
+
+ -- Damien Raude-Morvan <draz...@debian.org>  Thu, 01 Sep 2011 02:06:42 +0200
+
 maven-debian-helper (1.4.4) unstable; urgency=low
 
   [ Ludovic Claude ]

Modified: 
trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
===================================================================
--- 
trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
     2011-08-31 20:32:40 UTC (rev 14649)
+++ 
trunk/maven-debian-helper/maven-debian-plugin/src/main/java/org/debian/maven/plugin/SysInstallMojo.java
     2011-09-01 00:06:53 UTC (rev 14650)
@@ -21,14 +21,13 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
-import org.codehaus.plexus.util.FileUtils;
+
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.FileUtils;
 import org.debian.maven.repo.ListOfPOMs;
 import org.debian.maven.repo.POMCleaner;
-import org.debian.maven.repo.POMTransformer;
 
 /**
  * Install pom and jar files into the /usr/share/hierarchy
@@ -108,6 +107,15 @@
    * @readonly
    */
   private String jarDir;
+  
+  /**
+   * finalname of the artifact
+   *
+   * @parameter expression="${project.build.finalName}"
+   * @required
+   * @readonly
+   */
+  private String finalName;
 
   /**
    * Debian directory
@@ -151,6 +159,21 @@
      */
   private boolean installToUsj = true;
 
+  /**
+   * Basename of the JAR inside /usr/share/java
+   */
+       private String usjName;
+
+       /**
+        * Version of the JAR install /usr/share/java
+        */
+    private String usjVersion;
+
+    /**
+     * If true, disable installation of version-less JAR into /usr/share/java
+     */
+       private boolean noUsjVersionless;
+
   // ----------------------------------------------------------------------
   // Public methods
   // ----------------------------------------------------------------------
@@ -307,7 +330,16 @@
 
   protected String jarName()
   {
-    return artifactId + "-" + version + ".jar";
+         String jarName = "";
+         if (finalName != null && finalName.length() > 0)
+         {
+                 jarName += finalName;
+         }
+         else
+         {
+                 jarName += artifactId + "-" + version;
+         }
+    return jarName + ".jar";
   }
   
   protected String destJarName()
@@ -358,17 +390,66 @@
     return "../maven-repo" + destRepoPath() + destJarName();
   }
 
+  /**
+   * Example: /usr/share/java/xml-apis.jar
+   */
   protected String fullCompatPath()
   {
-    return compatSharePath() + compatName();
+    return compatSharePath() + destUsjJarName();
   }
 
+  /**
+   * Example: /usr/share/java/xml-apis-1.3.04.jar
+   */
   protected String versionedFullCompatPath()
   {
-    return compatSharePath() + destJarName();
+    return compatSharePath() + destUsjVersionnedJarName();
   }
+  
+  /**
+   * Compute version-less filename for installation into /usr/share/java
+   */
+  private String destUsjJarName() {
+         String usjJarName = "";
+         if (usjName != null && usjName.length() > 0)
+         {
+                 usjJarName += usjName;
+         }
+         else
+         {
+                 usjJarName += destArtifactId;
+         }
+                 
+         return usjJarName + ".jar";
+  }
 
   /**
+   * Compute versionned filename for installation into /usr/share/java
+   */
+  private String destUsjVersionnedJarName() {
+         String usjJarName = "";
+         if (usjName != null && usjName.length() > 0)
+         {
+                 usjJarName += usjName;
+         }
+         else
+         {
+                 usjJarName += destArtifactId;
+         }
+         
+         if (usjVersion != null && usjVersion.length() > 0)
+         {
+                 usjJarName += "-" + usjVersion;
+         }
+         else
+         {
+                 usjJarName += "-" + version;
+         }
+                 
+         return usjJarName + ".jar";
+  }
+
+/**
    * command for creating the relative symlink
    */
   private String[] linkCommand(String source, String dest)
@@ -422,7 +503,9 @@
     {
       mkdir(compatSharePath());
       System.out.println("Install link to " + artifactId + " into 
/usr/share/java");
-      run(linkCommand(compatRelPath(), fullCompatPath()));
+      if (!noUsjVersionless) {
+         run(linkCommand(compatRelPath(), fullCompatPath()));
+      }
       run(linkCommand(compatRelPath(), versionedFullCompatPath()));
     }
   }
@@ -457,6 +540,21 @@
     if (pomOption != null && pomOption.getDestPackage() != null) {
       destPackage = pomOption.getDestPackage();
     }
+    
+    // handle usj-name
+    if (pomOption != null && pomOption.getUsjName() != null) {
+      usjName = pomOption.getUsjName();
+    }
+    
+    // handle usj-version
+    if (pomOption != null && pomOption.getUsjVersion() != null) {
+      usjVersion = pomOption.getUsjVersion();
+    }
+    
+    // handle no-usj-versionless
+    if (pomOption != null) {
+      noUsjVersionless = pomOption.isNoUsjVersionless();
+    }
 
     List params = new ArrayList();
     params.add("--keep-pom-version");


_______________________________________________
pkg-java-commits mailing list
pkg-java-comm...@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-java-commits

Reply via email to