0

My question is similar to this: How to exclude a module from a Maven reactor build?; however what I'd like to do is define a way of turning off-on modules based on a property. This property will be defined in an external property file we're using as our build profile.

The problem is that the property file isn't read in until the lifecycle after the Reactor is run (it appears Reactor is always run first).

Something like:

propertyfile.properties

module1.enabled = true
module2.enabled = false
module3.enabled = true

pom.xml

<profiles>
 <profile>
  <id>module1</id>
  <activation>
   <activeByDefault>false</activeByDefault>
   <property>
    <name>module</name>
    <value>true</value>
   </property>
  </activation>
 </profile>
 ...
</profiles>
Community
  • 1
  • 1
Andrew
  • 777
  • 1
  • 7
  • 19
  • First question: Why would you like to do this? Can you give a little bit more background? Why not simply using the profiles as you already did? Activate/Deactivate via -Pmodule1 etc... – khmarbaise Dec 20 '11 at 10:51
  • Well, full background is: basically we produce several different release packages for different clients. We create a branch of the property file for each client. We would like to use the same maven command line to build the packages on our CI server rather than having to tweak the profiles involved; it's becoming especially cumbersome to do so now that there are upwards of 30 profiles involved. – Andrew Dec 20 '11 at 10:57
  • 1
    That means you have some modules in common for all clients and some which are special for the clients. That sounds to me that your approach is wrong. Create separate projects for the common parts deploy/release those artifacts and the client specific modules add a dependency to those common modules. – khmarbaise Dec 20 '11 at 11:41
  • You can use the CI (Jenkins e.g.) to create the different packages based on the profiles (matrix builds can be used for such a thing). – khmarbaise Dec 20 '11 at 11:41

0 Answers0