Maven - Assembly (Plugin)

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.

Pom.xml

The whole plugin is made through Descriptor Files.

Descriptor Files

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

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>

Documentation / Reference


Powered by ComboStrap