Either I'm missing something obvious, or both the Maven book and the Maven Assembly Plugin's homepage, while describing how to write custom assembly descriptors, don't say anything about where that file has to go. Is it part of my project? Does it go into some central Maven configuration directory? Do I have to specify its location somewhere?
2 Answers
Yes, you have to specify the location. According to the Configuration and Usage page, this is done this way:
<project> [...] <build> [...] <plugins> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptors> <descriptor>src/main/assembly/src.xml</descriptor> </descriptors> </configuration> [...] </project>
Actually, I'd recommend using src/main/assembly
as location.

- 562,542
- 136
- 1,062
- 1,124
-
3Thanks, also for the link pointing to that documentation page. I managed to figure it out around the same time you posted, but I think it's very confusing that this information is not right there where you look up how to write assembly descriptors. – Hanno Fietz Oct 15 '09 at 13:09
-
Doesn't work. See http://stackoverflow.com/questions/2463721/maven-assembly-error-reading-assemblies/2464350#2464350 – Ondra Žižka Jul 10 '13 at 21:35
-
3Maven is totally clear where assembly descriptors should be placed (not src/main/* src/assembly instead - https://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html) but you can place it whereever you want. Placing it under src/main is misleading IMHO. – BlackEye Jan 15 '19 at 09:06
In a somewhat roundabout way, I was eventually able to find out. First, this page about sharing assembly descriptors indirectly gives you some hints.
My first mistake was to use descriptorRef
instead of descriptor
in my plugin configuration. When I fixed that, and created the directory structure shown on the page linked above, I got a series of error messages that revealed how the plugin tries to resolve the descriptor name you gave it:
[INFO] Searching for file location: /path/to/project/dependency-collection.xml
[INFO] File: /path/to/project/dependency-collection.xml does not exist.
So, putting it in the project's root should work...
[INFO] Invalid artifact specification: 'dependency-collection.xml'. Must contain at least three fields, separated by ':'.
... or loading it from a Maven artifact ...
[INFO] Failed to resolve classpath resource: /assemblies/dependency-collection.xml from classloader: ClassRealm[/plugins/org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-2@48/thread:main, parent: ClassRealm[plexus.core, parent: null]]
[INFO] Failed to resolve classpath resource: dependency-collection.xml from classloader: ClassRealm[/plugins/org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-2@48/thread:main, parent: ClassRealm[plexus.core, parent: null]]
... or putting it on the classpath of the plugin (I guess that's where the predefined descriptors are) ...
[INFO] Building URL from location: dependency-collection.xml
Error: java.net.MalformedURLException: no protocol: dependency-collection.xml
... or load it from a URL.
Nice, but this really should be documented somewhere, I think. I just put the descriptor file next to th epom.xml and it worked. I probably could've tried that before searching the web...

- 30,799
- 47
- 148
- 234