开发者

Maven assembly plugin: run only one descriptor

I have a project which has several custom descriptors written for the assembly plugin. Is there a way to run only one of those descriptors at a time instead of the whole bunch? I tried using the descriptors switch as documented here, passing in the full path t开发者_运维百科o the one descriptor that I wanted to run, but instead it's running all of the descriptors in my app's main pom file, seeming to ignore the switch I specified.


Probably the easiest way to do so, is by using Maven Profiles.

Define some profiles in your pom.xml:

<profiles>
  <profile>
    <id>profile-1</id>
    <properties>
      <assembly-config>assem1.xml</assembly-config>
    </properties>
  </profile>
  <profile>
    <id>profile-2</id>
    <properties>
      <assembly-config>assem2.xml</assembly-config>
    </properties>
  </profile>
</profiles>

Then you use that particular property for the configuration of the assembly plugin:

 ...
 <descriptor>src/main/assembly/${assembly-config}</descriptor>
 ...

Then run your maven build with the -P option: mvn -P profile-1 compile

So, summarized, if you choose a profile at buildtime, the property assembly-config will be set depending on the defined profile. The assembly configuration depends in that case on the chosen profile.

Hope this helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