Class Assembler

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

@Mojo(name="dist", defaultPhase=INSTALL, requiresDependencyResolution=COMPILE_PLUS_RUNTIME) public final class Assembler extends org.apache.maven.plugin.AbstractMojo implements FilenameFilter
Creates a ZIP file containing the Apache SIS binary distribution. The created file contains:
  • the content of the application/sis-javafx/src/main/artifact directory;
  • the JAR files of all modules and their dependencies, without their native resources;
  • the native resources in a separated lib/ directory.
This MOJO can be invoked from the command line in the sis-javafx module as below:
mvn package org.apache.sis.core:sis-build-helper:dist

Limitation

The current implementation uses some hard-coded paths and filenames. See the Distribution file section in Build from source page for more information.

Since:
0.4
Version:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    Base directory of the module to compile.
    private org.apache.maven.project.MavenProject
    Project information (name, version, URL).
    private String
    The root directory (without the "target/binaries" sub-directory) where JARs are to be copied.

    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 filename)
    The filter to use for selecting the files to be included in the ZIP file.
    private void
    appendJAR(File file, org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream bundle, Map<String,byte[]> nativeFiles)
    Copies a JAR file in the given ZIP file, except the native resources which are stored in the given map.
    private void
    appendRecursively(File file, String relativeFile, org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream out)
    Adds the given file in the ZIP file.
    void
    Creates the distribution file.
    private static Set<File>
    files(org.apache.maven.project.MavenProject project)
    Returns all files to include for the given Maven project.
    private static boolean
    Returns true if the given JAR file contains at least one resource in the "native/" directory.

    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

    • project

      @Parameter(property="project", required=true, readonly=true) private org.apache.maven.project.MavenProject project
      Project information (name, version, URL).
    • baseDirectory

      @Parameter(property="basedir", required=true, readonly=true) private String baseDirectory
      Base directory of the module to compile. Artifact content is expected in the "src/main/artifact" subdirectory.
    • rootDirectory

      @Parameter(property="session.executionRootDirectory", required=true) private String rootDirectory
      The root directory (without the "target/binaries" sub-directory) where JARs are to be copied. It should be the directory of the root pom.xml.
  • Constructor Details

    • Assembler

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

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException
      Creates the distribution file.
      Specified by:
      execute in interface org.apache.maven.plugin.Mojo
      Throws:
      org.apache.maven.plugin.MojoExecutionException - if the plugin execution failed.
    • files

      private static Set<File> files(org.apache.maven.project.MavenProject project) throws org.apache.maven.plugin.MojoExecutionException
      Returns all files to include for the given Maven project.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • appendRecursively

      private void appendRecursively(File file, String relativeFile, org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream out) throws IOException
      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-javafx/src/main/artifact" directory and sub-directories before to zip.
      Throws:
      IOException
    • accept

      public boolean accept(File directory, String filename)
      The filter to use for selecting the files to be included in the ZIP file.
      Specified by:
      accept in interface FilenameFilter
      Parameters:
      directory - the directory.
      filename - the filename.
      Returns:
      true if the given file should be included in the ZIP file.
    • hasNativeResources

      private static boolean hasNativeResources(ZipFile in)
      Returns true if the given JAR file contains at least one resource in the "native/" directory. Those files will need to be rewritten in order to exclude those resources.
    • appendJAR

      private void appendJAR(File file, org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream bundle, Map<String,byte[]> nativeFiles) throws IOException
      Copies a JAR file in the given ZIP file, except the native resources which are stored in the given map.
      Parameters:
      file - the JAR file to copy.
      bundle - destination where to copy the JAR file.
      nativeFiles - where to store the native resources.
      Throws:
      IOException