我使用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
答案 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>