Maven Assembly Submodules Multimodules

人盡茶涼 提交于 2019-12-11 02:27:55

问题


Hi I need to assembly jars from multimodule project in master directory. Let us have a structure like this:

MASTER(pom)
|
+-A3(pom)
| +-A1(jar)
| +-A2(jar)
+-B3(pom)
  +-B1(jar)
  +-B2(jar)

What I want to achieve is to assembly all jar packaged modules in MASTER.

jars/
+- A1.jar
+- A2.jar
+- B1.jar
+- B2.jar

For now I achieved only good resolution on submodules (A3 and B3) by creating pom.xml like:

<modules>
 <module>../A1</module>
 <module>../A2</module>
</modules>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
                    <configuration>
                        <descriptors>
                            <descriptor>src/main/assembly/bin.xml</descriptor>
                        </descriptors>
                    </configuration>
        </plugin>
    </plugins>
 </build>

and assembly descriptor:

<moduleSets>
  <moduleSet>
    <includes>
      <include>org.mycompany:A1</include>
      <include>org.mycompany:A2</include>
    </includes>
    <binaries>
      <includeDependencies>false</includeDependencies>
      <outputDirectory>jars/${artifactId}</outputDirectory>
      <unpack>false</unpack>
    </binaries>
  </moduleSet>
</moduleSets>

When I do

mvn clean package assembly:assembly

on submodules (A3 or B3) separately they seem to assembly their own submodules fine.

I don't know how to specify assembly descriptor in MASTER. The one similar to A3 and B3 descriptor does not deal with it ([ERROR] you must specify at least one file). I tried several additional tags like includeSubModules... still nothing.


回答1:


Resolution as promised (Master Assembly Descriptor):

<moduleSets>
 <moduleSet>
    <binaries>
        <includeDependencies>false</includeDependencies>
        <outputDirectory>jars/${artifactId}</outputDirectory>
        <unpack>false</unpack>
    </binaries>
 </moduleSet>
</moduleSets>

as you can see - no pointing to specific modules with <include> like in A3 and B3

<includes>
 <include> 
  (...) 
 </include>
</includes>

this is strange indeed. Nevertheless working.




回答2:


<module> just tells to add other poms in the reactor, but it doesn't provide any dependencies. So you cannot refer these modules anywhere, including assembly descriptors until you add dependencies.

If you want and build, and depend, you should add and <module> and <dependency>.



来源:https://stackoverflow.com/questions/9093520/maven-assembly-submodules-multimodules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!