sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1746859 - in /sis/branches/JDK8/core/sis-build-helper: ./ src/main/java/org/apache/sis/internal/unopkg/
Date Sun, 05 Jun 2016 01:24:43 GMT
Author: desruisseaux
Date: Sun Jun  5 01:24:43 2016
New Revision: 1746859

URL: http://svn.apache.org/viewvc?rev=1746859&view=rev
Log:
Initial port of custom Maven plugin for as an helper tool for building the OpenOffice add-in.
This is specific to Apache SIS - not a Maven plugin for general use - and may change or be
removed in any future SIS version.

Added:
    sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/
    sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/FilteredJarFile.java
  (with props)
    sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/JavaMaker.java
  (with props)
    sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
  (with props)
    sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/package-info.java
  (with props)
Modified:
    sis/branches/JDK8/core/sis-build-helper/pom.xml

Modified: sis/branches/JDK8/core/sis-build-helper/pom.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/pom.xml?rev=1746859&r1=1746858&r2=1746859&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/pom.xml (original)
+++ sis/branches/JDK8/core/sis-build-helper/pom.xml Sun Jun  5 01:24:43 2016
@@ -45,9 +45,9 @@
   <!-- Left alignment because this description will be copied in META-INF/MANIFEST.MF
        The leading space after the first line is necessary for proper formatting. -->
 Define Maven Mojos and Javadoc taglets for generating resource files
- or formatting the Javadoc. While any project could use it, this module
- is primarily for internal use by Apache SIS and may change in any
- future version.
+ formatting the Javadoc or creating ".oxt" files for OpenOffice.org.
+ While any project could use it, this module is primarily for internal
+ use by Apache SIS and may change in any future version.
   </description>
 
 

Added: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/FilteredJarFile.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/FilteredJarFile.java?rev=1746859&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/FilteredJarFile.java
(added)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/FilteredJarFile.java
[UTF-8] Sun Jun  5 01:24:43 2016
@@ -0,0 +1,120 @@
+/*
+ * 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.unopkg;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.jar.JarFile;
+import java.util.jar.JarEntry;
+import java.util.zip.ZipEntry;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+
+
+/**
+ * A JAR file which can exclude some file entries and some attributes from the {@code MANIFEST.MF}
file.
+ * The main purpose of this class is to exclude the signature from JAR files before to compress
them
+ * using the {@code pack200} tools, because {@code pack200} modifies the binary stream, thus
making
+ * the signature invalid. If we don't remove the signature, attempts to use the JAR file
may result
+ * in {@literal "SHA1 digest error for <JAR file>"} error messages.
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+final class FilteredJarFile extends JarFile {
+    /**
+     * The manifest encoding in JAR files.
+     */
+    private static final String MANIFEST_ENCODING = "UTF-8";
+
+    /**
+     * Open the file specified by the given name.
+     */
+    FilteredJarFile(final File filename) throws IOException {
+        super(filename);
+    }
+
+    /**
+     * Returns the list of entries, excluding Maven files (which are of no interest for the
add-in)
+     * and the signature.
+     */
+    @Override
+    public Enumeration<JarEntry> entries() {
+        final List<JarEntry> entries = Collections.list(super.entries());
+        for (final Iterator<JarEntry> it=entries.iterator(); it.hasNext();) {
+            final String name = it.next().getName();
+            if (name.startsWith("META-INF/")) {
+                if (name.startsWith("META-INF/maven/") || name.endsWith(".SF") || name.endsWith(".RSA"))
{
+                    it.remove();
+                }
+            }
+        }
+        return Collections.enumeration(entries);
+    }
+
+    /**
+     * Returns the input stream for the given entry. If the given entry is the manifest,
+     * then this method will filter the manifest content in order to exclude the signature.
+     */
+    @Override
+    public InputStream getInputStream(final ZipEntry ze) throws IOException {
+        final InputStream in = super.getInputStream(ze);
+        if (!ze.getName().equals(JarFile.MANIFEST_NAME)) {
+            return in;
+        }
+        final List<String> lines = new ArrayList<>();
+        try (BufferedReader reader = new BufferedReader(new InputStreamReader(in, MANIFEST_ENCODING)))
{
+            String line;
+            while ((line = reader.readLine()) != null) {
+                if (line.trim().startsWith("SHA1-Digest:")) {
+                    final int n = lines.size();
+                    if (n == 0 || !lines.get(n-1).trim().startsWith("Name:")) {
+                        throw new IOException("Can not process the following line from "
+
+                                JarFile.MANIFEST_NAME + ":\n" + line);
+                    }
+                    lines.remove(n-1);
+                    continue;
+                }
+                lines.add(line);
+            }
+        }
+        /*
+         * 'in' has been closed at this point (indirectly, by closing the reader).
+         * Now remove trailing empty lines, and returns the new MANIFEST.MF content.
+         */
+        for (int i=lines.size(); --i>=0;) {
+            if (!lines.get(i).trim().isEmpty()) {
+                break;
+            }
+            lines.remove(i);
+        }
+        final StringBuilder buffer = new StringBuilder(lines.size() * 60);
+        for (final String line : lines) {
+            buffer.append(line).append('\n');
+        }
+        return new ByteArrayInputStream(buffer.toString().getBytes(MANIFEST_ENCODING));
+    }
+}

