maven配置打包插件assembly,一般打这个包是要配置自动化部署jenkins等工具需要。
pom.xml
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>fastboot</finalName>
<descriptors>
<descriptor>src/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
上面标签解释一下你需要改的两个,finalName是生成文件名的 A-B.zip的A,descriptor里面是读取下面具体配置的,配置文件路径。
assembly.xml
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>app</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>bin</directory>
<outputDirectory>bin</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>target/fastboot.jar</source>
<outputDirectory>/lib</outputDirectory>
</file>
</files>
</assembly>
上面标签解释一下你需要改的两个,id是生成文件名的 A-B.zip的B,format是A-B.zip的zip后缀,可以改成别的。 filesets是把directory的文件复制到outputDirectory下面,file是把source的具体jar移动到outputDirectory下面。
文件名:最后生成的文件名是,pom.xml的finalName,然后横杠-,assembly.xml的id,然后以assembly.xml里面的format作为文件后缀,以这里为例就是fastboot-app.zip