Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to define a Maven 3 profile (and its activation policy) in one place and reuse it later?
    text
    copied!<p>My build process is very complex and I need to perform a few actions when running in Windows and a few in Linux, and those actions need to be placed in many different POMs.</p> <p>I know I can activate a certain profile according to the OS. But all examples I find include taking action inside the <code>&lt;profiles&gt; ... &lt;/profiles&gt;</code> tags, which also include the activation criteria for those profiles. What I'm trying to avoid is having to declare many sections like this:</p> <p>POM 1:</p> <pre><code>&lt;/profiles&gt; &lt;profile&gt; &lt;activation&gt; &lt;os&gt; &lt;family&gt;Windows&lt;/family&gt; &lt;arch&gt;x86&lt;/arch&gt; &lt;/os&gt; &lt;/activation&gt; &lt;build&gt; ... &lt;/build&gt; &lt;/profile&gt; ... &lt;/profiles&gt; </code></pre> <p>Then the same when I need to do something for windows in a different POM, many times all over the place... For some profiles the activation is more extensive.</p> <p>I wanted to define the activation policy in one place, then do something like:</p> <pre><code>&lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;3.0&lt;/version&gt; &lt;configuration&gt; &lt;!-- if profile A is active --&gt; &lt;source&gt;1.6&lt;/source&gt; &lt;target&gt;1.6&lt;/target&gt; &lt;!-- if profile B is active --&gt; &lt;source&gt;1.5&lt;/source&gt; &lt;target&gt;1.5&lt;/target&gt; &lt;/configuration&gt; &lt;/plugin&gt; </code></pre> <p>Just configuring the plugin differently according to the active profile, without having to duplicate the plugin declaration and everything for each profile in a ton of POM files...</p> <p>Also, how do I configure things in multiple places if profile A is active? Would I have to declare the tag in each POM with its activation policy all over again or is there a way to avoid all this duplication?</p> <p>Any help is appreciated, I'm a bit confused and surprised how hard is to find anything beyond basic examples on the net.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload