Maven: property to activate profile in sub-modules -


We have a multi-module maven project, and there are various platforms to run it, such as Zebus 4 and Zebus 7. We specify the platform property, and then use it as a classifier for artifacts, and for the activation of platform-specific profiles in sub-modules such as:

  & lt; Activation & gt; & Lt; Property & gt; & Lt; Name & gt; Platform & lt; / Name & gt; & Lt; Price & gt; Jboss71x & lt; / Pricing & gt; & Lt; / Property & gt; & Lt; / Activation & gt;  

In these profiles, we, among other things, specify the version of dependency provided. As we import Jbys Parent Palm:

   & Lt; Version & gt; $ {Dependencies.jbossas7.version} & lt; / Edition & gt; & Lt; Type & gt; Pom & lt; / Type & gt; & Lt; Scope & gt; Import & lt; / Scope & gt; & Lt; / Dependencies & gt;  

So when we specify the property in the form of command-line arguments ( -Dplatform = jboss71x ), then it works fine.

But when the property is & lt; Property & gt; In the section, the root pom.xml (I also tries to set it in parent palm) is set, it seems that the versions of parent pom are remembered:

  [Error] 'dependencies.dependency.version' for commons-lang: commons-lang: jar is missing. @ Line 46, column 21 [Error] Commons-Benefits for 'Dependency. Dependency Version ': Commons-Binilities: Jar is missing. @ Line 56, column 21 [error] 'dependency for commons collection. Dependency Edition ': Commons Collection: Jar is missing. @ Line161, Column 21  

The Maven version is the latest: 3.2.1.

Why this happens, and how can we specify this property value in pom.xml, not in the command line?

Regrettably, it is not possible to do what you are trying to do. Before searching on CodeHouse website, I spent hours trying the same thing:

Note that the properties set on the Maven command line can only activate the profile. The properties established in POM, parent pom, or other profiles have no effect. In fact, profile activation is done long before POM processing, essentially it means that the property activating a profile should have a defined value at the beginning of a construction value. - As the property of the system, so on the command line - because Maven is any & lt; Properties & gt; element is a similar stack overflow question which provides more details and background docs.


Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -