Can A Maven Profile Enable/disable Another Profile From Its Definition?
Given two profiles A and B, is it possible to specify something within profile A definition that would enable or disable profile B?
This is not possible to activate / deactivate a profile from another profile. Maven needs to know the list of active profiles before building the model.
There are a couple of work-arounds depending on your use-case:
- Set one profile to
activeByDefault: it will be automatically deactivated when another profile is activated.
Use a custom property so that one profile is activated by the presence of the property and the other profile is deactivated by the presence of the property. Sample configuration would look like:
<profile> <id>profileA</id> <activation> <property> <name>somename</name> </property> </activation> </profile> <profile> <id>profileB</id> <activation> <property> <name>!somename</name> </property> </activation> </profile>
Thus, if you invoke Maven with
profileAwill be activated; otherwise
profileBwill be activated.
- → git with maven-release-plugin and buildnumber-maven-plugin
- → Convert Doc to PDf with documents4j
- → Failure build on Maven release plugin
- → Oracle Data source configuration in MULE
- → Is it possible to use Maven to develop Frontend/Web apps?
- → How to use files outside of war file on jetty server?
- → Intellij build different from maven build
- → ExpectedConditions can not be resolved
- → Maven. Complete a java-code during building
- → Logback configuration file not loaded
- → Error creating bean with name 'entityManagerFactory' defined in class path
- → Eclipse TDD - How to join test and main source folders?
- → javafx-maven-plugin Updates Wrong Folder