[Git][java-team/maven-debian-helper][master] 5 commits: Use the Maven logger in GenerateDebianFilesMojo instead of System.err/out

Emmanuel Bourg gitlab at salsa.debian.org
Tue Jun 26 23:38:35 BST 2018


Emmanuel Bourg pushed to branch master at Debian Java Maintainers / maven-debian-helper


Commits:
5fae5de4 by Emmanuel Bourg at 2018-06-26T22:38:14+02:00
Use the Maven logger in GenerateDebianFilesMojo instead of System.err/out

- - - - -
5ef52fea by Emmanuel Bourg at 2018-06-27T00:22:39+02:00
Added an 'executable' parameter to the generateFile() method in GenerateDebianFilesMojo

- - - - -
dfa79996 by Emmanuel Bourg at 2018-06-27T00:31:01+02:00
No longer ignore the JavaBeans Activation Framework dependencies (removed from Java 9)

- - - - -
f194bbbd by Emmanuel Bourg at 2018-06-27T00:34:06+02:00
Use XZ compression by default when repacking tarballs downloaded from GitHub

- - - - -
2d1010b8 by Emmanuel Bourg at 2018-06-27T00:37:49+02:00
Minor code simplification in GenerateDebianFilesMojo

- - - - -


4 changed files:

- debian/changelog
- maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
- maven-packager-utils/src/main/java/org/debian/maven/packager/util/IgnoreDependencyQuestions.java
- maven-packager-utils/src/main/resources/watch.github.vm


Changes:

=====================================
debian/changelog
=====================================
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,8 @@ maven-debian-helper (2.3~exp2) UNRELEASED; urgency=medium
 
   * Team upload.
   * No longer support generating CDBS based packages
+  * No longer ignore the JavaBeans Activation Framework dependencies (removed from Java 9)
+  * Use XZ compression by default when repacking tarballs downloaded from GitHub
   * Standards-Version updated to 4.1.4
   * The generated control file now specifies Standards-Version: 4.1.4
   * No longer generate the get-orig-source target in debian/rules


=====================================
maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
=====================================
--- a/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
+++ b/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
@@ -19,6 +19,7 @@ package org.debian.maven.packager;
 import java.io.File;
 import java.io.FileReader;
 import java.io.FileWriter;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
@@ -154,6 +155,7 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
     
     /**
      * If true, generate the Javadoc packaged in a separate package.
+     * 
      * @parameter expression="${generateJavadoc}" default-value="false"
      */
     protected boolean generateJavadoc;
