这是基于此answer的跟进。
我的结构看起来像
$ ls service/target/
classes lib maven-status surefire-reports
classes.-1194128992.timestamp maven-archiver service-1.0-SNAPSHOT.jar
和with-in lib
看起来像
$ ls service/target/lib/
activation-1.1.jar akka-http-spray-json-experimental_2.11-1.0.jar mail-1.4.7.jar scala-reflect-2.11.2.jar
akka-actor_2.11-2.3.12.jar akka-parsing-experimental_2.11-1.0.jar manager-1.0-SNAPSHOT.jar scala-xml_2.11-1.0.2.jar
akka-http-core-experimental_2.11-1.0.jar akka-stream-experimental_2.11-1.0.jar reactive-streams-1.0.0.jar scalatest_2.11-2.2.5.jar
akka-http-experimental_2.11-1.0.jar config-1.2.1.jar
作为mvn clean install
的一部分,我想捆绑应该包含
my-deployment-artifact
service-1.0-SNAPSHOT.jar
lib/* (all the jars here)
如何将其创建为tar
或.tar.gz
并使用mvn clean install
生成?
答案 0 :(得分:3)
您可以使用maven-assembly-plugin
执行该任务。
在src/assembly/distribution.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>distribution</id>
<formats>
<format>tar</format>
</formats>
<files>
<file>
<source>${project.build.directory}/${project.build.finalName}.${project.packaging}</source>
</file>
</files>
<fileSets>
<fileSet>
<directory>${project.build.directory}/lib</directory>
<outputDirectory>lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
在pom.xml
文件中,为其添加插件声明,执行阶段和目标。
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
<configuration>
<descriptor>${project.basedir}/src/assembly/distribution.xml</descriptor>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
可以在此处找到更多格式文件或自定义maven-assembly-plugin
:https://maven.apache.org/plugins/maven-assembly-plugin/