This extends the Maven assembly plugin with additional examples to create an assembly by controlling what artifacts get included in the archive.
Example 1: dev-assembly.xml
The datasource and properties files are packaged for DEV environment.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <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>dev</id> <baseDirectory>/</baseDirectory> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <directory>${basedir}/src/config/dev/ds</directory> <outputDirectory>ds</outputDirectory> <includes> <include>*-ds.xml</include> <include>*-jboss-beans.xml</include> </includes> </fileSet> <fileSet> <directory>${basedir}/src/config/dev/app-properties</directory> <outputDirectory>app-properties</outputDirectory> <includes> <include>**/*</include> </includes> </fileSet> </fileSets> </assembly> |
Example 2: dev-assembly.xml
Control what maven dependency jars and class files are included in the archive.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <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>dev</id> <baseDirectory>/</baseDirectory> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <directory>src/main/resources</directory> <outputDirectory>conf</outputDirectory> </fileSet> <fileSet> <outputDirectory>/</outputDirectory> <directory>target/classes</directory> <includes> <include>com/**/replay/*.*</include> </includes> </fileSet> </fileSets> <dependencySets> <dependencySet> <includes> <include>org.springframework:spring-core:jar</include> </includes> <outputDirectory>lib</outputDirectory> </dependencySet> </dependencySets> </assembly> |
Example 2: dev-assembly.xml
to include all the jar dependencies in the pom.xml, but exclude some
1 2 3 4 5 6 7 8 9 10 11 | <dependencySets> <dependencySet> <excludes> <exclude>com.myapp.enabler:app-enabler-service:jar</exclude> <exclude>com.myapp.enabler:app-enabler-common:jar</exclude> <exclude>com.myapp.enabler:app-enabler-schema:jar</exclude> </excludes> <outputDirectory>lib</outputDirectory> </dependencySet> </dependencySets> |
Example 3
The power of includes and excludes. In this example, the whole spring libraries were included from the pom, and out of the inclusions some were excluded.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | <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>myapp-replay</id> <baseDirectory>/</baseDirectory> <formats> <format>zip</format> </formats> <fileSets> <fileSet> <directory>src/main/resources</directory> <outputDirectory>conf</outputDirectory> <includes> <include>context/myappReplayContext.xml</include> <include>certificates/*</include> <include>config/*</include> </includes> </fileSet> <fileSet> <outputDirectory>/</outputDirectory> <directory>target/classes</directory> <includes> <include>com/**/replay/*.*</include> <include>com/mycompany/wrap/myapp/enabler/ssl/*</include> <include>com/mycompany/wrap/myapp/enabler/ssl/client/*</include> </includes> </fileSet> </fileSets> <dependencySets> <dependencySet> <includes> <include>javax.inject:javax.inject:jar</include> <include>org.springframework:**:jar</include> <include>org.apache.httpcomponents:**:jar</include> <include>com.mycompany.wrap.config:wrap-config-certificates:jar</include> <include>org.slf4j:*:jar</include> <include>ch.qos.logback:*:jar</include> <include>cgilib:*:jar</include> <include>antlr:*:jar</include> <include>aopalliance:*:jar</include> <include>org.aspectj:*:jar</include> <include>com.google.guava:*:jar</include> <include>org.apache.commons:*:jar</include> </includes> <excludes> <exclude> org.springframework:spring-jdbc:jar</exclude> <exclude> org.springframework:spring-orm:jar</exclude> <exclude> org.springframework:spring-oxm:jar</exclude> <exclude> org.springframework:spring-tx:jar</exclude> </excludes> <outputDirectory>lib</outputDirectory> </dependencySet> </dependencySets> </assembly> |