@@ -162,17 +164,6 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
     private LicensesScanner licensesScanner = new LicensesScanner();
 
     public void execute() throws MojoExecutionException {
-        File f = outputDirectory;
-        if (!f.exists()) {
-            f.mkdirs();
-        }
-
-        String controlTemplate = "control.vm";
-        String rulesTemplate = "rules.vm";
-        if ("ant".equals(packageType)) {
-            controlTemplate = "control.ant.vm";
-            rulesTemplate = "rules.ant.vm";
-        }
         // #638788: clean up email
         if (email != null && email.indexOf('<') >= 0 && email.indexOf('>') >= 0) {
             email = email.substring(email.indexOf('<') + 1, email.indexOf('>') - 1);
@@ -239,7 +230,7 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
             }
             context.put("copyrightOwner", copyrightOwner);
 
-            if (projectTeam == null || projectTeam.isEmpty()) {
+            if (projectTeam.isEmpty()) {
                 projectTeam = project.getName() + " developers";
             }
             context.put("projectTeam", projectTeam);
@@ -255,7 +246,7 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
                 copyrightYear = String.valueOf(currentYear);
             }
             context.put("copyrightYear", copyrightYear);
-            context.put("currentYear", new Integer(currentYear));
+            context.put("currentYear", currentYear);
 
             if (project.getDescription() == null || project.getDescription().trim().isEmpty()) {
                 project.setDescription(new MultilineQuestion("Please enter a short description of the project, press Enter twice to stop.").ask());
@@ -332,7 +323,7 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
                     context.put("testJars", testJars);
                 }
             } else {
-                System.err.println("Cannot find file " + substvarsFile);
+                getLog().warn("Cannot find file " + substvarsFile);
             }
 
             if ("ant".equals(packageType)) {
@@ -378,8 +369,8 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
                     baseUrl = baseUrl.substring(0, slashPos);
                 }
                 if (tagPos < 0 && downloadUrl.contains("/trunk")) {
-                    System.out.println("Download URL does not include a tagged revision but /trunk found,");
-                    System.out.println("Trying to guess the address of the tagged revision.");
+                    getLog().warn("Download URL does not include a tagged revision but /trunk found,");
+                    getLog().warn("Trying to guess the address of the tagged revision.");
                     tag = "trunk";
                     tagPos = downloadUrl.indexOf(tag);
                     baseUrl = downloadUrl.substring(0, tagPos);
@@ -393,14 +384,12 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
                     context.put("suffixUrl", suffixUrl);
 
                     generateFile(context, "watch.svn.vm", outputDirectory, "watch");
-                    generateFile(context, "orig-tar.svn.vm", outputDirectory, "orig-tar.sh");
-
-                    new File("debian/orig-tar.sh").setExecutable(true);
+                    generateFile(context, "orig-tar.svn.vm", outputDirectory, "orig-tar.sh", true);
 
                 } else {
-                    System.err.println("Cannot locate the version in the download url (" + downloadUrl + ").");
-                    System.err.println("Please run again and provide the download location with an explicit version tag, e.g.");
-                    System.err.println("-DdownloadUrl=scm:svn:http://svn.codehaus.org/modello/tags/modello-1.0-alpha-21/");
+                    getLog().warn("Cannot locate the version in the download url (" + downloadUrl + ").");
+                    getLog().warn("Please run again and provide the download location with an explicit version tag, e.g.");
+                    getLog().warn("-DdownloadUrl=scm:svn:http://svn.codehaus.org/modello/tags/modello-1.0-alpha-21/");
                 }
             }
 
@@ -419,22 +408,17 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
             }
 
             if (downloadType == DownloadType.UNKNOWN) {
-                System.err.println("Cannot recognize the download url (" +
-                        downloadUrl + ").");
+                getLog().warn("Cannot recognize the download url (" + downloadUrl + ").");
             }
 
+            String rulesTemplate = "ant".equals(packageType) ? "rules.ant.vm" : "rules.vm";
+
             generateFile(context, "README.source.vm", outputDirectory, "README.source");
             generateFile(context, "copyright.vm", outputDirectory, "copyright");
             generateFile(context, "compat.vm", outputDirectory, "compat");
-            generateFile(context, rulesTemplate, outputDirectory, "rules");
-
-            new File("debian/rules").setExecutable(true);
+            generateFile(context, rulesTemplate, outputDirectory, "rules", true);
 
-            String debianVersion = projectVersion.replace("-alpha-", "~alpha");
-            debianVersion = debianVersion.replace("-beta-", "~beta");
-            debianVersion = debianVersion.replace("-rc-", "~rc");
-            debianVersion += "-1";
-            context.put("version.vm", debianVersion);
+            context.put("version.vm", mangleVersion(projectVersion) + "-1");
 
             generateFile(context, rulesTemplate, new File("."), ".debianVersion");
 
@@ -443,8 +427,8 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
                     generateFile(context, "java-doc.doc-base.api.multi.vm", outputDirectory, binPackageName + "-doc.doc-base.api");
                     generateFile(context, "java-doc.install.multi.vm", outputDirectory, binPackageName + "-doc.install");
                 } else {
-                  generateFile(context, "java-doc.doc-base.api.vm", outputDirectory, binPackageName + "-doc.doc-base.api");
-                  generateFile(context, "java-doc.install.vm", outputDirectory, binPackageName + "-doc.install");
+                    generateFile(context, "java-doc.doc-base.api.vm", outputDirectory, binPackageName + "-doc.doc-base.api");
+                    generateFile(context, "java-doc.install.vm", outputDirectory, binPackageName + "-doc.install");
                 }
             }
 
