1

我们的 pom.xml 在 maven-jar-plugin 中有多个执行,目的是创建三个单独的 jar 文件。调用 mvn 并构建三个 jar 的方法是什么?

目前

mvn compile jar:jar

仍然只创建一个罐子。

    <artifactId>maven-jar-plugin</artifactId>
        <version>2.3.2</version>
    <executions>
        <execution>
            <id>UDFCommon</id>
            <goals><goal>jar</goal></goals>
            <phase>package</phase>
            <configuration>
                <forceCreation>true</forceCreation>
                <classifier>UDFCommon</classifier>
                <includes>
                    <include>**/pafcommon/*</include>
                </includes>
            </configuration>
        </execution>
        <execution>
            <id>UDFOne</id>
            <goals><goal>jar</goal></goals>
            <phase>package</phase>
            <configuration>
                <classifier>UDFOne</classifier>
                <includes>
                    <include>**/dqm/*</include>
                </includes>
            </configuration>
        </execution>
        <execution>
            <id>UDFTwo</id>
            <goals><goal>jar</goal></goals>
            <phase>package</phase>
            <configuration>
                <classifier>UDFTwo</classifier>
                <includes>
                    <include>**/ciview/*</include>
                </includes>
            </configuration>
        </execution>
    </executions>
    </plugin>
4

1 回答 1

1

jar:jar 似乎无法处理多个 jar 文件。但是跑步

mvn compile package

成功了。

-rw-r--r--   1 steve  staff  2629074 Oct 16 15:24 UDFPafDqm.jar
-rw-r--r--   1 steve  staff    13286 Oct 16 15:24 UDFPafDqm-UDFTwo.jar
-rw-r--r--   1 steve  staff    40315 Oct 16 15:24 UDFPafDqm-UDFOne.jar
-rw-r--r--   1 steve  staff     6942 Oct 16 15:24 UDFPafDqm-UDFCommon.jar

为此需要一个 assembly.xml:一个准系统如下所示。

<assembly>
    <id>job</id>
    <formats>
        <format>jar</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>
    <fileSets>
        <fileSet>
            <directory>${project.build.outputDirectory}</directory>
            <outputDirectory>/</outputDirectory>
        </fileSet>
    </fileSets>


    <dependencySets>
        <dependencySet>
            <scope>runtime</scope>
            <outputDirectory>lib</outputDirectory>
        </dependencySet>
    </dependencySets>
</assembly>
于 2013-10-16T22:27:12.923 回答