Speeding up maven assembly of multiple modules - maven

I'm having a project of the following form
- pom.xml
- projectA
- pom.xml
- src/main/
- java
- startupScript
- projectB
- pom.xml
- src/main/
- java
- startupScript
- projectAssembly
- pom.xml
I want projectAssembly to produce a tar.gz that would contain two folders one for projectA and one for projectB, in each folder, there would be project's dependencies and the startupScript library.
The "naive" way to do that is to add assembly.xml file to each project, a file which roughly looks like:
<assembly>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/${project.artifactId}</baseDirectory>
<fileSets>
<fileSet>
<directory>${basedir}/src/main/startupScripts</directory>
<outputDirectory>/startupScripts</outputDirectory>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>
Then, in the projectAssembly, depend on <type>tar.gz</type> of both projectA and projectB, and add an assembly file which roughly looks like
<assembly>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>true</unpack>
</dependencySet>
</dependencySets>
</assembly>
This works, however, I do not need the intermediate tar.gz of projects A and B, and producing them, especially if they have a lot of dependencies, takes a long time.
How can I tell maven to directly assembly only the tar.gz of projectAssembly without wasting times on packing and unpacking intermediate archives?

Your assembly descriptor in the projectAssembly needs to look something like this (See comments inside):
<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>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<!-- Enable access to all projects in the current multimodule build! -->
<useAllReactorProjects>true</useAllReactorProjects>
<!-- Now, select which projects to include in this module-set. -->
<includes>
<include>*:projectA</include>
<include>*:projectB</include>
</includes>
<!-- Select and map resources from each module -->
<sources>
<includeModuleDirectory>false</includeModuleDirectory>
<fileSets>
<fileSet>
<directory>src/main/startupScript</directory>
<outputDirectory>${module.artifactId}/startupScript</outputDirectory>
</fileSet>
</fileSets>
</sources>
<!-- Select and map dependencies from each module -->
<binaries>
<dependencySets>
<dependencySet>
<outputDirectory>${module.artifactId}/lib</outputDirectory>
</dependencySet>
</dependencySets>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
I believe that would be what you need. If not let us know..

Related

Maven assembly plugin: include file without taking its path folders

I'm using maven-assembly-plugin to include files from a dependency ZIP (also generated with assembly plugin) into a final release ZIP file.
The issue is that I want to select which files from the dependency to get, but not copying the folder path where those files are. Just the files.
For example:
<assembly>
<formats>
<format>zip</format>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<includes>
<include>package:artifactId:zip:*</include>
</includes>
<outputDirectory>sql/update/01.00.00_to_01.01.00</outputDirectory>
<unpack>true</unpack>
<unpackOptions>
<includes>
<include>oracle/update/1_alter_schema.sql</include>
<include>oracle/update/2_insert_data.sql</include>
</includes>
</unpackOptions>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveDependencies>false</useTransitiveDependencies>
</dependencySet>
</dependencySet>
</assembly>
This copies the required files like this:
sql/update/01.00.00_to_01.01.00/oracle/update/1_alter_schema.sql
sql/update/01.00.00_to_01.01.00/oracle/update/2_insert_data.sql
I would like to copy just the files without the original oracle/update/ folder, resulting in this folder structure:
sql/update/01.00.00_to_01.01.00/1_alter_schema.sql
sql/update/01.00.00_to_01.01.00/2_insert_data.sql
The dependency ZIP contains many files used by different projects, therefore the structure to differentiate oracle from sql-server files makes sense there, but for this distribution I don't need those folders, just the files.
Does somebody knows if this is possible with maven-assembly-plugin?
Many thanks in advance!
From the documentation of maven-assembly-plugin (maven-assembly-plugin) I can see that the <fileSets> tag does not provide us with the option of changing the path of an included resource. Instead we can use the <file> tag which gives us this flexibility.
For example, the below configuration will include file1.jar and run.bat in the root folder of the extracted zip file, skipping their original paths.
<assembly>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>target/file1.jar</source>
<destName>file1.jar</destName>
</file>
<file>
<source>src/main/resources/run.bat</source>
<destName>run.bat</destName>
</file>
</files>
</assembly>
It should work by splitting the dependency unzipping and the file assembly.
Configure the dependency-plugin to unpack the desired dependency before performing the assembly work:
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<includeArtifactIds>project-sql</includeArtifactIds>
<outputDirectory>${project.build.directory}/extract</outputDirectory>
<includes>oracle/update/1_alter_schema.sql,oracle/update/2_insert_data.sql</includes>
</configuration>
<executions>
<execution>
<id>unpack-sql</id>
<phase>prepare-package</phase>
<goals><goal>unpack-dependencies</goal></goals>
</execution>
</executions>
</plugin>
Then, in your assembly-distribution.xml, just assemble from the sub-directory:
<?xml version="1.0" encoding="UTF-8"?>
<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>distribution-${project.version}</id>
<formats>
<format>zip</format>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}/extract/oracle/update</directory>
<outputDirectory>sql/update/01.00.00_to_01.01.00</outputDirectory>
</fileSet>
</fileSets>
</assembly>
I had the same problem, using dependencies plugin dumped a lot of other files, which I am sure it can be improved. But I think I found a simpler and better solution.
All you need to do is add another <fileSet>. The fileSet has the relative source path and an output directory. The value of your outputDirectory determines the path in the resulting zip. It is as simple as that. Hope this helps someone out there, fighting with producing lambda zips for AWS (rolling my eyes)
Here is my assembly.xml BEFORE(HAS PROBLEM) that I was struggling with:
<assembly>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory></directory>
<outputDirectory/>
<includes>
<include>lib/**.*</include>
<include>${basedir}/target/classes/com/abc/test.LambdaTest.*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
The above produces zip with directory target, but here is an improved and FIXED (CORRECT) which does not have the path "target" in zip.
<assembly>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory></directory>
<outputDirectory/>
<includes>
<include>lib/**.*</include>
</includes>
</fileSet>
<fileSet>
<directory>${basedir}/target/classes</directory>
<outputDirectory/>
<includes>
<include>com/abc/test.LambdaTest.*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
Pay attention to the value of <directory> in both fileSets, which provides a relative path which is not used to when files are added to the zip

Maven: add non-JAR dependency

I'am using the maven-assembly-plugin to create a tar.gz archive. Now I need to include files in that archive. These are just a bunch of plain old text files and are a dependency at runtime, not at compile or (unit) test time.
I thought about adding a maven dependency on that but these files are not stored in a maven repository but in a simple remove folder. To make it even worse, this folder is password protected. I could, in a pre-build-step, download these password-protected files into a local folder. But then there is still the problem of using those files in the assembly. Also, this is extra work I want to avoid.
Is there any way to do that?
If you can download those files, workaround password. Maybe this will help.
Create mod assembly project where you put something like that:
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>${artifact.version}</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<useProjectArtifact>false</useProjectArtifact>
<useTransitiveDependencies>true</useTransitiveDependencies>
<unpack>false</unpack>
<excludes>
<exclude>${project.groupId}:*:*</exclude>
</excludes>
<outputFileNameMapping>project${timestamp}_code-${artifact.name}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<includes>
<include>readme.txt</include> <!-- here's that plain file -->
</includes>
</fileSet>
</fileSets>
You can include those files in fileSets.
http://maven.apache.org/plugins/maven-assembly-plugin/examples/single/filtering-some-distribution-files.html for more info

maven-assembly-plugin include *.properties at root level of zip

I'm trying to get maven to include my *.properties files when it zips up my artifacts. They are located inside src/main/resources. I tried adding the fileSet element to my assembly file, but the resources are not being included in the zip. I saw this question which seems to indicate that adding fileSet should work.
plugins.xml:
<?xml version="1.0"?>
<assembly>
<id>release</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.properties</include>
</includes>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>/</outputDirectory>
<useProjectArtifact>true</useProjectArtifact>
<useTransitiveFiltering>true</useTransitiveFiltering>
</dependencySet>
</dependencySets>
</assembly>
The properties that you want to include inside your ZIP are located in the src/main/resources source directory of your project. So the <fileSet> element should point to this directory.
${project.build.directory} is Maven current build directory, which is by default target. You could also point to the temporary directory where Maven copies all resources during the build but it is preferable to stick with the permanent data where possible.
As such, you just need to change your <fileSet> element with:
<directory>src/main/resources</directory>

Including an unpacked War in the Assembly

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.
I know I should be able to add the unpacked war into my assembly. I see that unpack option, and I know it works for other dependencies. However, it looks like I can only access it via a <dependencySet> or a <moduleSet>. I should be able to specify my project as its own module. There must be something I am doing wrong.
Spleen Vent
This is the big thing I hate about Maven: Maven does a great job hiding things from you which is nice because it prevents you from doing stuff you shouldn't. I hate it when developers build Ant build.xml files because most developers don't understand how to do a build, and the build.xml becomes an unreadable mess. With Maven, this isn't an issue. Just configure your project, and Maven will take care of this for you.
But sometimes Maven is like a black box with a bunch of levers and buttons. You sit there pushing and pulling levers and buttons trying to figure out how to get it to do something you want to do. I spend way too much of my time trying to help developers to configure their Maven projects. They want to do something a little different like use hibernate or build source from WSDL files, and have no idea how to get Maven to do what they want.
One developer describes it as a self driving car which can't quite go where you want. You may even see the destination out the window, but you can't figure out how to manipulate the car's destination to get you there.
What I want to do should be easy. I just want to create an assembly, and instead of using the packed war file, I want it unpacked.
In Ant, this can be accomplished in a single task. In Maven, it's a mysterious process. I think I'm close, I am probably missing one little configuration parameter that will make it all work, but I've already spent hours working on this.
What I ended up doing
I used the maven-dependency-plugin to unpack my war. I wasn't sure whether this would work because I didn't want the dependency plugin downloading the war, but it seems to understand that when I specify my war, I am talking about the current build, and nothing is downloaded. (I don't even have the war in our Maven repo).
I also had to upgrade Maven from 2.x to 3.x because I need to make sure that the maven-dependency-plugin ran before the maven-assembly-plugin. Since both run in the packaging phase of the build, Maven 2.x can't guarantee the order the plugins run in.
Once I used that plugin, all I had to do was specify the directory where I unpacked the war in my assembly plugin, and it was included in my zip.
I still want to know how to use the <unpack> entity in the assembly plugin itself instead of having to use another plugin to unpack my war. If anyone can tell me how to do the unpack in the assembly file itself, I'll mark that as the correct answer.
pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.9</version>
<executions>
<execution>
<id>unpack</id>
<phase>package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/unwar/${project.artifactId}</outputDirectory>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
<type>war</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<finalName>${project.artifactId}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<outputDirectory>${project.build.directory}/archive</outputDirectory>
<descriptors>
<descriptor>src/assembly/bin.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
bin.xml (My Assembly)
<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>
<fileMode>0755</fileMode>
<lineEnding>lf</lineEnding>
<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}/unwar</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
The ACTUAL Answer
Thanks to khmarbaise's link (see the comment below), I copied that project's assembly plugin and it almost worked. Like my attempt, it unpacked all the runtime jars, and not just the one I wanted. However, it also unpacked my war too.
There were only two differences between that link's answer and my attempt:
They included <useProjectArtifact>true</useProjectArtifact> and I didn't. However, this defaults to true. Removing it still allowed it to work.
They included a / in front of the directory name in the <outputDirectory>. Removing this made no difference.
This meant that it now matched what I had previously tried. So, why was it working this time.
Turns out, I was testing the assembly changes by simply running mvn assembly:single. After all, why do the whole build and repackage when I am simply trying to get the assembly to work. When you run just mvn assembly:single -- even though everything is already packaged, you get this error:
[WARNING] Cannot include project artifact: \
com.vegicorp:myproj:war:1.0.0; \
it doesn't have an associated file or directory.
And your war isn't unpacked. However, if you put the assembly into the package phase, and then run mvn package, everything works out just nifty.
I then spent time trying to just get my war and not all the associated runtime stuff with it. I used <includes/> to do this, but because I have a war and not a jar, I had to include a classifier in my <include>.
At last, I have everything working. I have this in my assembly:
<dependencySets>
<dependencySet>
<outputDirectory>${project.artifactId}</outputDirectory>
<unpack>true</unpack>
<scope>runtime</scope>
<includes>
<include>${project.groupId}:${project.artifactId}:*:${project.version}</include>
</includes>
</dependencySet>
</dependencySets>
And as long as I run mvn package, it works.
This is way better than what I had with the maven-dependency-plugin. Now, all of the information having to do with the assembly is in the assembly XML file.

Exclude 3rd party dependency from target single jar in maven assembly

I am using maven-assembly-plugin to make a single jar from maven modules.
Here is the assembly.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">
<id>all-jar</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<unpack>true</unpack>
<useTransitiveDependencies>false</useTransitiveDependencies>
<unpackOptions>
<excludes>
<exclude>**/resources</exclude>
<exclude>xsom:xsom</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>
I am using a 3rd part jar in one of my modules. Although i put in the exclude list, this third party jar is also unpacked and isnt excluded. How can i exclude it from unpacking? In fact i only want the resource folders of the modules to be unpacked , other java sources could be stay packed.
You need to put the exclude tag outside of unpack options:
<dependencySets>
<dependencySet>
<unpack>true</unpack>
<useTransitiveDependencies>false</useTransitiveDependencies>
<excludes>
<exclude>xsom:xsom</exclude>
</excludes>
<unpackOptions>
<excludes>
<exclude>**/resources</exclude>
</excludes>
</unpackOptions>
</dependencySet>
</dependencySets>
If you use exclude inside unpackOptions, you exclude contents from being unpacked.

Resources