0

基本上我有一个具有这种结构和依赖关系的多模块项目

pom - With dependencies with scope provided
  + ---- mod1 - with mod1 dependencies
          + -----  depends on libAAA
          + ------ depends on libBBB
  + ---- mod2 - with mod2 dependencies
          + -----  depends on libXXX
          + ------ depends on libYYY

组装(使用 maven-assembly-plugin)预计如下所示:

bin/lib      - Contains all provided dependencies
bin/mod1/    - Contains mod1 artifact
bin/mod1/lib - Contains mod1 dependencies (only mod1) 
bin/mod2/    - Contains mod2 artifact
bin/mod2/lib - Contains mod2 dependencies (only mod2) 

一切都“几乎”按预期工作,但所有项目依赖项都被复制到 mod1/lib 和 mod2/lib,因此生成的程序集看起来像这样

bin/mod1/lib
bin/mod2/lib
   BOTH containing libAAA, libBBB, libXXX, libYYY

我期望得到的是:

bin/mod1/lib
    containing libAAA, libBBB
bin/mod2/lib
    containing libXXX, libYYY

有人知道是否可以在不使用过滤器的情况下在每个目录上复制“隔离”(不确定使用什么词)模块依赖项?

在此先感谢,托尼奥

4

1 回答 1

0

我正在添加程序集描述符。

这个描述符设置在一个称为分发的“pom”模块中,如多模块项目的 maven-assembly-plugin 文档中所述。

我尝试生成 2 个 moduleSet 而不是一个,每个模块一个,结果与上述相同。

下面是 XML 和 pom 配置:


    <?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>bin</id>

        <formats>
            <format>dir</format>
            <format>jar</format>
        </formats>

        <includeBaseDirectory>true</includeBaseDirectory>
        <baseDirectory>basic-modules</baseDirectory>

        <dependencySets>
            <dependencySet>
                <unpack>false</unpack>
                <scope>provided</scope>
                <outputDirectory>lib</outputDirectory>
                <excludes>
                    <exclude>*:payment-api</exclude>
                </excludes>
            </dependencySet>
        </dependencySets>

        <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>*:paypal-payment</include>
                    <include>*:moneris-payment</include>
                </includes>

                <binaries>
                    <outputDirectory>${module.artifactId}</outputDirectory>
                    <outputFileNameMapping>${module.artifactId}.${module.extension}</outputFileNameMapping>
                    <unpack>false</unpack>
                    <dependencySets>
                        <dependencySet>
                            <unpack>false</unpack>
                            <scope>runtime</scope>
                            <outputDirectory>${module.artifactId}/lib</outputDirectory>
                        </dependencySet>
                    </dependencySets>
                </binaries>
            </moduleSet>

        </moduleSets>
    </assembly>    

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>distro-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <finalName>basic-modules-${pom.version}</finalName>
                            <appendAssemblyId>false</appendAssemblyId>
                            <descriptor>assembly.xml</descriptor>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
于 2012-10-02T18:27:44.197 回答