I have a project which builds a war (no problem). And, that war needs to be packaged with a few shell scripts. Because that war contains properties files that vary from site-to-site, we can't simply install the war as is, but munge the properties files in it. That's what the shell scripts do.
I'd like to package my war in my assembly as a unpacked war. I see <unpacked>
in the Assembly Descriptor, but I haven't been able to get that to work.
Here's my first bin.xml
where I just packed the war as is. This works fine:
<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>bin</id> <formats> <format>zip</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> <fileSet> <directory>${project.basedir}/src/assembly/scripts</directory> <includes> <include>deploy.sh</include> <include>lock_build.sh</include> <include>description.sh</include> <include>url-encode.pl</include> </includes> <outputDirectory>/</outputDirectory> </fileSet> <fileSet> <directory>${project.build.directory}/${project.artifactId}-${project.version}</directory> <outputDirectory>${project.artifactId}</outputDirectory> </fileSet> </fileSets> </assembly>
Here's my first attempt at unpacked:
<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>bin</id> <formats> <format>zip</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> <fileSet> <directory>${project.basedir}/src/assembly/scripts</directory> <includes> <include>deploy.sh</include> <include>lock_build.sh</include> <include>description.sh</include> <include>url-encode.pl</include> </includes> <outputDirectory>/</outputDirectory> </fileSet> </fileSets> <moduleSets> <moduleSet> <includes> <include>{$project.groupId}:${project.artifactId}:war</include> </includes> <binaries> <includes> <include>${project.build.directory}-${project.artifactId}-${project.version}.${project.packaging}</include> </includes> <outputDirectory>${project.artifactId}</outputDirectory> <unpack>true</unpack> </binaries> </moduleSet> </moduleSets> </assembly>
Here's my last try at getting the unpacked war:
<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>bin</id> <formats> <format>zip</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> <fileSet> <directory>${project.basedir}/src/assembly/scripts</directory> <includes> <include>deploy.sh</include> <include>lock_build.sh</include> <include>description.sh</include> <include>url-encode.pl</include> </includes> <outputDirectory>/</outputDirectory> </fileSet> </fileSets> <moduleSets> <moduleSet> <binaries> <attachmentClassifier>war</attachmentClassifier> <outputDirectory>${project.artifactId}</outputDirectory> <unpack>true</unpack> <includeDependencies>true</includeDependencies> <dependencySets> <dependencySet/> </dependencySets> </binaries> </moduleSet> </moduleSets> </assembly>
In each of these last two attempts, I am only packaging the scripts and the war isn't coming over.
I know I could use the ${project.build.directory}/${project.artifactId}-${project.version}
directory which contains almost all of the files in the war, but it doesn't contain my MANIFEST.MF
entries which includes information linking the war back to a particular Jenkins build and Subversion revision.
What do I need to do to include an unpacked war into my assembly?
Another Attempt
<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>bin</id> <formats> <format>zip</format> </formats> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> <fileSet> <directory>${project.basedir}/src/assembly/scripts</directory> <includes> <include>deploy.sh</include> <include>lock_build.sh</include> <include>description.sh</include> <include>url-encode.pl</include> </includes> <outputDirectory>/</outputDirectory> </fileSet> </fileSets> <dependencySets> <dependencySet> <outputDirectory>${project.artifactId}</outputDirectory> <unpack>true</unpack> <scope>runtime</scope> </dependencySet> </dependencySets> </assembly>
When I ran this, I got:
[INFO] ------------------------------------------------------------------------ [INFO] Building My Project 1.0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-assembly-plugin:2.5.2:single (default-cli) @ myproj --- [INFO] Reading assembly descriptor: src/assembly/bin.xml [WARNING] Cannot include project artifact: \ com.vegicorp:myproj:war:1.0.0; \ it doesn't have an associated file or directory. [INFO] Building zip: ~/workdir/trunk/myproj/target/archive/myproj.zip [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------
Inside the zip are all the jars in the war nice and unpacked, but not my unpacked war.