@@ -478,15 +462,25 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
                 generateFile(context, "maven.properties.vm", outputDirectory, "maven.properties");
             }
 
-            generateFile(context, controlTemplate, outputDirectory, "control");
+            generateFile(context, "ant".equals(packageType) ? "control.ant.vm" : "control.vm", outputDirectory, "control");
             generateFile(context, "format.vm", new File(outputDirectory, "source"), "format");
 
-        } catch (Exception ex) {
+        } catch (IOException ex) {
             ex.printStackTrace();
         }
     }
 
     /**
+     * Normalizes the project version for use as a Debian package version.
+     */
+    private String mangleVersion(String projectVersion) {
+        String debianVersion = projectVersion.replace("-alpha-", "~alpha");
+        debianVersion = debianVersion.replace("-beta-", "~beta");
+        debianVersion = debianVersion.replace("-rc-", "~rc");
+        return debianVersion;
+    }
+
+    /**
      * Format the specified text to be suitable as a package long description.
      * Lines are wrapped after 70 characters and a dot is placed on empty lines.
      * 
@@ -558,12 +552,20 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
         }
     }
 
-    private void generateFile(VelocityContext context, String templateName, File destDir, String fileName) throws Exception {
+    private void generateFile(VelocityContext context, String templateName, File destDir, String fileName) throws IOException {
+        generateFile(context, templateName, destDir, fileName);
+    }
+
+    private void generateFile(VelocityContext context, String templateName, File destDir, String fileName, boolean executable) throws IOException {
         destDir.mkdirs();
-        FileWriter out = new FileWriter(new File(destDir, fileName));
+        File file = new File(destDir, fileName);
+        FileWriter out = new FileWriter(file);
         Velocity.mergeTemplate(templateName, "UTF8", context, out);
         out.flush();
         out.close();
+        if (executable) {
+            file.setExecutable(true);
+        }
     }
 
     private List<String> split(String s) {


=====================================
maven-packager-utils/src/main/java/org/debian/maven/packager/util/IgnoreDependencyQuestions.java
=====================================
--- a/maven-packager-utils/src/main/java/org/debian/maven/packager/util/IgnoreDependencyQuestions.java
+++ b/maven-packager-utils/src/main/java/org/debian/maven/packager/util/IgnoreDependencyQuestions.java
@@ -20,12 +20,6 @@ public class IgnoreDependencyQuestions {
         {"org.apache.geronimo.specs", "geronimo-jaxb_2.1_spec"},
         {"org.apache.geronimo.specs", "geronimo-jaxb_2.2_spec"},
         {"jaxb", "jsr173_api"},
-        // Java Activation Framework (added to Java 6)
-        {"activation", "activation"},
-        {"javax.activation", "activation"},
-        {"jaf", "activation"},
-        {"org.apache.geronimo.specs", "geronimo-activation_1.0.2_spec"},
-        {"org.apache.geronimo.specs", "geronimo-activation_1.1_spec"},
         // JMX (added to Java 5)
         {"mx4j", "mx4j"},
         {"mx4j", "mx4j-jmx"},


=====================================
maven-packager-utils/src/main/resources/watch.github.vm
=====================================
--- a/maven-packager-utils/src/main/resources/watch.github.vm
+++ b/maven-packager-utils/src/main/resources/watch.github.vm
@@ -1,2 +1,3 @@
 version=3
+opts="repack,compression=xz" \
 https://github.com/${userId}/${repository}/tags .*/(?:.*?)([\d\.]+)\.tar\.gz



View it on GitLab: https://salsa.debian.org/java-team/maven-debian-helper/compare/bb4755e1b57dc07eb7ecc6754cbe306d448b1b07...2d1010b82bca4b33f9146674962d946455f12df9

-- 
View it on GitLab: https://salsa.debian.org/java-team/maven-debian-helper/compare/bb4755e1b57dc07eb7ecc6754cbe306d448b1b07...2d1010b82bca4b33f9146674962d946455f12df9
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20180626/6fd1f204/attachment.html>


More information about the pkg-java-commits mailing list