如何使用maven在装配目标后重新包装到罐子里?

时间:2012-02-22 16:21:57

标签: maven maven-assembly-plugin

我需要将一个jar文件重新打包到多个jar的内容中,所以我使用Maven assembly plugin将jar解压缩到程序集目录。这是通过一个非常标准的程序集描述符完成的:

<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>assembly</id>
    <formats>
        <format>dir</format>
    </formats>
    <includeBaseDirectory>false</includeBaseDirectory>

    <dependencySets>

        <dependencySet>
            <outputDirectory>lib</outputDirectory>
            <unpack>true</unpack>
            <unpackOptions>
                <excludes>
                    <exclude>**/dll/**</exclude>
                    <exclude>**/dylib/**</exclude>
                    <exclude>**/so/**</exclude>
                </excludes>
            </unpackOptions>
            <scope>runtime</scope>
            <useTransitiveDependencies>false</useTransitiveDependencies>
            <includes>
                <include>com.corp*:*</include>
            </includes>
            <excludes>
                <exclude>com.corp*:*-xb-*</exclude>
                <exclude>com.corp*:juniper</exclude>
            </excludes>
        </dependencySet>
    </dependencySets>

    <files>
        <file>
            <source>about.txt</source>
            <outputDirectory>/lib</outputDirectory>
            <filtered>true</filtered>
        </file>
    </files>

</assembly>

问题是,如何将整个东西打包到罐子里?我是否需要创建一个新的POM才能重新打包组件的输出?

由于

1 个答案:

答案 0 :(得分:5)

您可以添加到程序集描述符

<format>jar</format>