扩展Maven货物插件jvmargs [英] Extend maven cargo plugins jvmargs

查看:117
本文介绍了扩展Maven货物插件jvmargs的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个maven项目,该项目扩展了现有的父项目(这是标准产品",从中我的产品将成为定制产品".)

I have a maven project which extends an existing parent project (It's the "standard product" from which my product will be a "Customized product").

父级声明一个org.codehaus.cargo / cargo-maven2-plugin并将其传递给configuration/cargo.jvmargs下的某些VM参数.像这样:

The parent declares a org.codehaus.cargo / cargo-maven2-plugin and passes it some VM args under configuration / cargo.jvmargs. Like this:

    <plugin>
      <groupId>org.codehaus.cargo</groupId>
      <artifactId>cargo-maven2-plugin</artifactId>
      <version>1.4.18</version>
      <configuration>
        <container>
          <containerId>tomcat8x</containerId>
          [...]
          <dependencies>
            [...]
          </dependencies>
        </container>
        <configuration>
          <properties>
            <cargo.jvmargs>-ArgA -ArgB -ArgC</cargo.jvmargs>
          </properties>
          <configfiles>
            [...]
          </configfiles>
          <files>
            [...]
          </files>
        </configuration>
      </configuration>
    </plugin>

现在在我的自定义项目中,我想使用一个以上的参数(例如-ArgD)扩展这些jvm args,以便args为-ArgA -ArgB -ArgC -ArgD.我不想重写整个插件只是为了做一点点改动.

Now in my custom project, I want to extend these jvm args with one more argument (Let's say -ArgD), so that the args are -ArgA -ArgB -ArgC -ArgD. I don't want to override the entire plugin only to do this one little change.

我知道我可以指定以下内容:cargo:run -Dcargo.jvmargs="-ArgD",但是这里的问题是:所有其他args(ArgA,ArgB,ArgC)都将被覆盖/删除,仅ArgD将保留.我需要的是类似cargo:run -Dcargo.jvmargs="current_cargo.jvmargs + -ArgD"的东西.

I know that I can specify this: cargo:run -Dcargo.jvmargs="-ArgD" but the problem here is: All other args (ArgA, ArgB, ArgC) get overridden/removed, only ArgD will remain. What I need is something like cargo:run -Dcargo.jvmargs="current_cargo.jvmargs + -ArgD".

这有可能吗?

推荐答案

最干净的方法是将父pom中的jvmargs移动到maven属性.然后,在您的自定义项目中,您将可以使用maven属性将jvmargs与您的自定义值组合在一起.例如:

The cleanest possibility would be to move jvmargs in parent pom to maven property. Then in your custom project you would be able combine jvmargs using maven property with your custom values. For example:

父pom:

<properties>
    <cargo.base.jvmargs>-ArgA -ArgB -ArgC</cargo.base.jvmargs>
</properties>
[...]
<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <version>1.5.0</version>
  <configuration>
      [...]
    <configuration>
      <properties>
        <cargo.jvmargs>${cargo.base.jvmargs}</cargo.jvmargs>
      </properties>
        [...]
    </configuration>
  </configuration>
</plugin>

您的自定义pom:

<plugin>
  <groupId>org.codehaus.cargo</groupId>
  <artifactId>cargo-maven2-plugin</artifactId>
  <configuration>
      [...]
    <configuration>
      <properties>
        <cargo.jvmargs>${cargo.base.jvmargs} -ArgD</cargo.jvmargs>
      </properties>
        [...]
    </configuration>
  </configuration>
</plugin>

如果无法修改父pom,则可以使用Cargo属性cargo.start.jvmargs(请参阅此页面).此属性在启动时向容器添加Java参数.

If there isn't possibility to modify parent pom you may use Cargo property cargo.start.jvmargs (see this page). This property add java arguments to container when it is started.

这篇关于扩展Maven货物插件jvmargs的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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