If you have some resources (xml files, properties files etc) that contains project properties to be substituted before generating the zip package of those resources. Probably Maven is pretty helpful to create it. For example you have some paths of DTD schema in your xml files that you need to resolve before generating the deployable resource package.
You need to use Maven Assembly plugin to generate a zip file. You have to create an assembly descriptor file that you will include in your POM file.
The assembly descriptor will look like. you can save it as (zip-descriptor.xml)
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd " >
<includeBaseDirectory >false </includeBaseDirectory >
<formats >
<format >zip </format >
</formats >
<fileSets >
<fileSet >
<directory >directory-name </directory >
<outputDirectory > </outputDirectory >
<filtered >true </filtered >
</fileSet >
</fileSets >
</assembly >
your POM file will look like. (POM.xml)
<project xmlns="http://maven.apache.org/POM/4.0.0 " xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd " >
<modelVersion >4.0.0 </modelVersion >
<groupId >iceland-picking </groupId >
<artifactId >iceland-picking </artifactId >
<version >0.0.1-SNAPSHOT </version >
<packaging >pom </packaging >
<name >iceland-picking </name >
<prerequisites >
<maven >2.2.0 </maven >
</prerequisites >
<properties >
<product.codename >codename </product.codename >
<product.name >product name </product.name >
<product.version >${project.version} </product.version >
<model.codename >${product.codename} </model.codename >
<model.name >${product.name } </model.name >
<model.version >${project.version} </model.version >
<metabase.version >1 </metabase.version >
<database.version >1 </database.version >
</properties >
<build >
<plugins >
<plugin >
<groupId >org.apache.maven.plugins </groupId >
<artifactId >maven-assembly-plugin </artifactId >
<configuration >
<descriptors >
<descriptor >zip-descriptor.xml </descriptor >
</descriptors >
<finalName >this will be the name of the output zip file </finalName >
<appendAssemblyId >false </appendAssemblyId >
</configuration >
<executions >
<execution >
<id >make-assembly </id >
<phase >package </phase >
<goals >
<goal >single </goal >
</goals >
</execution >
</executions >
</plugin >
</plugins >
</build >
</project >
For more details please visit the following Maven link:
1) http://maven.apache.org/guides/mini/guide-assemblies.html
2) http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html
1 comment:
Thanks for this post. It was exactly what I needed for creating a zip that contains a bunch of scripts. No filtering needed so I set that to false.
Thanks!
Post a Comment