You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by András Kerekes <an...@gmail.com> on 2017/04/13 00:05:44 UTC

Check if parameter is explicitly set

Hi,

I'm working on a Maven plugin and I'd like to check whether a parameter for
a Mojo has been explicitly set by the user (via POM), or it contains the
default value. Is there a way to do this?

Thanks,
 András

Re: Check if parameter is explicitly set

Posted by Robert Scholte <rf...@apache.org>.
On Thu, 13 Apr 2017 14:39:44 +0200, András Kerekes  
<an...@gmail.com> wrote:

> Hey,
>
> Sure, let me give you more context. The parameter has a default value  
> that
> users can override. But if they don't set it and another condition is  
> true
> (some file exists in the project), then we want to use a different  
> value, a
> different default. Maybe the best is to remove the default value, and in
> the Mojo's execute() if it's null (the user didn't set it) we can decide
> what value to assign to it based on the mentioned condition.

Right, a *conditional* default value should not be treated as a default  
value.

>
> András
>
> On Thu, Apr 13, 2017, 02:41 Karl Heinz Marbaise <kh...@gmx.de>  
> wrote:
>
>> Hi,
>>
>> On 13/04/17 02:05, András Kerekes wrote:
>> > Hi,
>> >
>> > I'm working on a Maven plugin and I'd like to check whether a  
>> parameter
>> for
>> > a Mojo has been explicitly set by the user (via POM), or it contains  
>> the
>> > default value. Is there a way to do this?
>>
>> Maybe I misunderstand a thing but why do you need to distinguish between
>> those two? Isn't that why defaultValue exist?
>>
>> Kind regards
>> Karl Heinz Marbaise
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
>> For additional commands, e-mail: dev-help@maven.apache.org
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Check if parameter is explicitly set

Posted by András Kerekes <an...@gmail.com>.
Hey,

Sure, let me give you more context. The parameter has a default value that
users can override. But if they don't set it and another condition is true
(some file exists in the project), then we want to use a different value, a
different default. Maybe the best is to remove the default value, and in
the Mojo's execute() if it's null (the user didn't set it) we can decide
what value to assign to it based on the mentioned condition.

András

On Thu, Apr 13, 2017, 02:41 Karl Heinz Marbaise <kh...@gmx.de> wrote:

> Hi,
>
> On 13/04/17 02:05, András Kerekes wrote:
> > Hi,
> >
> > I'm working on a Maven plugin and I'd like to check whether a parameter
> for
> > a Mojo has been explicitly set by the user (via POM), or it contains the
> > default value. Is there a way to do this?
>
> Maybe I misunderstand a thing but why do you need to distinguish between
> those two? Isn't that why defaultValue exist?
>
> Kind regards
> Karl Heinz Marbaise
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
> For additional commands, e-mail: dev-help@maven.apache.org
>
>

Re: Check if parameter is explicitly set

Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi,

On 13/04/17 02:05, Andr�s Kerekes wrote:
> Hi,
>
> I'm working on a Maven plugin and I'd like to check whether a parameter for
> a Mojo has been explicitly set by the user (via POM), or it contains the
> default value. Is there a way to do this?

Maybe I misunderstand a thing but why do you need to distinguish between 
those two? Isn't that why defaultValue exist?

Kind regards
Karl Heinz Marbaise

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Check if parameter is explicitly set

Posted by Tibor Digana <ti...@apache.org>.
Try to put a break point to setter but you won't distinguish between user
and default value.

On Thu, Apr 13, 2017 at 2:06 AM, András Kerekes [via Maven] <
ml-node+s40175n5905937h87@n5.nabble.com> wrote:

> Hi,
>
> I'm working on a Maven plugin and I'd like to check whether a parameter
> for
> a Mojo has been explicitly set by the user (via POM), or it contains the
> default value. Is there a way to do this?
>
> Thanks,
>  András
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
> http://maven.40175.n5.nabble.com/Check-if-parameter-is-
> explicitly-set-tp5905937.html
> To start a new topic under Maven Developers, email
> ml-node+s40175n142166h86@n5.nabble.com
> To unsubscribe from Maven Developers, click here
> <http://maven.40175.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=142166&code=dGlib3JkaWdhbmFAYXBhY2hlLm9yZ3wxNDIxNjZ8LTI4OTQ5MjEwMg==>
> .
> NAML
> <http://maven.40175.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://maven.40175.n5.nabble.com/Check-if-parameter-is-explicitly-set-tp5905937p5905947.html
Sent from the Maven Developers mailing list archive at Nabble.com.