I’m using maven have used assembly plugins in my project to build the different artefact for Dev, SIT, UAT and Prod.
How can I use the Maven Assembly Plugin to create a ZIP archive that includes a specific folder and all of its files?
Now we’ve another project which holds properties files for all other projects as many teams uses that module to updated their piece of work and that creates discrepancies sometimes.
We’re looking to copy few required properties files from the external folder at the build time from that project and create zip out of it.
Any quick suggestions how can we do it?
zip-dev.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>zip</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/config/shared</directory>
<lineEnding>unix</lineEnding>
<fileMode>644</fileMode>
<outputDirectory>config</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/config/dev</directory>
<lineEnding>unix</lineEnding>
<fileMode>644</fileMode>
<outputDirectory>config</outputDirectory>
</fileSet>
</fileSets>
</assembly>
Normal zip.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>jar</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>${project.build.finalName}.jar</include>
</includes>
<outputDirectory/>
</fileSet>
</fileSets>
</assembly>
other details
<plugin>
.....
.....
.....
.....
.....
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>zip-main</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/zip.xml</descriptor>
</descriptors>
<finalName>ABC-${project.version}</finalName>
</configuration>
</execution>
<execution>
<id>zip-dev</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/assembly/zip-dev.xml</descriptor>
</descriptors>
<finalName>ABC-config-dev-${project.version}</finalName>
</configuration>
</execution>
</executions>
</plugin>