You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jochen Wiedmann <jo...@gmail.com> on 2018/12/26 21:36:32 UTC

How to interpolate a value in a Maven plugin

Hi,

I have written a Maven plugin, which must interpret values like
${project.artifactId}, and the like.
My first attempt was to use
project.getProperties().get("project.artifactId"), but that seems
to work only for the values, which are configured in the POM's
property section. So, what would be a better approach?

Thanks,

Jochen

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


Re: How to interpolate a value in a Maven plugin

Posted by Maxim Solodovnik <so...@gmail.com>.
I was able to perform some properties manipulation with inline groovy script
similar to this answer: https://stackoverflow.com/a/35731118/3571661

On Thu, 27 Dec 2018 at 15:54, Robert Scholte <rf...@apache.org> wrote:

> Hi,
>
> try to find a plugin which does similar things and have a look at its
> sources.
> In this case help:evaluate[1]
>
> thanks,
> Robert
>
> [1] https://maven.apache.org/plugins/maven-help-plugin/evaluate-mojo.html
>
> On Wed, 26 Dec 2018 22:36:32 +0100, Jochen Wiedmann
> <jo...@gmail.com> wrote:
>
> > Hi,
> >
> > I have written a Maven plugin, which must interpret values like
> > ${project.artifactId}, and the like.
> > My first attempt was to use
> > project.getProperties().get("project.artifactId"), but that seems
> > to work only for the values, which are configured in the POM's
> > property section. So, what would be a better approach?
> >
> > Thanks,
> >
> > Jochen
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

-- 
WBR
Maxim aka solomax

Re: How to interpolate a value in a Maven plugin

Posted by Jochen Wiedmann <jo...@gmail.com>.
Thanks, Robert,

the reference to the PluginParameterExpressionEvaluator in the
maven-help-plugin was what I need. It's a bit clumsy to obtain, but
does exactly what I want.

Jochen

On Thu, Dec 27, 2018 at 9:55 AM Robert Scholte <rf...@apache.org> wrote:
>
> Hi,
>
> try to find a plugin which does similar things and have a look at its
> sources.
> In this case help:evaluate[1]
>
> thanks,
> Robert
>
> [1] https://maven.apache.org/plugins/maven-help-plugin/evaluate-mojo.html
>
> On Wed, 26 Dec 2018 22:36:32 +0100, Jochen Wiedmann
> <jo...@gmail.com> wrote:
>
> > Hi,
> >
> > I have written a Maven plugin, which must interpret values like
> > ${project.artifactId}, and the like.
> > My first attempt was to use
> > project.getProperties().get("project.artifactId"), but that seems
> > to work only for the values, which are configured in the POM's
> > property section. So, what would be a better approach?
> >
> > Thanks,
> >
> > Jochen
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> > For additional commands, e-mail: users-help@maven.apache.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>

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


Re: How to interpolate a value in a Maven plugin

Posted by Robert Scholte <rf...@apache.org>.
Hi,

try to find a plugin which does similar things and have a look at its  
sources.
In this case help:evaluate[1]

thanks,
Robert

[1] https://maven.apache.org/plugins/maven-help-plugin/evaluate-mojo.html

On Wed, 26 Dec 2018 22:36:32 +0100, Jochen Wiedmann  
<jo...@gmail.com> wrote:

> Hi,
>
> I have written a Maven plugin, which must interpret values like
> ${project.artifactId}, and the like.
> My first attempt was to use
> project.getProperties().get("project.artifactId"), but that seems
> to work only for the values, which are configured in the POM's
> property section. So, what would be a better approach?
>
> Thanks,
>
> Jochen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org

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


Re: How to interpolate a value in a Maven plugin

Posted by Karl Heinz Marbaise <kh...@gmx.de>.
Hi Jochen,
On 26/12/18 23:27, Jochen Wiedmann wrote:
> On Wed, Dec 26, 2018 at 10:54 PM Karl Heinz Marbaise <kh...@gmx.de> wrote:
> 
>>> I have written a Maven plugin, which must interpret values like
>>> ${project.artifactId}, and the like.
>>
>> Where exactly do you use them ? Are injected as parameters ?
> 
> No, they are basically snippets, which have been extracted from
> external files. Hard to describe. Please assume, that I can't use the
> standard filtering, because I've got to operate on strings, not files.
> (Think of values in a hash map.)

I would suggest to take a look at a more higher level:

http://maven.apache.org/shared/maven-filtering/

If you need more low level than take a look here:

https://codehaus-plexus.github.io/plexus-interpolation/
https://github.com/codehaus-plexus/plexus-interpolation

Kind regards
Karl Heinz Marbaise



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


Re: How to interpolate a value in a Maven plugin

Posted by Jochen Wiedmann <jo...@gmail.com>.
On Wed, Dec 26, 2018 at 10:54 PM Karl Heinz Marbaise <kh...@gmx.de> wrote:

> > I have written a Maven plugin, which must interpret values like
> > ${project.artifactId}, and the like.
>
> Where exactly do you use them ? Are injected as parameters ?

No, they are basically snippets, which have been extracted from
external files. Hard to describe. Please assume, that I can't use the
standard filtering, because I've got to operate on strings, not files.
(Think of values in a hash map.)

> Can you give a full example for that ? Or a link to the project?

Sorry, not open source, thus not available.

Thanks,

Jochen

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


Re: How to interpolate a value in a Maven plugin

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

On 26/12/18 22:36, Jochen Wiedmann wrote:
> Hi,
> 
> I have written a Maven plugin, which must interpret values like
> ${project.artifactId}, and the like.

Where exactly do you use them ? Are injected as parameters ?
> My first attempt was to use
> project.getProperties().get("project.artifactId"), but that seems
> to work only for the values, which are configured in the POM's
> property section. So, what would be a better approach?

Can you give a full example for that ? Or a link to the project?

Kind regards
Karl Heinz Marbaise

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