Propchange: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/FilteredJarFile.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/JavaMaker.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/JavaMaker.java?rev=1746859&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/JavaMaker.java
(added)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/JavaMaker.java
[UTF-8] Sun Jun  5 01:24:43 2016
@@ -0,0 +1,101 @@
+/*
+ * 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.unopkg;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.codehaus.plexus.util.FileUtils;
+
+
+/**
+ * Compiles Java interfaces from OpenOffice IDL files.
+ *
+ * <p>In an ideal world, this plugin would execute {@code idlc} on the {@code *.idl}
files,
+ * then {@code regmerge} on the generated {@code *.urd} files,
+ * then {@code javamaker} on the generated {@code *.rdb} files.
+ * However, since the above mentioned tools are native and would require a manual installation
+ * on every developer machine, current version just copies a pre-compiled class file.
+ * This copy must occurs after the compilation phase (in order to overwrite the files generated
+ * by {@code javac}), which is why the usual Maven resources mechanism doesn't fit.
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+@Mojo(name = "javamaker", defaultPhase = LifecyclePhase.PROCESS_CLASSES)
+public final class JavaMaker extends AbstractMojo {
+    /**
+     * Base directory of the module to compile.
+     */
+    @Parameter(property="basedir", required=true, readonly=true)
+    private String baseDirectory;
+
+    /**
+     * Directory where the output Java files will be located.
+     */
+    @Parameter(property="project.build.outputDirectory", required=true, readonly=true)
+    private String outputDirectory;
+
+    /**
+     * Copies the {@code .class} files generated by OpenOffice.
+     *
+     * @throws MojoExecutionException if the plugin execution failed.
+     */
+    @Override
+    public void execute() throws MojoExecutionException {
+        final int n;
+        try {
+            n = copyClasses(new File(baseDirectory, UnoPkg.SOURCE_DIRECTORY), new File(outputDirectory));
+        } catch (IOException e) {
+            throw new MojoExecutionException("Failed to copy *.class files.", e);
+        }
+        getLog().info("[geotk-unopkg] Copied " + n + " pre-compiled class files.");
+    }
+
+    /**
+     * Copies {@code *.class} files from source directory to output directory.
+     * The output directory shall already exists. It should be the case if all
+     * sources files have been compiled before this method is invoked.
+     *
+     * @return The number of files copied.
+     */
+    private static int copyClasses(final File sourceDirectory,
+                                   final File outputDirectory) throws IOException
+    {
+        int n = 0;
+        final String[] filenames = sourceDirectory.list();
+        for (final String filename : filenames) {
+            final File file = new File(sourceDirectory, filename);
+            if (file.isFile()) {
+                if (filename.endsWith(".class") || filename.endsWith(".CLASS")) {
+                    FileUtils.copyFileToDirectory(file, outputDirectory);
+                    n++;
+                }
+            } else if (file.isDirectory()) {
+                n += copyClasses(file, new File(outputDirectory, filename));
+            }
+        }
+        return n;
+    }
+}

