attach-source-javadoc |-- pom.xml |-- src\ `-- target `-- apache-maven-cookbook-1.0-SNAPSHOT-bin `-- apache-maven-cookbook-1.0-SNAPSHOT-bin.tar.bz2 `-- apache-maven-cookbook-1.0-SNAPSHOT-bin.tar.gz `-- apache-maven-cookbook-1.0-SNAPSHOT-bin.zip
To generate an assembly, we need to configure an assembly descriptor called bin.xml in the src/assembly directory. Firstly, we specify the wanted formats, i.e.
<formats> <format>tar.gz</format> <format>tar.bz2</format> <format>zip</format> </formats>
And the wanted files sets, i.e.
<fileSets> <fileSet> <includes> <include>README*</include> </includes> </fileSet> <fileSet> <directory>src/bin</directory> <outputDirectory>bin</outputDirectory> <includes> <include>*.bat</include> </includes> <lineEnding>dos</lineEnding> </fileSet> <fileSet> <directory>src/bin</directory> <outputDirectory>bin</outputDirectory> <includes> <include>hello</include> </includes> <lineEnding>unix</lineEnding> <fileMode>0755</fileMode> </fileSet> <fileSet> <directory>target</directory> <outputDirectory>lib</outputDirectory> <includes> <include>generate-assembly-*.jar</include> </includes> </fileSet> </fileSets>
We execute the assembly:single goal from the Assembly plugin during the package phase.
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptor>src/assembly/bin.xml</descriptor> <finalName>apache-maven-cookbook-${pom.version}</finalName> </configuration> <executions> <execution> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin>