[pkg-java] r9393 - in trunk/maven-debian-helper/maven-packager-utils/src/main: java/org/debian/maven/packager resources

Ludovic Claude ludovicc-guest at alioth.debian.org
Sat Jul 25 22:16:40 UTC 2009


Author: ludovicc-guest
Date: 2009-07-25 22:16:36 +0000 (Sat, 25 Jul 2009)
New Revision: 9393

Modified:
   trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java
   trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
   trunk/maven-debian-helper/maven-packager-utils/src/main/resources/README.source.vm
   trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm
   trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm
   trunk/maven-debian-helper/maven-packager-utils/src/main/resources/orig-tar.svn.vm
   trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.ant.vm
Log:
* Improve pom cleanup

Modified: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java	2009-07-25 19:31:58 UTC (rev 9392)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/DependenciesSolver.java	2009-07-25 22:16:36 UTC (rev 9393)
@@ -198,9 +198,9 @@
             if (pom.exists()) {
                 projects.add(pom);
             } else {
-                File debianPom = new File(baseDir, "debian/pom.xml");
-                if (debianPom.exists()) {
-                    projects.add(debianPom);
+                pom = new File(baseDir, "debian/pom.xml");
+                if (pom.exists()) {
+                    projects.add(pom);
                 } else {
                     System.err.println("Cannot find the POM file");
                     return;

Modified: trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java	2009-07-25 19:31:58 UTC (rev 9392)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java	2009-07-25 22:16:36 UTC (rev 9393)
@@ -106,7 +106,7 @@
     protected String binPackageName;
     /**
      * Type of the package (e.g. 'maven' or 'ant')
-     * @parameter expression="${packageType}" default="maven"
+     * @parameter expression="${packageType}" default-value="maven"
      */
     protected String packageType;
     /**
@@ -118,12 +118,12 @@
     protected String downloadUrl;
     /**
      * If true, include running the tests during the build.
-     * @parameter expression="${runTests}" default="true"
+     * @parameter expression="${runTests}" default-value="false"
      */
     protected boolean runTests;
     /**
      * If true, generate the Javadoc packaged in a separate package.
-     * @parameter expression="${generateJavadoc}" default="true"
+     * @parameter expression="${generateJavadoc}" default-value="false"
      */
     protected boolean generateJavadoc;
 
@@ -150,6 +150,7 @@
             Velocity.init(velocityProperties);
             VelocityContext context = new VelocityContext();
             context.put("package", packageName);
+            context.put("packageType", packageType);
             context.put("binPackage", binPackageName);
             context.put("packager", packager);
             context.put("packagerEmail", email);
@@ -173,16 +174,84 @@
             context.put("licenses", new TreeSet());
             List description = new ArrayList();
             if (project.getDescription() != null) {
-                StringTokenizer st = new StringTokenizer(project.getDescription().trim(), "\n");
+                StringTokenizer st = new StringTokenizer(project.getDescription().trim(), "\n\t ");
+                StringBuffer descLine = new StringBuffer();
                 while (st.hasMoreTokens()) {
-                    description.add(st.nextToken().trim());
+                    descLine.append(st.nextToken());
+                    descLine.append(" ");
+                    if (descLine.length() > 70 || !st.hasMoreTokens()) {
+                        String line = descLine.toString().trim();
+                        if (line.isEmpty()) {
+                            line = ".";
+                        }
+                        description.add(line);
+                        descLine = new StringBuffer();
+                    }
                 }
             }
             context.put("description", description);
 
+            File substvarsFile = new File(outputDirectory, binPackageName + ".substvars");
+            if (substvarsFile.exists()) {
+                Properties substvars = new Properties();
+                substvars.load(new FileReader(substvarsFile));
+                List depends = new ArrayList();
+                depends.addAll(split(substvars.getProperty("maven.CompileDepends")));
+                depends.addAll(split(substvars.getProperty("maven.Depends")));
+                if (runTests) {
+                    depends.addAll(split(substvars.getProperty("maven.TestDepends")));
+                }
+                if ("maven".equals(packageType)) {
+                    // Remove dependencies that are implied by maven-debian-helper
+                    depends.remove("libmaven-clean-plugin-java");
+                    depends.remove("libmaven-resources-plugin-java");
+                    depends.remove("libmaven-compiler-plugin-java");
+                    depends.remove("libmaven-jar-plugin-java");
+                    depends.remove("libmaven-site-plugin-java");
+                    depends.remove("libsurefire-java");
+                    depends.remove("velocity");
+                    depends.remove("libplexus-velocity-java");
+                    if (generateJavadoc) {
+                        depends.add("libmaven-javadoc-plugin-java");
+                    }
+                } else if ("ant".equals(packageType)) {
+                    // Remove dependencies that are implied by ant packaging
+                    depends.remove("ant");
+                    depends.remove("ant-optional");
+                }
+                context.put("compileDependencies", depends);
+                context.put("runtimeDependencies", split(substvars.getProperty("maven.Depends")));
+                context.put("optionalDependencies", split(substvars.getProperty("maven.OptionalDepends")));
+
+                if ("ant".equals(packageType)) {
+                    Set buildJars = new TreeSet();
+                    for (Iterator i = depends.iterator(); i.hasNext();) {
+                        String library = (String) i.next();
+                        buildJars.addAll(listSharedJars(library));
+                    }
+                    context.put("buildJars", buildJars);
+                }
+            } else {
+                System.err.println("Cannot find file " + substvarsFile);
+            }
+
+            if ("ant".equals(packageType)) {
+                List pomDirs = new ArrayList();
+                if (collectedProjects.isEmpty()) {
+                    pomDirs.add("");
+                }
+                for (Iterator i = collectedProjects.iterator(); i.hasNext();) {
+                    MavenProject mavenProject = (MavenProject) i.next();
+                    String basedir = project.getBasedir().getAbsolutePath();
+                    String dirRelPath = mavenProject.getBasedir().getAbsolutePath().substring(basedir.length() + 1);
+                    pomDirs.add(dirRelPath);
+                }
+                context.put("pomDirs", pomDirs);
+            }
+
             String projectVersion = project.getVersion();
+            int downloadType = DownloadType.UNKNOWN;
 
-            int downloadType = DownloadType.UNKNOWN;
             if (downloadUrl == null) {
                 if (project.getScm() != null) {
                     downloadUrl = project.getScm().getConnection();
@@ -191,17 +260,32 @@
             if (downloadUrl != null && downloadUrl.startsWith("scm:svn:")) {
                 downloadType = DownloadType.SVN;
                 downloadUrl = downloadUrl.substring("scm:svn:".length());
-                final int versionPos = downloadUrl.indexOf(projectVersion);
-                if (versionPos > 0) {
-                    String baseUrl = downloadUrl.substring(0, versionPos);
-                    String suffixUrl = downloadUrl.substring(versionPos + projectVersion.length());
+                String tag = projectVersion;
+                int tagPos = downloadUrl.indexOf(tag);
+                String baseUrl = null;
+                String suffixUrl = null;
+                String tagMarker = null;
+                if (tagPos >= 0) {
+                    baseUrl = downloadUrl.substring(0, tagPos);
+                    suffixUrl = downloadUrl.substring(tagPos + tag.length());
                     if (!suffixUrl.endsWith("/")) {
                         suffixUrl += "/";
                     }
                     int slashPos = baseUrl.lastIndexOf("/");
-                    String tagMarker = baseUrl.substring(slashPos + 1);
+                    tagMarker = baseUrl.substring(slashPos + 1);
                     baseUrl = baseUrl.substring(0, slashPos);
-
+                }
+                if (tagPos < 0 && downloadUrl.indexOf("/trunk") >= 0) {
+                    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.");
+                    tag = "trunk";
+                    tagPos = downloadUrl.indexOf(tag);
+                    baseUrl = downloadUrl.substring(0, tagPos);
+                    baseUrl += "tags";
+                    tagMarker = packageName  + "-";
+                    suffixUrl = "";
+                }
+                if (tagPos >= 0) {
                     context.put("baseUrl", baseUrl);
                     context.put("tagMarker", tagMarker);
                     context.put("suffixUrl", suffixUrl);
@@ -231,49 +315,6 @@
                         downloadUrl + ").");
             }
 
-            File substvarsFile = new File(outputDirectory, binPackageName + ".substvars");
-            if (substvarsFile.exists()) {
-                Properties substvars = new Properties();
-                substvars.load(new FileReader(substvarsFile));
-                List depends = new ArrayList();
-                depends.addAll(split(substvars.getProperty("maven.CompileDepends")));
-                depends.addAll(split(substvars.getProperty("maven.Depends")));
-                if (runTests) {
-                    depends.addAll(split(substvars.getProperty("maven.TestDepends")));
-                }
-                if ("maven".equals(packageType) && generateJavadoc) {
-                    depends.add("libmaven-javadoc-plugin-java");
-                }
-                context.put("compileDependencies", depends);
-                context.put("runtimeDependencies", split(substvars.getProperty("maven.Depends")));
-                context.put("optionalDependencies", split(substvars.getProperty("maven.OptionalDepends")));
-
-                if ("ant".equals(packageType)) {
-                    Set buildJars = new TreeSet();
-                    for (Iterator i = depends.iterator(); i.hasNext();) {
-                        String library = (String) i.next();
-                        buildJars.addAll(listSharedJars(library));
-                    }
-                    context.put("buildJars", buildJars);
-                }
-            } else {
-                System.err.println("Cannot find file " + substvarsFile);
-            }
-
-            if ("ant".equals(packageType)) {
-                List pomDirs = new ArrayList();
-                if (collectedProjects.isEmpty()) {
-                    pomDirs.add("");
-                }
-                for (Iterator i = collectedProjects.iterator(); i.hasNext();) {
-                    MavenProject mavenProject = (MavenProject) i.next();
-                    String basedir = project.getBasedir().getAbsolutePath();
-                    String dirRelPath = mavenProject.getBasedir().getAbsolutePath().substring(basedir.length() + 1);
-                    pomDirs.add(dirRelPath);
-                }
-                context.put("pomDirs", pomDirs);
-            }
-
             FileWriter out = new FileWriter(new File(outputDirectory, "README.source"));
             Velocity.mergeTemplate("README.source.vm", "UTF8", context, out);
             out.flush();

Modified: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/README.source.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/README.source.vm	2009-07-25 19:31:58 UTC (rev 9392)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/README.source.vm	2009-07-25 22:16:36 UTC (rev 9393)
@@ -4,6 +4,8 @@
 This package was debianized using the mh_make command
 from the maven-debian-helper package.
 
+#if(${packageType} == 'maven')
 The build system uses Maven but prevent it from downloading
 anything from the Internet, making the build compliant with
 the Debian policy.
+#end

Modified: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm	2009-07-25 19:31:58 UTC (rev 9392)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.ant.vm	2009-07-25 22:16:36 UTC (rev 9393)
@@ -3,7 +3,9 @@
 #macro(printDependencies $dependencies)
 #set ($lineLength=0)
 #foreach ($dependency in $dependencies)
-#if($lineLength==0)${space}#end${dependency}#if($velocityHasNext), #end
+#if($lineLength==0)${space}#end${dependency}#if($velocityCount<$dependencies.size()), #else
+$space
+#end
 #set ($lineLength = $lineLength + $dependency.length() + 2)
 #if ($lineLength > 70)
 $space
@@ -32,17 +34,18 @@
 #printDependencies($runtimeDependencies)
 #if(!$optionalDependencies.isEmpty())
 Recommends: #printDependencies($optionalDependencies)
-#fi
-Description:#if ($description.isEmpty()) TODO - fill the description #else $description.get(0) #end
+#end
+Description: ${project.Name}
+#if ($description.isEmpty()) TODO - fill the description
+#else
 #foreach ($line in $description)
-#if ($velocityCount > 1)
- #if ($line == "")
+#if ($line == "")
  .
- #else
+#else
  $line
- #end
 #end
 #end
+#end
 
 
 #if ($generateJavadoc)
@@ -55,13 +58,13 @@
 #if ($description.isEmpty()) TODO - fill the description #else $description.get(0) #end
 #foreach ($line in $description)
 #if ($velocityCount > 1)
- #if ($line == "")
+#if ($line == "")
  .
- #else
+#else
  $line
- #end
 #end
 #end
+#end
 
  .
  This package provides the API documentation for ${binPackage}.

Modified: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm	2009-07-25 19:31:58 UTC (rev 9392)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/control.vm	2009-07-25 22:16:36 UTC (rev 9393)
@@ -31,16 +31,17 @@
 ## libraries should not depend on runtime - default-jre-headless | java2-runtime-headless,
 Depends: ${dollar}{misc:Depends}, ${dollar}{maven:Depends}
 Recommends: ${dollar}{maven:OptionalDepends}
-Description:#if ($description.isEmpty()) TODO - fill the description #else $description.get(0) #end
+Description: ${project.Name}
+#if ($description.isEmpty()) TODO - fill the description
+#else
 #foreach ($line in $description)
-#if ($velocityCount > 1)
- #if ($line == "")
+#if ($line == "")
  .
- #else
+#else
  $line
- #end
 #end
 #end
+#end
 
 
 #if ($generateJavadoc)
@@ -50,16 +51,16 @@
 Depends: ${dollar}{misc:Depends}
 Suggests: ${binPackage}
 Description: Documentation for ${project.Name}
-#if ($description.isEmpty()) TODO - fill the description #else $description.get(0) #end
+#if ($description.isEmpty()) TODO - fill the description
+#else
 #foreach ($line in $description)
-#if ($velocityCount > 1)
- #if ($line == "")
+#if ($line == "")
  .
- #else
+#else
  $line
- #end
 #end
 #end
+#end
 
  .
  This package provides the API documentation for ${binPackage}.

Modified: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/orig-tar.svn.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/orig-tar.svn.vm	2009-07-25 19:31:58 UTC (rev 9392)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/orig-tar.svn.vm	2009-07-25 22:16:36 UTC (rev 9393)
@@ -12,6 +12,5 @@
 # move to directory 'tarballs'
 if [ -r .svn/deb-layout ]; then
   . .svn/deb-layout
-  mv $TAR $origDir
-  echo "moved $TAR to $origDir"
+  mv $TAR $origDir && echo "moved $TAR to $origDir"
 fi

Modified: trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.ant.vm
===================================================================
--- trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.ant.vm	2009-07-25 19:31:58 UTC (rev 9392)
+++ trunk/maven-debian-helper/maven-packager-utils/src/main/resources/rules.ant.vm	2009-07-25 22:16:36 UTC (rev 9393)
@@ -2,13 +2,14 @@
 
 include /usr/share/cdbs/1/rules/debhelper.mk
 include /usr/share/cdbs/1/class/ant.mk
+#set ($space=' ')
 #macro(printJars $jars)
 #set ($lineLength=0)
 #foreach ($jar in $jars)
-#if($lineLength==0)${space}#end${jar}#if($velocityHasNext), #end
+#if($lineLength==0)${space}#end${jar}#if($velocityHasNext)${space}#end
 #set ($lineLength = $lineLength + $jar.length() + 2)
 #if ($lineLength > 70)
-$space
+${space}\
 #set ($lineLength=0)
 #end
 #end
@@ -17,7 +18,7 @@
 PACKAGE              := $(DEB_SOURCE_PACKAGE)
 VERSION              := $(DEB_UPSTREAM_VERSION)
 JAVA_HOME            := /usr/lib/jvm/default-java
-DEB_JARS             := ant-nodeps#if (!$buildJars.isEmpty()),#end
+DEB_JARS             := ant-nodeps#if (!$buildJars.isEmpty()) #end
 #printJars($buildJars)
 DEB_ANT_BUILDFILE    := /usr/share/maven-ant-helper/maven-build.xml
 DEB_ANT_ARGS         := -Dbasedir=$(realpath .) -Dpackage=$(PACKAGE) -Dversion=$(VERSION)




More information about the pkg-java-commits mailing list