Propchange: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/JavaMaker.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java?rev=1746859&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
(added)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
[UTF-8] Sun Jun  5 01:24:43 2016
@@ -0,0 +1,286 @@
+/*
+ * 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.unopkg;
+
+import java.io.*;
+import java.util.Map;
+import java.util.zip.CRC32;
+import java.util.jar.JarFile;
+import java.util.jar.Pack200;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.project.MavenProject;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+
+import static java.util.jar.Pack200.Packer;
+
+
+/**
+ * Creates an {@code .oxt} package for <a href="http://www.openoffice.org">OpenOffice.org</a>
addins.
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+@Mojo(name = "unopkg", defaultPhase = LifecyclePhase.PACKAGE)
+public final class UnoPkg extends AbstractMojo implements FilenameFilter {
+    /**
+     * The subdirectory (relative to {@link #baseDirectory}) where the UNO files are expected.
+     */
+    static final String SOURCE_DIRECTORY = "src/main/unopkg";
+
+    /**
+     * The encoding for text files to read and write.
+     */
+    private static final String ENCODING = "UTF-8";
+
+    /**
+     * The string to replace by the final name.
+     */
+    private static final String SUBSTITUTE = "${project.build.finalName}";
+
+    /**
+     * Base directory of the module to compile.
+     * The UNO files are expect in the {@code "src/main/unopkg"} subdirectory.
+     * The plugin will look for the {@code META-INF/manifest.xml} and {@code *.rdb} files
in that directory.
+     */
+    @Parameter(property="basedir", required=true, readonly=true)
+    private String baseDirectory;
+
+    /**
+     * Directory where the output {@code .oxt} file will be located.
+     */
+    @Parameter(property="project.build.directory", required=true, readonly=true)
+    private String outputDirectory;
+
+    /**
+     * In {@code META-INF/manifest.xml}, all occurrences of {@code ${project.build.finalName}}
+     * will be replaced by this value.
+     */
+    @Parameter(property="project.build.finalName", required=true, readonly=true)
+    private String finalName;
+
+    /**
+     * The name for the {@code .oxt} file to create, without the {@code ".oxt"} filename
extension.
+     */
+    @Parameter(property="project.build.finalName", required=true, readonly=true)
+    private String oxtName;
+
+    /**
+     * {@code true} for using Pack200 compression. If {@code true}, then the add-in registration
+     * class needs to unpack the files itself before use. The default value is {@code false}.
+     */
+    @Parameter(defaultValue="false")
+    private String pack200;
+
+    /**
+     * The Maven project running this plugin.
+     */
+    @Parameter(property="project", required=true, readonly=true)
+    private MavenProject project;
+
+    /**
+     * The prefix to be added before JAR file names.
+     * To be determined by heuristic rule.
+     */
+    private transient String prefix;
+
+    /**
+     * Apply prefix only for dependencies of this group.
+     */
+    private transient String prefixGroup;
+
+    /**
+     * Tests if a specified file should be included in a file list.
+     *
+     * @param   directory the directory in which the file was found.
+     * @param   name      the name of the file.
+     */
+    @Override
+    public boolean accept(final File directory, final String name) {
+        if (name.endsWith("-sources.jar") || name.endsWith("-javadoc.jar")) {
+            return false;
+        }
+        return name.endsWith(".jar") || name.endsWith(".JAR") ||
+               name.endsWith(".rdb") || name.endsWith(".RDB") ||
+               name.endsWith(".xml") || name.endsWith(".XML") |
+               name.endsWith(".png") || name.endsWith(".PNG");
+    }
+
+    /**
+     * Generates the {@code .oxt} file from all {@code .jar} files found in the target directory.
+     *
+     * @throws MojoExecutionException if the plugin execution failed.
+     */
+    @Override
+    public void execute() throws MojoExecutionException {
+        final int i = finalName.indexOf(project.getArtifactId());
+        prefix = (i >= 0) ? finalName.substring(0, i) : "";
+        prefixGroup = project.getGroupId();
+        try {
+            createPackage();
+        } catch (IOException e) {
+            throw new MojoExecutionException("Error creating the oxt file.", e);
+        }
+    }
+
+    /**
+     * Creates the {@code .oxt} file.
+     */
+    private void createPackage() throws IOException {
+        final String  manifestName = "META-INF/manifest.xml";
+        final File sourceDirectory = new File(baseDirectory, SOURCE_DIRECTORY);
+        final File outputDirectory = new File(this.outputDirectory);
+        final File         zipFile = new File(outputDirectory, oxtName + ".oxt");
+        final File    manifestFile = new File(sourceDirectory, manifestName);
+        final File[]          jars = outputDirectory.listFiles(this);
+        final File[]          rdbs = sourceDirectory.listFiles(this);
+        try (ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFile))) {
+            out.setLevel(9);
+            if (manifestFile.isFile()) {
+                copyFiltered(manifestFile, out, manifestName);
+            }
+            /*
+             * Copies the RDB files.
+             */
+            for (int i=0; i<rdbs.length; i++) {
+                copy(rdbs[i], out, null);
+            }
+            /*
+             * Copies the JAR (and any additional JARs provided in the output directory).
+             * Do not pack this JAR, because it contains the code needed to inflate the
+             * PACK200 file.
+             */
+            for (int i=0; i<jars.length; i++) {
+                copy(jars[i], out, null);
+            }
+            /*
+             * Copies the dependencies, optionally in a single PACK200 entry.
+             */
+            Pack200.Packer packer = null;
+            if (Boolean.parseBoolean(pack200)) {
+                packer = Pack200.newPacker();
+                final Map<String,String> p = packer.properties();
+                p.put(Packer.EFFORT,            "9");               // take more time choosing
codings for better compression.
+                p.put(Packer.SEGMENT_LIMIT,     "-1");              // use largest-possible
archive segments (>10% better compression).
+                p.put(Packer.KEEP_FILE_ORDER,   Packer.FALSE);      // reorder files for
better compression.
+                p.put(Packer.MODIFICATION_TIME, Packer.LATEST);     // smear modification
times to a single value.
+                p.put(Packer.CODE_ATTRIBUTE_PFX+"LineNumberTable",    Packer.STRIP);    
   // discard debug attributes.
+                p.put(Packer.CODE_ATTRIBUTE_PFX+"LocalVariableTable", Packer.STRIP);    
   // discard debug attributes.
+                p.put(Packer.CLASS_ATTRIBUTE_PFX+"SourceFile",        Packer.STRIP);    
   // discard debug attributes.
+                p.put(Packer.DEFLATE_HINT,      Packer.TRUE);       // transmitting a single
request to use "compress" mode.
+                p.put(Packer.UNKNOWN_ATTRIBUTE, Packer.ERROR);      // throw an error if
an attribute is unrecognized.
+            }
+            for (final Artifact artifact : project.getDependencyArtifacts()) {
+                final String scope = artifact.getScope();
+                if (scope != null &&  // Maven 2.0.6 bug?
+                   (scope.equalsIgnoreCase(Artifact.SCOPE_COMPILE) ||
+                    scope.equalsIgnoreCase(Artifact.SCOPE_RUNTIME)))
+                {
+                    final File file = artifact.getFile();
+                    String name = file.getName();
+                    if (artifact.getGroupId().startsWith(prefixGroup) && !name.startsWith(prefix))
{
+                        name = prefix + name;
+                    }
+                    if (packer != null && name.endsWith(".jar")) {
+                        name = name.substring(0, name.length()-3) + "pack";
+                        try (JarFile jar = new FilteredJarFile(file)) {
+                            out.putNextEntry(new ZipEntry(name));
+                            packer.pack(jar, out);
+                            out.closeEntry();
+                        }
+                    } else {
+                        copy(file, out, name);
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * Copies the content of the specified binary file to the specified output stream.
+     *
+     * @param name The ZIP entry name, or {@code null} for using the name of the given file.
+     */
+    private static void copy(final File file, final ZipOutputStream out, String name) throws
IOException {
+        if (name == null) {
+            name = file.getName();
+        }
+        final ZipEntry entry = new ZipEntry(name);
+        if (name.endsWith(".png")) {
+            final long size = file.length();
+            entry.setMethod(ZipOutputStream.STORED);
+            entry.setSize(size);
+            entry.setCompressedSize(size);
+            entry.setCrc(getCRC32(file));
+        }
+        out.putNextEntry(entry);
+        try (InputStream in = new FileInputStream(file)) {
+            final byte[] buffer = new byte[4*1024];
+            int length;
+            while ((length = in.read(buffer)) >= 0) {
+                out.write(buffer, 0, length);
+            }
+        }
+        out.closeEntry();
+    }
+
+    /**
+     * Copies the content of the specified ASCII file to the specified output stream.
+     */
+    private void copyFiltered(final File file, final ZipOutputStream out, String name) throws
IOException {
+        if (name == null) {
+            name = file.getName();
+        }
+        final ZipEntry entry = new ZipEntry(name);
+        out.putNextEntry(entry);
+        final Writer writer = new OutputStreamWriter(out, ENCODING);
+        try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file),
ENCODING))) {
+            String line; while ((line=in.readLine()) != null) {
+                int r=-1; while ((r=line.indexOf(SUBSTITUTE, r+1)) >= 0) {
+                    line = line.substring(0, r) + finalName + line.substring(r + SUBSTITUTE.length());
+                }
+                writer.write(line);
+                writer.write('\n');
+            }
+        }
+        writer.flush();
+        out.closeEntry();
+    }
+
+    /**
+     * Computes CRC32 for the given file.
+     */
+    private static long getCRC32(final File file) throws IOException {
+        final CRC32 crc = new CRC32();
+        try (InputStream in = new FileInputStream(file)) {
+            final byte[] buffer = new byte[4*1024];
+            int length;
+            while ((length = in.read(buffer)) >= 0) {
+                crc.update(buffer, 0, length);
+            }
+        }
+        return crc.getValue();
+    }
+}

