How to repackage to jar after assembly goal using

2019-07-31 19:37发布

问题:

I need to repackage to a jar file the content of multiple jars so I use Maven assembly plugin to unpack the jars to the assembly dir. This is done with a pretty standard assembly descriptor:

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

The problem is, how do I package the whole thing to a jar? Do I need to create a new POM just to repackage the output of the assembly?

Thanks

回答1:

You could add to your assembly descriptor

<format>jar</format>