简体   繁体   中英

How to have a maven multi-module assembly put war files in a separate subdir from jar files?

Using maven 3.0.4

I have a multi-module maven project, with some modules producing war files, and some producing jar files, as declared in their respective poms

I want to create a distribution archive with the jar artifacts and dependencies going into one subdirectory and the webapp artifacts (sans dependencies) going into another subdirectory.

something like

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

It's simple enough to get the assembly to dump everything in one directory.

This is what I have tried:

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

Now when I run this, I get these warnings:

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

Not sure what I am doing wrong. My includes are following the "group:artifact:version" pattern specified on maven's web page.

Thanks

This seems to work. Not sure if it is the best way to do it, though. Maven seems to be not honoring the ${module.whatever} variables.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM