1

使用 Maven 3.0.4

我有一个多模块 maven 项目,其中一些模块产生 war 文件,而一些产生 jar 文件,正如它们各自的 pom 中所声明的那样

我想创建一个分发存档,其中 jar 工件和依赖项进入一个子目录,而 webapp 工件(无依赖项)进入另一个子目录。

就像是

project.tar/lib     <-- module jars and deps here
project.tar/webapp  <-- wars here

让程序集将所有内容转储到一个目录中很简单。

这是我尝试过的:

<assembly>
    <id>bin</id>
    <formats>
        <format>tar.gz</format>
    </formats>

    <moduleSets>
        <moduleSet>
            <includes>
                <include>${module.groupId}:${module.artifactId}:war:${module.version}</include>
            </includes>
            <binaries>
                <includeDependencies>false</includeDependencies>
                <outputDirectory>webapp</outputDirectory>
            </binaries>
        </moduleSet>
        <moduleSet>
            <includes>
                <include>${module.groupId}:${module.artifactId}:jar:${module.version}</include>
            </includes>
            <binaries>
                <includeDependencies>true</includeDependencies>
                <outputDirectory>lib</outputDirectory>
            </binaries>
        </moduleSet>
    </moduleSets>
</assembly>

现在,当我运行它时,我收到以下警告:

[INFO] Reading assembly descriptor: assembly.xml
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o  '${module.groupId}:${module.artifactId}:war:${module.version}'

[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o  '${module.groupId}:${module.artifactId}:jar:${module.version}'

[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o  '${module.groupId}:${module.artifactId}:war:${module.version}'

[WARNING] NOTE: Currently, inclusion of module dependencies may produce unpredictable results if a version conflict occurs.
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o  '${module.groupId}:${module.artifactId}:jar:${module.version}'

不知道我做错了什么。我的包含遵循 maven 网页上指定的“group:artifact:version”模式。

谢谢

4

1 回答 1

3

这似乎有效。不过,不确定这是否是最好的方法。Maven 似乎不尊重 ${module.whatever} 变量。

<dependencySets>
    <dependencySet>
        <includes>
            <include>${project.groupId}:*:war:${project.version}</include>
        </includes>
        <useProjectArtifact>true</useProjectArtifact>
        <outputDirectory>webapp</outputDirectory>
        <unpack>false</unpack>
    </dependencySet>
    <dependencySet>
        <excludes>
            <exclude>${project.groupId}:*:war:${project.version}</exclude>
        </excludes>
        <useProjectArtifact>true</useProjectArtifact>
        <outputDirectory>lib</outputDirectory>
        <unpack>false</unpack>
    </dependencySet>
</dependencySets>
于 2012-08-24T23:42:36.353 回答