解压缩位于磁盘上的文件(maven-assembly-plugin)

时间:2015-10-30 17:42:16

标签: java maven maven-assembly-plugin

我正在尝试输出在./target/dist文件夹中运行项目所需的所有文件。我想在准备装配时捆绑一个JRE。 JRE位于我项目的基本目录中,包含在名为jre.zip的zip文件中。

如何在./jre.zip文件夹中解压缩./target/dist

这是我的汇编的XML。

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
    <id>dist</id>
    <formats>
        <format>dir</format>
    </formats>
    <baseDirectory>./</baseDirectory>
    <fileSets>
        <fileSet>
            <directory>./</directory>
            <outputDirectory>./jre</outputDirectory>
            <excludes>
                <exclude>*/**</exclude>
            </excludes>
        </fileSet>
    </fileSets>
    <files>
        <file>
            <source>${project.build.directory}/${project.build.finalName}.jar</source>
            <destName>${artifactId}.jar</destName>
            <outputDirectory>./</outputDirectory>
        </file>     
    </files>
</assembly>

1 个答案:

答案 0 :(得分:2)

虽然您可以使用Maven Assembly Plugin解压缩依赖关系,但我非常喜欢使用jre ....

我建议您在执行Assembly插件之前解压缩jre,如此

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
    <execution>
        <id>prepare</id>
        <phase>validate</phase>
        <configuration>
            <tasks>
                <echo message="prepare phase" />
                <unzip src="jre.zip" dest="target/jre"/>
            </tasks>
        </configuration>
        <goals>
            <goal>run</goal>
        </goals>
    </execution>
</executions>

相关问题