TL;DR
No, using activeByDefault
is NOT against maven best practices.
Details
As described in docs this feature is quite simple:
This profile will automatically be active for all builds unless another profile in the same POM is activated using one of the previously described methods. All profiles that are active by default are automatically deactivated when a profile in the POM is activated on the command line or through its activation config.
However in practice you may (and will) have a lot of different conditions for your project defaults:
- true active by default = always active, unless explicitly deactivated
- legacy systems = active, unless JDK is above (or below) specific version
- else-profile = active, when base profile is deactivated
- environment specific
- filesystem specific
- OS specific
- ...
Thus to use activeByDefault
you need to meet three conditions:
- you need such behaviour, as described in docs
- simple project structure
- controlled build environment (dev, CI)
I saw small projects where it was effectively used. I saw huge projects, where this feature was prohibited. And of course I saw projects with this feature misuse, caused by developer's ignorance (rtfm).
Conclusion
This feature could be useful for a small part of Maven community. It's an example of uncommon API, just like java.lang.Long#getLong
- useful in rare cases, but ignored by the majority of developers.
PS
Unconditional active by default profile:
<profile>
<id>active-unless-explicitly-deactivated</id>
<activation>
<file><exists>.</exists></file>
</activation>
...
</profile>
and it's deactivation:
./mvnw -P !active-unless-explicitly-deactivated ...
alwaysActive
" (which I made up), why make a profile to begin with? If it is for the purpose of being able to disable it, properties would allow for that just fine (as the quote said). Activation through properties is popular among many (those seem to like-Dxxx
over-Pxxx
; I don't care either way). I've not seenactiveByDefault
a lot in the wild... – SwankyactiveByDefault
profile in the child ? Consider this: there is a 'dev' and a 'production' profile, with the former being activated by the absence of a 'prod' property and the latter being activated by the presence of the same. In that case, devs don't have that property and the dev profile is activated by default. So just the presence or absence of property switches between the two profiles. – Versatile