Activate Maven Profile by Packaging

251 Views Asked by At

The Release Notes of Maven 3.9.0 state that you can now activate profiles by packaging.

Can someone give me an example how to do this?

1

There are 1 best solutions below

0
kerbermeister On BEST ANSWER

I think you can refer to this introduction

See the section How can a profile be triggered? How does this vary according to the type of profile being used?

Shortly it says the following:

Since Maven 3.9.0 one can also evaluate the POM's packaging value by referencing property packaging. This is only useful where the profile activation is defined in a common parent POM which is reused among multiple Maven projects. The next example will trigger the profile when a project with packaging war is built:

<profiles>
  <profile>
    <activation>
      <property>
        <name>packaging</name>
        <value>war</value>
      </property>
    </activation>
    ...
  </profile>
</profiles>