Maven - Assembly (Plugin)

1 - About

The assembly plugin will build assembly.

An “assembly” is a group of files, directories, and dependencies that are assembled into an archive format and distributed.

The plugin goals documentation can be found here.

3 - Pom.xml

The whole plugin is made through Descriptor Files.

3.1 - Descriptor Files

3.1.1 - Custom


<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <descriptors>
            <descriptor>src/main/assembly/myDescriptor.xml</descriptor>
          </descriptors>
        </configuration>
        [...]
</project>

Descriptor Reference

3.1.2 - Pre-defined

There is 4 Pre-defined Descriptor Files:

  • bin: to create a binary distribution archive of your project.
  • jar-with-dependencies: to create a JAR which contains the binary output of your project See shade
  • src: to create source archives for your project
  • project: produce an assembly containing the entire project, minus any build output that lands in the target directory.

Example in the pom.xml with the jar-with-dependencies (See the descriptorRefs element)


<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <!-- NOTE: We don't need a groupId specification because the group is
             org.apache.maven.plugins ...which is assumed by default.
         -->
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.4</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        [...]
</project>

4 - Documentation / Reference


Data Science
Data Analysis
Statistics
Data Science
Linear Algebra Mathematics
Trigonometry

Powered by ComboStrap