sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1515995 - in /sis/branches/JDK7: ./ core/sis-build-helper/ core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/ core/sis-build-helper/src/site/apt/
Date Tue, 20 Aug 2013 22:27:43 GMT
Author: desruisseaux
Date: Tue Aug 20 22:27:43 2013
New Revision: 1515995

URL: http://svn.apache.org/r1515995
Log:
Create the distribution file automatically.

Added:
    sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
  (with props)
    sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java
  (with props)
Modified:
    sis/branches/JDK7/core/sis-build-helper/pom.xml
    sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
    sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
    sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
    sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
    sis/branches/JDK7/core/sis-build-helper/src/site/apt/index.apt
    sis/branches/JDK7/pom.xml

Modified: sis/branches/JDK7/core/sis-build-helper/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/pom.xml?rev=1515995&r1=1515994&r2=1515995&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/pom.xml (original)
+++ sis/branches/JDK7/core/sis-build-helper/pom.xml Tue Aug 20 22:27:43 2013
@@ -84,6 +84,10 @@ Define Maven Mojos and Javadoc taglets f
       <artifactId>maven-plugin-api</artifactId>
       <version>3.0.5</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-compress</artifactId>
+    </dependency>
   </dependencies>
 
 

Added: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java?rev=1515995&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
(added)
+++ sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
[UTF-8] Tue Aug 20 22:27:43 2013
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.maven;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.FilenameFilter;
+import java.io.FileInputStream;
+import java.io.FilterOutputStream;
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
+import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
+
+import static org.apache.sis.internal.maven.Filenames.*;
+
+
+/**
+ * Creates a ZIP files containing the content of the <code>application/sis-console/src/main/artifact</code>
+ * directory together with the Pack200 file created by <code>BundleCreator</code>.
+ * This mojo can be invoked from the command line as below:
+ *
+ * <blockquote><code>mvn org.apache.sis.core:sis-build-helper:dist --non-recursive</code></blockquote>
+ *
+ * Do not forget the <code>--non-recursive</code> option, otherwise the Mojo
will be executed many time.
+ *
+ * <p><b>Current limitation:</b>
+ * The directory to ZIP is hard-coded to <code>application/sis-console/src/main/artifact</code>,
+ * and the final name is hard coded to <code>apache-sis-&lt;version&gt;.zip</code>
for now.</p>
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ *
+ * @goal dist
+ * @phase install
+ */
+public class Assembler extends AbstractMojo implements FilenameFilter {
+    /**
+     * Project information (name, version, URL).
+     *
+     * @parameter default-value="${project}"
+     * @required
+     * @readonly
+     */
+    private MavenProject project;
+
+    /**
+     * The root directory (without the "<code>target/binaries</code>" sub-directory)
where JARs
+     * are to be copied. It should be the directory of the root <code>pom.xml</code>.
+     *
+     * @parameter property="session.executionRootDirectory"
+     * @required
+     */
+    private String rootDirectory;
+
+    /**
+     * Creates the distribution file.
+     *
+     * @throws MojoExecutionException if the plugin execution failed.
+     */
+    @Override
+    public void execute() throws MojoExecutionException {
+        final File sourceDirectory = new File(rootDirectory, ARTIFACT_PATH);
+        if (!sourceDirectory.isDirectory()) {
+            throw new MojoExecutionException("Directory not found: " + sourceDirectory);
+        }
+        final File targetDirectory = new File(rootDirectory, TARGET_DIRECTORY);
+        final String version = project.getVersion();
+        final String artifactBase = FINALNAME_PREFIX + version;
+        try {
+            final File targetFile = new File(distributionDirectory(targetDirectory), artifactBase
+ ".zip");
+            try (ZipArchiveOutputStream zip = new ZipArchiveOutputStream(targetFile)) {
+                zip.setLevel(9);
+                appendRecursively(sourceDirectory, artifactBase, zip, new byte[8192]);
+                /*
+                 * At this point, all the "application/sis-console/src/main/artifact" and
sub-directories
+                 * have been zipped.  Now generate the Pack200 file and zip it directly (without
creating
+                 * a temporary "sis.pack.gz" file).
+                 */
+                final Packer packer = new Packer(project.getName(), project.getUrl(), version,
targetDirectory);
+                final ZipArchiveEntry entry = new ZipArchiveEntry(
+                        artifactBase + '/' + LIB_DIRECTORY + '/' + FATJAR_FILE + PACK_EXTENSION);
+                entry.setMethod(ZipArchiveEntry.STORED);
+                zip.putArchiveEntry(entry);
+                packer.preparePack200(FATJAR_FILE + ".jar").pack(new FilterOutputStream(zip)
{
+                    /*
+                     * Closes the archive entry, not the ZIP file.
+                     */
+                    @Override
+                    public void close() throws IOException {
+                        zip.closeArchiveEntry();
+                    }
+                });
+            }
+        } catch (IOException e) {
+            throw new MojoExecutionException(e.getLocalizedMessage(), e);
+        }
+    }
+
+    /**
+     * Adds the given file in the ZIP file. If the given file is a directory, then this method
+     * recursively adds all files contained in this directory. This method is invoked for
zipping
+     * the "application/sis-console/src/main/artifact" directory and sub-directories before
to zip
+     * the Pack200 file.
+     */
+    private void appendRecursively(final File file, String relativeFile, final ZipArchiveOutputStream
out,
+            final byte[] buffer) throws IOException
+    {
+        if (file.isDirectory()) {
+            relativeFile += '/';
+        }
+        final ZipArchiveEntry entry = new ZipArchiveEntry(file, relativeFile);
+        if (file.canExecute()) {
+            entry.setUnixMode(0744);
+        }
+        out.putArchiveEntry(entry);
+        if (!entry.isDirectory()) {
+            try (FileInputStream in = new FileInputStream(file)) {
+                int n;
+                while ((n = in.read(buffer)) >= 0) {
+                    out.write(buffer, 0, n);
+                }
+            }
+        }
+        out.closeArchiveEntry();
+        if (entry.isDirectory()) {
+            for (final String filename : file.list(this)) {
+                appendRecursively(new File(file, filename), relativeFile.concat(filename),
out, buffer);
+            }
+        }
+    }
+
+    /**
+     * The filter to use for selecting the files to be included in the ZIP file.
+     *
+     * @param  directory The directory.
+     * @param  filename  The filename.
+     * @return {@code true} if the given file should be included in the ZIP file.
+     */
+    @Override
+    public boolean accept(final File directory, final String filename) {
+        return !filename.isEmpty() && filename.charAt(0) != '.';
+    }
+}

