views:

303

answers:

1

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 to 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.

+1  A: 

Hey,

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!

Esk
I was hoping it wouldn't come to that, but I can't see any other way to do it either. Thanks.
jobrahms