Propchange: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/UnoPkg.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/package-info.java?rev=1746859&view=auto
==============================================================================
--- sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/package-info.java
(added)
+++ sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/package-info.java
[UTF-8] Sun Jun  5 01:24:43 2016
@@ -0,0 +1,95 @@
+/*
+ * 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.
+ */
+
+
+/**
+ * Creates a {@code .oxt} file for <a href="http://www.openoffice.org">OpenOffice.org</a>
add-in.
+ * Those files are basically ZIP files with {@code META-INF/manifest.xml} and {@code .rdb}
entries.
+ * The principle is similar to Java JAR files.
+ *
+ * <p>This Maven plugin has be written for building the Apache SIS add-in for OpenOffice.org,
+ * but can also be used for other projects. See the Apache SIS add-in module for an example
+ * about how a module can be configured in order to use this Maven plugin.</p>
+ *
+ * <div class="section">Usage</div>
+ * Below is an example of {@code pom.xml} build configuration.
+ * The following strings need to be replaced:
+ *
+ * <ul>
+ *   <li>{@code com.myproject.Registration} —
+ *       The fully qualified class name of your class which contain the {@code __getServiceFactory(…)}
+ *       and {@code __writeRegistryServiceInfo(…)} public static methods.</li>
+ *   <li>{@code myAddinFilename} —
+ *       The final filename, without the {@code .oxt} extension.</li>
+ *   <li>{@code usePack200} (optional) —
+ *       Whether to use Pack200 compression rather than plain JAR files for all dependencies.
+ *       The default value is {@code false} (store plain old JAR files).</li>
+ * </ul>
+ *
+ * Note that if Pack200 files are generated, then it is implementor responsibility to unpack
them
+ * inside OpenOffice.org add-in directory during the {@code __writeRegistryServiceInfo} execution
phase.
+ *
+ * <div class="section">Maven project file</div>
+ * {@preformat xml
+ *   <dependencies>
+ *     <!-- Put all your project dependencies here, including transitive dependencies.
-->
+ *   </dependencies>
+ *
+ *   <build>
+ *     <plugins>
+ *       <!-- Add a manifest entry for add-ins registration in OpenOffice -->
+ *       <plugin>
+ *         <groupId>org.apache.maven.plugins</groupId>
+ *         <artifactId>maven-jar-plugin</artifactId>
+ *         <configuration>
+ *           <archive>
+ *             <manifestEntries>
+ *               <RegistrationClassName>
+ *                 com.myproject.Registration
+ *               </RegistrationClassName>
+ *             </manifestEntries>
+ *           </archive>
+ *         </configuration>
+ *       </plugin>
+ *
+ *       <!-- Create the oxt file. -->
+ *       <plugin>
+ *         <groupId>org.apache.sis.core</groupId>
+ *         <artifactId>sis-build-helper</artifactId>
+ *         <configuration>
+ *           <oxtName>myAddinFilename</oxtName>
+ *           <pack200>usePack200</pack200>
+ *         </configuration>
+ *         <executions>
+ *           <execution>
+ *             <goals>
+ *               <goal>javamaker</goal>
+ *               <goal>unopkg</goal>
+ *             </goals>
+ *           </execution>
+ *         </executions>
+ *       </plugin>
+ *     </plugins>
+ *   </build>
+ * }
+ *
+ * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @since   0.8
+ * @version 0.8
+ * @module
+ */
+package org.apache.sis.internal.unopkg;

Propchange: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/package-info.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: sis/branches/JDK8/core/sis-build-helper/src/main/java/org/apache/sis/internal/unopkg/package-info.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain;charset=UTF-8



Mime
View raw message