Either I'm missing something obvious, or both the Maven book and the Maven Assembly Plugin's homepage, while describing how to write custom as开发者_开发技巧sembly 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?
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.
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...
精彩评论