Propchange: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Assembler.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java?rev=1515995&r1=1515994&r2=1515995&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/BundleCreator.java
[UTF-8] Tue Aug 20 22:27:43 2013
@@ -22,16 +22,20 @@ import org.apache.maven.plugin.AbstractM
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 
+import static org.apache.sis.internal.maven.Filenames.*;
+
 
 /**
  * Merges the binaries produced by <code>JarCollector</code> and compress them
using Pack200.
- * This mojo delegates the work to <code>Packer</code>, which can be invoked
from the command
- * line without Maven. Maven invocation syntax is:
+ * This mojo can be invoked from the command line as below:
  *
  * <blockquote><code>mvn org.apache.sis.core:sis-build-helper:pack --non-recursive</code></blockquote>
  *
  * Do not forget the <code>--non-recursive</code> option, otherwise the Mojo
will be executed many time.
  *
+ * <p><b>Current limitation:</b>
+ * The final name is hard coded to <code>apache-sis-&lt;version&gt;.pack.gz</code>
for now.</p>
+ *
  * @author  Martin Desruisseaux (Geomatys)
  * @since   0.3 (derived from geotk-3.00)
  * @version 0.4
@@ -60,19 +64,20 @@ public class BundleCreator extends Abstr
     private String rootDirectory;
 
     /**
-     * Creates the Pack200 files from the JAR files collected in the "<code>target/binaries</code>"
directory.
+     * Creates the Pack200 file from the JAR files collected in the "<code>target/binaries</code>"
directory.
      *
      * @throws MojoExecutionException if the plugin execution failed.
      */
     @Override
     public void execute() throws MojoExecutionException {
-        final File targetDirectory = new File(rootDirectory, JarCollector.TARGET_DIRECTORY);
+        final File targetDirectory = new File(rootDirectory, TARGET_DIRECTORY);
         if (!targetDirectory.isDirectory()) {
             throw new MojoExecutionException("Directory not found: " + targetDirectory);
         }
+        final String version = project.getVersion();
         try {
-            final Packer packer = new Packer(project.getName(), project.getUrl(), project.getVersion(),
targetDirectory);
-            packer.createPack200("sis.jar");
+            final Packer packer = new Packer(project.getName(), project.getUrl(), version,
targetDirectory);
+            packer.preparePack200(FINALNAME_PREFIX + version + ".jar").pack();
         } catch (IOException e) {
             throw new MojoExecutionException(e.getLocalizedMessage(), e);
         }

Added: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java?rev=1515995&view=auto
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java
(added)
+++ sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java
[UTF-8] Tue Aug 20 22:27:43 2013
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.internal.maven;
+
+import java.io.File;
+import java.io.IOException;
+
+
+/**
+ * Hard-coded file and directory names used by this package.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @since   0.4
+ * @version 0.4
+ * @module
+ */
+final class Filenames {
+    /**
+     * The target directory.
+     */
+    static final String TARGET_DIRECTORY = "target";
+
+    /**
+     * The sub-directory (inside {@code target}) for binaries.
+     */
+    static final String BINARIES_DIRECTORY = "binaries";
+
+    /**
+     * The name of the file where to list SIS JAR files and their dependencies
+     * on platforms that do not support hard links.
+     */
+    static final String CONTENT_FILE = "content.txt";
+
+    /**
+     * The sub-directory (inside {@code target}) containing pack files.
+     * This directory will be automatically created if it does not already exist.
+     */
+    static final String DISTRIBUTION_DIRECTORY = "distribution";
+
+    /**
+     * The directory to zip for creating the distribution ZIP file.
+     */
+    static final String ARTIFACT_PATH = "application/sis-console/src/main/artifact";
+
+    /**
+     * The name of the {@code lib} directory in the artifact.
+     */
+    static final String LIB_DIRECTORY = "lib";
+
+    /**
+     * The big JAR file which will contains everything, without extension.
+     */
+    static final String FATJAR_FILE = "sis";
+
+    /**
+     * The prefix of the final filename. This is hard coded for now.
+     */
+    static final String FINALNAME_PREFIX = "apache-sis-";
+
+    /**
+     * The extension for Pack200 files.
+     */
+    static final String PACK_EXTENSION = ".pack.gz";
+
+    /**
+     * Do not allow instantiation of this class.
+     */
+    private Filenames() {
+    }
+
+    /**
+     * Returns the distribution directory, creating it if needed.
+     *
+     * @param targetDirectory The {@code target} directory.
+     */
+    static File distributionDirectory(final File targetDirectory) throws IOException {
+        final File outDirectory = new File(targetDirectory, DISTRIBUTION_DIRECTORY);
+        if (!outDirectory.isDirectory()) {
+            if (!outDirectory.mkdir()) {
+                throw new IOException("Can't create the \"" + DISTRIBUTION_DIRECTORY + "\"
directory.");
+            }
+        }
+        return outDirectory;
+    }
+}

Propchange: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Filenames.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8

Modified: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java?rev=1515995&r1=1515994&r2=1515995&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/JarCollector.java
[UTF-8] Tue Aug 20 22:27:43 2013
@@ -32,6 +32,8 @@ import org.apache.maven.plugin.MojoExecu
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.artifact.Artifact;
 
+import static org.apache.sis.internal.maven.Filenames.*;
+
 
 /**
  * Collects <code>.jar</code> files in a single "{@code target/binaries}" directory.
@@ -50,22 +52,6 @@ import org.apache.maven.artifact.Artifac
  */
 public final class JarCollector extends AbstractMojo implements FileFilter {
     /**
-     * The target directory.
-     */
-    static final String TARGET_DIRECTORY = "target";
-
-    /**
-     * The sub directory to create inside the "target" directory.
-     */
-    static final String SUB_DIRECTORY = "binaries";
-
-    /**
-     * The name of the file where to list SIS JAR files and their dependencies
-     * on platforms that do not support hard links.
-     */
-    static final String CONTENT_FILE = "content.txt";
-
-    /**
      * The Maven project running this plugin.
      *
      * @parameter property="project"
@@ -121,7 +107,7 @@ public final class JarCollector extends 
         File collect = new File(rootDirectory, TARGET_DIRECTORY);
         if (!collect.exists()) {
             if (!collect.mkdir()) {
-                throw new MojoExecutionException("Failed to create target directory.");
+                throw new MojoExecutionException("Failed to create \"" + TARGET_DIRECTORY
+ "\" directory.");
             }
         }
         if (collect.getCanonicalFile().equals(jarFile.getParentFile().getCanonicalFile()))
{
@@ -137,10 +123,10 @@ public final class JarCollector extends 
          * Creates a "binaries" subdirectory inside the "target" directory, then copy the
          * JAR file compiled by Maven. If an JAR file already existed, it will be deleted.
          */
-        collect = new File(collect, SUB_DIRECTORY);
+        collect = new File(collect, BINARIES_DIRECTORY);
         if (!collect.exists()) {
             if (!collect.mkdir()) {
-                throw new MojoExecutionException("Failed to create binaries directory.");
+                throw new MojoExecutionException("Failed to create \"" + BINARIES_DIRECTORY
+ "\" directory.");
             }
         }
         File copy = new File(collect, jarFile.getName());

Modified: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java?rev=1515995&r1=1515994&r2=1515995&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/PackOutput.java
[UTF-8] Tue Aug 20 22:27:43 2013
@@ -31,6 +31,7 @@ import java.io.FileOutputStream;
 import java.util.zip.GZIPOutputStream;
 
 import static java.util.jar.Pack200.Packer.*;
+import static org.apache.sis.internal.maven.Filenames.*;
 
 
 /**
@@ -272,6 +273,15 @@ final class PackOutput implements Closea
      */
     @Override
     public void close() throws IOException {
+        for (final PackInput input : inputJARs.values()) {
+            /*
+             * The code in this loop is never executed in normal execution, since the map
shall be empty after
+             * successful completion of 'writeContent()'. However the map may be non-empty
if the above method
+             * threw an exception, in which case this 'close()' method will be invoked in
a 'finally' block.
+             */
+            input.close();
+        }
+        inputJARs.clear();
         if (outputStream != null) {
             outputStream.close();
         }
@@ -293,14 +303,25 @@ final class PackOutput implements Closea
         if (ext > 0) {
             filename = filename.substring(0, ext);
         }
-        filename += ".pack.gz";
+        filename += PACK_EXTENSION;
         final File outputFile = new File(inputFile.getParent(), filename);
         if (outputFile.equals(inputFile)) {
             throw new IOException("Input file is already packed: " + inputFile);
         }
-        /*
-         * Now process to the compression.
-         */
+        pack(new FileOutputStream(outputFile));
+    }
+
+    /**
+     * Creates a Pack200 file from the output JAR, then delete the JAR.
+     *
+     * @param  out Where to write the Pack200. This stream will be closed by this method.
+     * @throws IOException if an error occurred while packing the JAR.
+     */
+    void pack(final OutputStream out) throws IOException {
+        if (outputStream != null) {
+            throw new IllegalStateException("JAR output stream not closed.");
+        }
+        final File inputFile = outputJAR;
         final Pack200.Packer packer = Pack200.newPacker();
         final Map<String,String> p = packer.properties();
         p.put(EFFORT, String.valueOf(9));  // Maximum compression level.
@@ -309,8 +330,8 @@ final class PackOutput implements Closea
         p.put(DEFLATE_HINT,       TRUE);   // Ignore all JAR deflation requests.
         p.put(UNKNOWN_ATTRIBUTE,  ERROR);  // Throw an error if an attribute is unrecognized
         try (JarFile jarFile = new JarFile(inputFile)) {
-            try (OutputStream out = new GZIPOutputStream(new FileOutputStream(outputFile)))
{
-                packer.pack(jarFile, out);
+            try (OutputStream deflater = new GZIPOutputStream(out)) {
+                packer.pack(jarFile, deflater);
             }
         }
         if (!inputFile.delete()) {

Modified: sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java?rev=1515995&r1=1515994&r2=1515995&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
[UTF-8] (original)
+++ sis/branches/JDK7/core/sis-build-helper/src/main/java/org/apache/sis/internal/maven/Packer.java
[UTF-8] Tue Aug 20 22:27:43 2013
@@ -25,6 +25,8 @@ import java.io.FilenameFilter;
 import java.io.FileNotFoundException;
 import java.io.IOException;
 
+import static org.apache.sis.internal.maven.Filenames.*;
+
 
 /**
  * Creates a PACK200 files from the JAR in the {@code target/binaries} directory.
@@ -38,12 +40,6 @@ import java.io.IOException;
  */
 final class Packer implements FilenameFilter {
     /**
-     * The {@code target} sub-directory containing pack files.
-     * This directory will be automatically created if it does not already exist.
-     */
-    private static final String PACK_DIRECTORY = "distribution";
-
-    /**
      * The project name, URL and version to declare in the manifest file, or {@code null}
if none.
      */
     private final String projectName, projectURL, version;
@@ -75,7 +71,7 @@ final class Packer implements FilenameFi
         this.projectURL  = projectURL;
         this.version     = version;
         this.targetDirectory = targetDirectory;
-        this.binariesDirectory = new File(targetDirectory, JarCollector.SUB_DIRECTORY);
+        this.binariesDirectory = new File(targetDirectory, BINARIES_DIRECTORY);
         if (!binariesDirectory.isDirectory()) {
             throw new FileNotFoundException("Directory not found: " + binariesDirectory);
         }
@@ -98,7 +94,7 @@ final class Packer implements FilenameFi
      * All input JAR files are opened by this method. They will need to be closed by {@link
PackInput#close()}.
      */
     private Map<File,PackInput> getInputJARs() throws IOException {
-        final Set<String> filenames = JarCollector.loadDependencyList(new File(binariesDirectory,
JarCollector.CONTENT_FILE));
+        final Set<String> filenames = JarCollector.loadDependencyList(new File(binariesDirectory,
CONTENT_FILE));
         filenames.addAll(Arrays.asList(binariesDirectory.list(this)));
         final Map<File,PackInput> inputJARs = new LinkedHashMap<>(filenames.size()
* 4/3);
         for (final String filename : filenames) {
@@ -117,29 +113,28 @@ final class Packer implements FilenameFi
     }
 
     /**
-     * Creates the Pack 200 file which will contain every JAR files in the {@code target/binaries}
directory.
+     * Prepares the Pack 200 file which will contain every JAR files in the {@code target/binaries}
directory.
      * The given {@code outputJAR} name is the name of the JAR file to create before to be
packed.
      * This filename shall end with the "{@code .jar}" suffix.
      *
+     * <p>Callers needs to invoke one of the {@code PackOutput.pack(…)} methods on
the returned object.</p>
+     *
      * @param  outputJAR The name of the JAR file to create before the Pack200 creation.
      * @throws IOException If an error occurred while collecting the target directory content.
      */
-    public void createPack200(final String outputJAR) throws IOException {
+    PackOutput preparePack200(final String outputJAR) throws IOException {
         /*
          * Creates the output directory. We do that first in order to avoid the
          * costly opening of all JAR files if we can't create this directory.
          */
-        final File outDirectory = new File(targetDirectory, PACK_DIRECTORY);
-        if (!outDirectory.isDirectory()) {
-            if (!outDirectory.mkdir()) {
-                throw new IOException("Can't create the \"" + PACK_DIRECTORY + "\" directory.");
-            }
+        final File outDirectory = distributionDirectory(targetDirectory);
+        final PackOutput output = new PackOutput(getInputJARs(), new File(outDirectory, outputJAR));
+        try {
+            output.open(projectName, projectURL, version);
+            output.writeContent();
+        } finally {
+            output.close();
         }
-        final PackOutput output;
-        output = new PackOutput(getInputJARs(), new File(outDirectory, outputJAR));
-        output.open(projectName, projectURL, version);
-        output.writeContent();
-        output.close();
-        output.pack();
+        return output;
     }
 }

Modified: sis/branches/JDK7/core/sis-build-helper/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/core/sis-build-helper/src/site/apt/index.apt?rev=1515995&r1=1515994&r2=1515995&view=diff
==============================================================================
--- sis/branches/JDK7/core/sis-build-helper/src/site/apt/index.apt [UTF-8] (original)
+++ sis/branches/JDK7/core/sis-build-helper/src/site/apt/index.apt [UTF-8] Tue Aug 20 22:27:43
2013
@@ -166,3 +166,14 @@ Building Apache SIS
 
   The Pack200 bundle does not include the <<<sis-webapp>>> module because
the later can be downloaded
   as a <<<WAR>>> file from the Maven repository.
+
+
+* Distribution file
+
+  The distribution file is a ZIP file containing the same Pack200 bundle than above,
+  together with a <<<README>>> file, configuration files and convenience
shell scripts.
+  The distribution file is generated as below:
+
+-------------------------------------------------------------------
+   mvn org.apache.sis.core:sis-build-helper:dist --non-recursive
+-------------------------------------------------------------------

Modified: sis/branches/JDK7/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK7/pom.xml?rev=1515995&r1=1515994&r2=1515995&view=diff
==============================================================================
--- sis/branches/JDK7/pom.xml (original)
+++ sis/branches/JDK7/pom.xml Tue Aug 20 22:27:43 2013
@@ -343,6 +343,11 @@ Apache SIS is a free software, Java lang
         <version>6.0</version>
         <scope>provided</scope>
       </dependency>
+      <dependency>
+        <groupId>org.apache.commons</groupId>
+        <artifactId>commons-compress</artifactId>
+        <version>1.5</version>
+      </dependency>
 
       <!-- Optional dependencies -->
       <dependency>



Mime
View raw message