I'm trying to activate a maven profile using a property defined inside pom.xml
:
<project>
[...]
<properties>
<run.it>true</run.it>
</properties>
[...]
<profiles>
<profile>
<activation>
<property><name>run.it</name></property>
</activation>
[...]
</profile>
</profiles>
[...]
</project>
Apparently it doesn't work. However, activation works from the command line:
mvn -Drun.it
Is it "by design"? If it is, what is a possible workaround?
A profile in Maven is an alternative set of configuration values which set or override default values. Using a profile, you can customize a build for different environments. Profiles are configured in the pom. xml and are given an identifier.
Edit, complete rewrite, as i understand the question now.
See this forum post:
profile activation is based on SYSTEM properties. you cannot activate profiles based on properties defined in your pom you cannot activate profiles based on system properties defined after the build plan has started execution
What about using an activation like this
<profile>
<id>gwt</id>
<activation>
<file>
<exists>uses-gwt.marker</exists>
</file>
</activation>
and adding the file 'uses-gwt.marker' into source control, right next to pom.xml. That gives all developers the same state and sort of allows an aspect-oriented pom. we're using this technique in the parent pom and put hte marker files in the childs svn. Not ideal, but works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With