Maven Assembly Plugin Example

Categories: Development Notes; Tagged with: ; @ April 27th, 2014 0:22

Requirement:

Generate a distributable archive.

Example:

/src/assemble/distribution.xml:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  <id>distribution</id>
  <formats>
    <format>zip</format>
  </formats>
  <files>
    <file>
      <source>/src/main/doc/install.txt</source>
      <outputDirectory>/docs</outputDirectory>
      <filtered>true</filtered>
    </file>
    <file>
        <source>/target/j2ee.war</source>
        <outputDirectory>/</outputDirectory>
    </file>
  </files>
  
   <fileSets>
    <fileSet>
      <directory>${basedir}/src/main/scripts</directory>
      <includes>
        <include>*.sh</include>
      </includes>
      <excludes>
        <exclude>README.txt</exclude>
        <exclude>NOTICE.txt</exclude>
      </excludes>
      <outputDirectory>/fileset</outputDirectory>
    </fileSet>
  </fileSets>
</assembly>

pom.xml:

<plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.4</version>
    <configuration>
      <!-- <filters>
        <filter>src/assemble/filter.properties</filter>
      </filters> -->
      <descriptors>
        <descriptor>src/assemble/distribution.xml</descriptor>
      </descriptors>
    </configuration>
  </plugin>

image



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.