Maven包zip文件结构

时间:2014-05-18 11:31:38

标签: maven

我使用maven-assembly-plugin打包zip。完成打包后,zip文件结构如下:

test.zip
    |--test
        |--test.jar
        |--test.dalp

我的assemble.xml和pom.xml配置如下:

assemble.xml

<assembly>
<id>bin</id>
<formats>
    <format>zip</format>
</formats>
<fileSets>
    <fileSet>
        <directory>/</directory>
        <outputDirectory>/</outputDirectory>
        <includes>
            <include>test.dalp</include>
        </includes>
    </fileSet>
    <fileSet>
        <directory>/target</directory>
        <outputDirectory>/</outputDirectory>
        <includes>
            <include>test.jar</include>
        </includes>
    </fileSet>
</fileSets>

的pom.xml

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2.1</version>
    <configuration>
        <appendAssemblyId>false</appendAssemblyId>
        <descriptors>
            <descriptor>src/main/assembly/assembly.xml</descriptor>
        </descriptors>
    </configuration>
    <executions>
        <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
                <goal>single</goal>
            </goals>
        </execution>
    </executions>
</plugin>

我想知道如何配置assemble.xml和pom.xml,并在运行&#34; mvn clean package&#34;在命令行中,zip文件结构如下:

test.zip
    |__test.jar
    |__test.dalp 

1 个答案:

答案 0 :(得分:1)

您可以将配置更改为以下内容:

<assembly>
  <id>bin</id>
<formats>
    <format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
    <fileSet>
        <directory>/</directory>
        <outputDirectory>/</outputDirectory>
        <includes>
            <include>test.dalp</include>
        </includes>
    </fileSet>
    <fileSet>
        <directory>/target</directory>
        <outputDirectory>/</outputDirectory>
        <includes>
            <include>test.jar</include>
        </includes>
    </fileSet>
</fileSets>