捆绑多个工件进行部署? [英] bundling multiple artifact for deployment?

查看:141
本文介绍了捆绑多个工件进行部署?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是基于此答案的跟进。

我的结构看起来像

$ ls service/target/
classes             lib             maven-status            surefire-reports
classes.-1194128992.timestamp   maven-archiver          service-1.0-SNAPSHOT.jar

和with-in lib 看起来像

and with-in that lib looks like

$ 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 ,我想要捆绑le my-deployment-artifact 应该看起来包含

As part of mvn clean install, I want to bundle my-deployment-artifact which should look contain

service-1.0-SNAPSHOT.jar
lib/* (all the jars here)

我如何创建这是 tar .tar.gz 并使用生成mvn clean install

How do I create this as a tar or .tar.gz and produce with mvn clean install?

推荐答案

你可以使用 maven-assembly-plugin 执行该任务。

You can use maven-assembly-plugin to do that task.

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 文件中,添加插件声明,执行阶段和目标。

In pom.xml file, add plugin declare, execution phase and goal for it.

<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 /

More format file or customize of maven-assembly-plugin can be found here: https://maven.apache.org/plugins/maven-assembly-plugin/

这篇关于捆绑多个工件进行部署?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