Re: Profile file activation in a reactor pom, using paren't relative dir - odd behavior

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: Profile file activation in a reactor pom, using paren't relative dir - odd behavior

Jörg Schaible
Hi,

Am Mittwoch, 27. November 2019, 20:15:11 CET schrieb Danny Shemesh:
> Hey everyone,
>
> I’m trying to activate a profile in a multi-module project, with several
> reactor poms, based on a file existing (or missing) from the parent
> directory of the root ‘grand’ parent pom.

[snip]

> It seems like the activation file path is expanded correctly in the child
> module, however, it does not activate the profile as I would’ve expected;
> Sadly, using session.executionRootDirectory, or
> maven.multiModuleProjectDirectory wouldn’t meet all Our requirements, as we
> have several parent poms, and we don’t always run maven from the ‘grand’
> pom directory.
>
> The above was tested using maven 3.6.3 on windows.
>
> Would love to have any pointers on why this doesn’t work, and how can I
> achieve such a behavior irregardless.

The first thing Maven does, is generating the effective POM. It will first select
all active profiles (from the complete hierarchy) and then interpolate all the
properties. The assumption is simply wrong that a parent POM is completely
resolved first (incl. properties). You cannot activate a profile in a child POM
based on the value set in a parent POM. Especially in the activation part of a
profile there is no property interpolation (or very limited in the meanwhile).

What you can do though: Declare a profile in a parent based on the existence of
a file or directory with a relative path. If it is present in the context of a
child project, the profile gets activated. That's how profiles can be predefined
in a parent and selectively activated. We use typically a directory profiles
with empty files in each child that should use some special, but generic build.

Cheers,
Jörg



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]