Class UnoPkg

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.sis.internal.unopkg.UnoPkg
All Implemented Interfaces:
FilenameFilter, org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="unopkg", defaultPhase=PACKAGE, requiresDependencyResolution=COMPILE_PLUS_RUNTIME) public final class UnoPkg extends org.apache.maven.plugin.AbstractMojo implements FilenameFilter
Creates an .oxt package for OpenOffice.org addins.
Since:
0.8
Version:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    Base directory of the module to compile.
    private static final String
    The encoding for text files to read and write.
    private static final String
    The string to replace by the final name.
    private static final String
    The string to replace by the version number.
    private String
    In META-INF/manifest.xml, all occurrences of ${project.build.finalName} will be replaced by this value.
    private String
    Directory where the output .oxt file will be located.
    private String
    The name for the .oxt file to create, without the ".oxt" filename extension.
    private org.apache.maven.project.MavenProject
    The Maven project running this plugin.
    (package private) static final String
    The subdirectory (relative to baseDirectory) where the UNO files are expected.
    private static final String
    Module to decompress.
    private String
    In description.xml, all occurrences of ${project.version} will be replaced by this value.

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
    Invoked by reflection for creating the MOJO.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    accept(File directory, String name)
    Tests if a specified file should be included in a file list.
    private static void
    copy(File file, ZipOutputStream bundle)
    Copies the content of the specified binary file to the specified output stream.
    private void
    copyFiltered(File file, ZipOutputStream bundle, String name)
    Copies the content of the specified ASCII file to the specified output stream.
    private static void
    Copies a JAR file in the given ZIP file, but without compression for the files in SIS_DATA directory.
    void
    Generates the .oxt file from all .jar files found in the target directory.
    private static long
    getCRC32(File file)
    Computes CRC32 for the given file.

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SOURCE_DIRECTORY

      static final String SOURCE_DIRECTORY
      The subdirectory (relative to baseDirectory) where the UNO files are expected.
      See Also:
    • TO_INFLATE

      private static final String TO_INFLATE
      Module to decompress. We inflate the "sis-embedded-data" module because Derby is much slower when using an embedded database in a compressed ZIP file compared to flat storage. Since the JAR files are distributed in a ZIP file anyway, inflating that file has little impact on the final ZIP file size.
      See Also:
    • ENCODING

      private static final String ENCODING
      The encoding for text files to read and write.
      See Also:
    • FILTERED_NAME

      private static final String FILTERED_NAME
      The string to replace by the final name.
      See Also:
    • FILTERED_VERSION

      private static final String FILTERED_VERSION
      The string to replace by the version number.
      See Also:
    • baseDirectory

      @Parameter(property="basedir", required=true, readonly=true) private String baseDirectory
      Base directory of the module to compile. The UNO files are expected in the "src/main/unopkg" subdirectory. The plugin will look for the META-INF/manifest.xml and *.rdb files in that directory.
    • outputDirectory

      @Parameter(property="project.build.directory", required=true, readonly=true) private String outputDirectory
      Directory where the output .oxt file will be located.
    • finalName

      @Parameter(property="project.build.finalName", required=true, readonly=true) private String finalName
      In META-INF/manifest.xml, all occurrences of ${project.build.finalName} will be replaced by this value.
    • version

      @Parameter(property="project.version", required=true, readonly=true) private String version
      In description.xml, all occurrences of ${project.version} will be replaced by this value.
    • oxtName

      @Parameter(property="project.build.finalName", required=true, readonly=true) private String oxtName
      The name for the .oxt file to create, without the ".oxt" filename extension.
    • project

      @Parameter(property="project", required=true, readonly=true) private org.apache.maven.project.MavenProject project
      The Maven project running this plugin.
  • Constructor Details

    • UnoPkg

      public UnoPkg()
      Invoked by reflection for creating the MOJO.
  • Method Details

    • accept

      public boolean accept(File directory, String name)
      Tests if a specified file should be included in a file list.
      Specified by:
      accept in interface FilenameFilter
      Parameters:
      directory - the directory in which the file was found.
      name - the name of the file.
    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Generates the .oxt file from all .jar files found in the target directory.
      Specified by:
      execute in interface org.apache.maven.plugin.Mojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if the plugin execution failed.
    • copy

      private static void copy(File file, ZipOutputStream bundle) throws IOException
      Copies the content of the specified binary file to the specified output stream.
      Parameters:
      file - the regular file to copy inside the ZIP file.
      bundle - the ZIP file where to copy the given regular file.
      Throws:
      IOException
    • copyFiltered

      private void copyFiltered(File file, ZipOutputStream bundle, String name) throws IOException
      Copies the content of the specified ASCII file to the specified output stream.
      Parameters:
      file - the regular file to copy inside the ZIP file.
      bundle - the ZIP file where to copy the given regular file.
      name - the ZIP entry name.
      Throws:
      IOException
    • copyInflated

      private static void copyInflated(File file, ZipOutputStream bundle) throws IOException
      Copies a JAR file in the given ZIP file, but without compression for the files in SIS_DATA directory.
      Parameters:
      file - the JAR file to copy.
      bundle - destination where to copy the JAR file.
      Throws:
      IOException
    • getCRC32

      private static long getCRC32(File file) throws IOException
      Computes CRC32 for the given file.
      Throws:
      IOException