[
https://jira.codehaus.org/browse/MASSEMBLY-649?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=342273#comment-342273
]
Karl Heinz Marbaise commented on MASSEMBLY-649:
-----------------------------------------------
With maven-assembly-plugin:2.4 this can be solved simpler with the following
descriptor (which is not perfect and can be improved):
{code}
<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>sources</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<excludes>
<exclude>*:webgui:war:*</exclude>
<exclude>*:app:ear:*</exclude>
<exclude>*:service:ejb:*</exclude>
<exclude>*:shade:jar:*</exclude>
</excludes>
<binaries>
<includeDependencies>false</includeDependencies>
<attachmentClassifier>sources</attachmentClassifier>
<outputDirectory>sources</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
</assembly>
{code}
Unfortunately you have to define exclude rules for those modules which don't
have attached sources packages. But no need to go via fileSet.
> Assembly descriptor needs <sourceBinaries> (or similar) to go with <binaries>
> and <sources>
> -------------------------------------------------------------------------------------------
>
> Key: MASSEMBLY-649
> URL: https://jira.codehaus.org/browse/MASSEMBLY-649
> Project: Maven Assembly Plugin
> Issue Type: Improvement
> Reporter: Nicholas Williams
>
> Consider the following project structure:
> {noformat}
> - parent
> - pom.xml
> - assembly
> - pom.xml
> - module1
> - pom.xml
> - module2
> - pom.xml
> - module3
> - pom.xml
> {noformat}
> As recommended
> [here|http://maven.apache.org/plugins/maven-assembly-plugin/faq.html#module-binaries],
> the "assembly" sub-project exists to run the assembly plugin during package
> phase and depends on module1, module2, and module3 to achieve this.
> Using {{<moduleSet>/<binaries>}} I can include all of the compiled binaries
> from module1, module2, and module3 in the assembly. Using
> {{<moduleSet>/<sources>}} I can likewise include all of the sources, but the
> problem is that {{<sources>}} actually includes the entire source directories
> including POM and project files for each module, which is not always desired.
> Modules 1-3 in this case use the maven-source-plugin to create source
> binaries ([artifactId]-[version]-sources.jar). I want to include those source
> JARs in the assembly. However, I cannot do this with {{<moduleSet>}} or with
> {{<dependencySet>}}. I have to add a {{<fileSet>}} for each module's lone
> source JAR, like so:
> {code:xml}
> <fileSet>
> <directory>../module1/target</directory>
> <includes><include>*-sources.jar</include></includes>
> <outputDirectory>/sources</outputDirectory>
> </fileSet>
> <fileSet>
> <directory>../module2/target</directory>
> <includes><include>*-sources.jar</include></includes>
> <outputDirectory>/sources</outputDirectory>
> </fileSet>
> <fileSet>
> <directory>../module3/target</directory>
> <includes><include>*-sources.jar</include></includes>
> <outputDirectory>/sources</outputDirectory>
> </fileSet>
> {code}
> This gets tedious with many modules (and really shouldn't be necessary). We
> either need a {{<sourceBinaries>}} option that works similarly to
> {{<binaries>}} except on source JARs, or {{<binaries>}} needs to be changed
> to optionally support source JARs.
--
This message was sent by Atlassian JIRA
(v6.1.6#6162)