打开/关闭“maven汇编插件”

ef1yzkbh  于 2021-07-03  发布在  Java
关注(0)|答案(2)|浏览(346)

我们当前的devops环境运行 mvn package 并在私有maven存储库中自动部署jar工件,所有目标文件夹都被缓存以供以后使用。但该项目也有一个 maven-assembly-plugin 设置第二个jar文件(后缀为- jar-with-dependencies ).
我们不希望“胖jar”是由 maven-assembly-plugin 和其他文件一起存储在缓存中。
有没有办法转换 maven-assembly-plugin 通过命令行(或任何其他属性或环境变量)打开和关闭以仅在显式需要时运行它?

xzv2uavs

xzv2uavs1#

最简单的方法(imho)是在自己的概要文件中定义插件。在你的 pom.xml ,则添加 profiles 在那一节中 profile 包括插件:

<profiles>
  <profile>
    <id>assemble</id>
    <build>
      <plugins>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-assembly-plugin</artifactId>
          <!-- All the configuration you have for the plugin -->
        </plugin>
      </plugins>
    </build>
  </profile>
</profiles>

那么,默认情况下,这个插件将不会被调用。当您想调用它时,可以使用 -P 标志:

mvn package -Passemble
jobtbby3

jobtbby32#

您可以设置属性 assembly.skipAssemblytrue .
在命令行上(使用 -Dassembly.skipAssembly=true )或者在pom里。

相关问题