用maven打包tar.gz文件

时间:2021-01-26 17:15:16

 

项目目录结构:

用maven打包tar.gz文件
 

pom.xml中添加:

  <build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptor>src/main/s/assembly/assembly.xml</descriptor>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

 

assembly.xml

<assembly>
<id>assembly</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/resources/assembly/bin</directory>
<outputDirectory>bin</outputDirectory>
<fileMode>0755</fileMode>
</fileSet>
<fileSet>
<directory>src/main/resources/assembly/conf</directory>
<outputDirectory>conf</outputDirectory>
<fileMode>0644</fileMode>
</fileSet>
</fileSets>
<dependencySets>
<dependencySet>
<outputDirectory>lib</outputDirectory>
</dependencySet>
</dependencySets>
</assembly>

 

 

pom.xml目录下执行命令 mvn package即可

执行完成后tar.gz文件中有三个文件夹bin conf 和 lib

 

 

参考:

https://my.oschina.net/u/1867229/blog/828200

  • 用maven打包tar.gz文件
  • 大小: 14.7 KB