maven-assembly plugin - how to create nested assemblies

Viewed 12576

I have a project whereby I'm trying to create a distribution zip file, which contains (amongst other files) an executable jar with dependencies of my java project.

So I sort of want it to look like this:

-wiki-search-1.0.0-dist.zip
    -wiki-search.bat
    -wiki-search-help.html
    -wiki-search-1.0.0-jar-with-dependencies.jar
        -jar content...

I'm using the assembly plugin, and the predefined descriptor "jar-with-dependencies" to create my executable jar file.

I'm specifying a separate assembly plugin entry in my pom, referencing a custom descriptor to try and build the distributable zip file.

So the part of my pom looks like this:

<plugin>
 <artifactId>maven-assembly-plugin</artifactId>
 <configuration>
  <descriptorRefs>
   <descriptorRef>jar-with-dependencies</descriptorRef>
  </descriptorRefs>
  <archive>
   <manifest>
    <mainClass>quicksearch.QuickSearchApp</mainClass>
   </manifest>
  </archive>
 </configuration>
 <executions>
  <execution>
   <id>make-assembly</id>
   <phase>package</phase>
   <goals>
    <goal>attached</goal>
   </goals>
  </execution>
 </executions>
</plugin>
<plugin>
 <artifactId>maven-assembly-plugin</artifactId>
 <configuration>
  <descriptors>
   <descriptor>src/main/assembly/dist.xml</descriptor>
  </descriptors>
 </configuration>
 <executions>
  <execution>
   <id>make-assembly</id>
   <phase>package</phase>
   <goals>
    <goal>attached</goal>
   </goals>
  </execution>
 </executions>
</plugin>

And my custom descriptor looks like this:

<assembly>
  <id>dist</id>
  <formats>
    <format>tar.gz</format>
    <format>tar.bz2</format>
    <format>zip</format>
  </formats>
  <fileSets>
    <fileSet>
      <includes>
        <include>${project.basedir}/target/wiki-search-0.0.1-SNAPSHOT-jar-with-dependencies.jar</include>
      </includes>
      <outputDirectory>.</outputDirectory> 
    </fileSet>
    <fileSet>
      <directory>${project.basedir}/src/main/etc</directory>
      <includes>
        <include>*</include>
      </includes>
     <outputDirectory></outputDirectory> 
    </fileSet>
  </fileSets>
</assembly>

Everything works fine. The jar-with-dependencies is being built. My dist zip file is being built. But the dist zip file does not contain the jar-with-dependencies file.

2 Answers
Related