如何让maven多模块程序集将war文件与jar文件放在一个单独的子目录中?

v440hwme  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(365)

使用maven 3.0.4
我有一个多模块maven项目,其中一些模块生成war文件,一些模块生成jar文件,正如在各自的pom中声明的那样
我想创建一个分发归档,其中jar工件和依赖项进入一个子目录,webapp工件(sans依赖项)进入另一个子目录。
像这样的

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}'

不知道我做错了什么。我的收入如下“group:artifact:version“在maven的网页上指定的模式。
谢谢

pod7payv

pod7payv1#

这似乎管用。不过,不确定这是不是最好的方法。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>

相关问题