This plugin uses TrueZIP which treats archives as a virtual file systems. Each archive file is considered as a directory of a file system.
Similar to assembly and clean plugins, FileSet is used extensively to manipulate file system type actions.
The following contains some brief examples on how to use the truezip goals.
The remove goal can remove files from an existing archive. The below example shows how to remove any pom.properties file under the META-INF/maven directory of the archive.
<build> [...] <plugins> [...] <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>truezip-maven-plugin</artifactId> <version>1.2</version> <executions> <execution> <id>remove-a-file</id> <goals> <goal>remove</goal> </goals> <phase>package</phase> <configuration> <fileset> <!-- note how the archive is treated as a normal file directory --> <directory>${archive}/META-INF/maven</directory> <includes> <include>**/pom.properties</include> </includes> </fileset> </configuration> </execution> [...] </executions> </plugin> [...] </plugins> </build> <properties> <archive>path.to.an.archive</archive> </properties>
The copy goal can copy files in and out of the archive. The below example shows multiple executions:
<build> [...] <plugins> [...] <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>truezip-maven-plugin</artifactId> <version>1.2</version> <executions> <execution> <id>copy-out-files</id> <goals> <goal>copy</goal> </goals> <phase>package</phase> <configuration> <files> <file> <source>${archive}/META-INF/maven/${project.groupId}/${project.artifactId}/pom.properties</source> <outputDirectory>${project.build.directory}/copy-file</outputDirectory> </file> <file> <source>${archive}/META-INF/maven/${project.groupId}/${project.artifactId}/pom.xml</source> <outputDirectory>${project.build.directory}/copy-file</outputDirectory> <destName>pom.with.xml.extension</destName> </file> </files> </configuration> </execution> <execution> <id>copy-out-fileset</id> <goals> <goal>copy</goal> </goals> <phase>package</phase> <configuration> <fileset> <directory>${archive}</directory> <excludes> <exclude>**/pom.properties</exclude> </excludes> <outputDirectory>${project.build.directory}/copy-fileset</outputDirectory> </fileset> </configuration> </execution> <execution> <id>copy-into</id> <goals> <goal>copy</goal> </goals> <phase>package</phase> <configuration> <fileset> <directory>${basedir}</directory> <includes> <include>*</include> </includes> <outputDirectory>${archive}/copy-into</outputDirectory> </fileset> </configuration> </execution> </plugin> [...] </plugins> </build> <properties> <archive>path.to.an.archive</archive> </properties>
Use cp goal to copy an archive/directory to another archive/directory.
mvn truezip:cp -Dfrom=apache-maven-2.2.1-bin.tar.gz -Dto=.
mvn truezip:cp -Dfrom=apache-maven-2.2.1 -Dto=apache-maven-2.2.1.zip
mvn truezip:cp -Dfrom=apache-maven-2.2.1-bin.tar.gz -Dto=apache-maven-2.2.1-bin.zip
The move goal can move a file in, out, or within the archive. The below examples show how to move an archive's file to another location in the archive. Note that the location can be outside of the archive as well.
<build> [...] <plugins> [...] <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>truezip-maven-plugin</artifactId> <version>1.2</version> <executions> <execution> <id>move-a-file</id> <goals> <goal>move</goal> </goals> <phase>package</phase> <configuration> <!-- move a archive file to another directory in the same archive --> <from>${archive}/META-INF/MANIFEST.MF</from> <to>${archive}/META-INF2/MANIFEST.MF</to> <!-- use this if you want to move it out of the archive --> <!--to>${project.build.directory}/MANIFEST.MF</to--> </configuration> </execution> [...] </executions> </plugin> [...] </plugins> </build> <properties> <archive>path.to.an.archive</archive> </properties>