You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Laird Nelson <lj...@gmail.com> on 2011/12/13 18:31:08 UTC
Plugin configuration and property precedence question
I've noticed that some plugins feature expressions that, when present as
properties, will override configuration values.
So, taking the maven-compiler-plugin as an arbitrary example, I can
configure its "source" property like this:
<configuration>
<source>1.6</source>
</configuration>
...or I could simply set a property in my pom.xml file (i.e. instead of the
configuration above):
<maven.compiler.source>1.6</maven.compiler.source> <!-- the expression is
defined according to the docs as maven.compiler.source -->
...or I could eliminate that and make sure that I always specified the
following on the command line (an admittedly contrived solution):
-Dmaven.compiler.source=1.6
So far this all makes sense to me.
Now let's introduce inheritance. Suppose I have a pom.xml that extends
another one. Suppose the parent opts for solution #2 above. That is,
inside its <properties> section it does this:
<maven.compiler.source>*1.6*</maven.compiler.source>
...and furthermore does not specify an explicit configuration for the
maven-compiler-plugin. Now suppose the child introduces this:
<configuration>
<source>*1.5*</source>
</configuration>
Will the maven-compiler-plugin executed in the child be configured with (at
build time) a source value of 1.6 or 1.5?
Thanks,
Laird
--
http://about.me/lairdnelson
Re: Plugin configuration and property precedence question
Posted by Laird Nelson <lj...@gmail.com>.
On Tue, Dec 13, 2011 at 4:32 PM, Stephen Connolly <
stephen.alan.connolly@gmail.com> wrote:
> i think of it like so...
>
> if no value in plugin configuration in pom, then evaluate expression, if
> expression evaluates to null, then use default value, if still here, don't
> inject into the field (so the fields initializer from the jvm/class
> applies)
>
Thank you; that's very helpful. However, what was confusing me--and still
is, I guess--is that even if there *is* a value in the plugin
configuration, a property specified on the command line (an expression)
will override...or...that was my impression. {blink blink} Perhaps not.
Long day; back to more tests.
Thanks,
Laird
--
http://about.me/lairdnelson
Re: Plugin configuration and property precedence question
Posted by Stephen Connolly <st...@gmail.com>.
i think of it like so...
if no value in plugin configuration in pom, then evaluate expression, if
expression evaluates to null, then use default value, if still here, don't
inject into the field (so the fields initializer from the jvm/class applies)
- Stephen
---
Sent from my Android phone, so random spelling mistakes, random nonsense
words and other nonsense are a direct result of using swype to type on the
screen
On 13 Dec 2011 17:44, "Laird Nelson" <lj...@gmail.com> wrote:
> On Tue, Dec 13, 2011 at 12:39 PM, Laird Nelson <lj...@gmail.com> wrote:
>
> > On Tue, Dec 13, 2011 at 12:36 PM, Guillaume Polet <
> > guillaume.polet@gmail.com> wrote:
> >
> >> use mvn help:effective-pom to find out. My guess would be 1.5.
> >>
> >
> > OK; I was more curious to know how one would determine whether there was
> a
> > bug in Maven's property precedence rules. If the answer is: "use Maven
> and
> > see what it says, that's the answer" :-) then there cannot be a bug in
> this
> > area. :-) :-)
> >
>
> Actually, mvn help:effective-pom won't do it, BTW; it will simply show what
> the <properties> property is, not the actual configuration values. I
> guess mvn
> -X will tell me what Maven *happens* to be doing. I'll start there.
>
> best,
> Laird
>
> --
> http://about.me/lairdnelson
>
Re: Plugin configuration and property precedence question
Posted by Laird Nelson <lj...@gmail.com>.
On Tue, Dec 13, 2011 at 12:39 PM, Laird Nelson <lj...@gmail.com> wrote:
> On Tue, Dec 13, 2011 at 12:36 PM, Guillaume Polet <
> guillaume.polet@gmail.com> wrote:
>
>> use mvn help:effective-pom to find out. My guess would be 1.5.
>>
>
> OK; I was more curious to know how one would determine whether there was a
> bug in Maven's property precedence rules. If the answer is: "use Maven and
> see what it says, that's the answer" :-) then there cannot be a bug in this
> area. :-) :-)
>
Actually, mvn help:effective-pom won't do it, BTW; it will simply show what
the <properties> property is, not the actual configuration values. I guess mvn
-X will tell me what Maven *happens* to be doing. I'll start there.
best,
Laird
--
http://about.me/lairdnelson
Re: Plugin configuration and property precedence question
Posted by Laird Nelson <lj...@gmail.com>.
On Tue, Dec 13, 2011 at 12:36 PM, Guillaume Polet <guillaume.polet@gmail.com
> wrote:
> use mvn help:effective-pom to find out. My guess would be 1.5.
>
OK; I was more curious to know how one would determine whether there was a
bug in Maven's property precedence rules. If the answer is: "use Maven and
see what it says, that's the answer" :-) then there cannot be a bug in this
area. :-) :-)
Best,
Laird
--
http://about.me/lairdnelson
Re: Plugin configuration and property precedence question
Posted by Guillaume Polet <gu...@gmail.com>.
use mvn help:effective-pom to find out. My guess would be 1.5.
Cheers,
Guillaume
Le 13/12/2011 18:31, Laird Nelson a écrit :
> I've noticed that some plugins feature expressions that, when present as
> properties, will override configuration values.
>
> So, taking the maven-compiler-plugin as an arbitrary example, I can
> configure its "source" property like this:
>
> <configuration>
> <source>1.6</source>
> </configuration>
>
> ...or I could simply set a property in my pom.xml file (i.e. instead of the
> configuration above):
>
> <maven.compiler.source>1.6</maven.compiler.source> <!-- the expression is
> defined according to the docs as maven.compiler.source -->
>
> ...or I could eliminate that and make sure that I always specified the
> following on the command line (an admittedly contrived solution):
>
> -Dmaven.compiler.source=1.6
>
> So far this all makes sense to me.
>
> Now let's introduce inheritance. Suppose I have a pom.xml that extends
> another one. Suppose the parent opts for solution #2 above. That is,
> inside its<properties> section it does this:
>
> <maven.compiler.source>*1.6*</maven.compiler.source>
>
> ...and furthermore does not specify an explicit configuration for the
> maven-compiler-plugin. Now suppose the child introduces this:
>
> <configuration>
> <source>*1.5*</source>
> </configuration>
>
> Will the maven-compiler-plugin executed in the child be configured with (at
> build time) a source value of 1.6 or 1.5?
>
> Thanks,
> Laird
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org