How to interpolate a value in a Maven plugin

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

How to interpolate a value in a Maven plugin

jochen-2
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to interpolate a value in a Maven plugin

Karl Heinz Marbaise-3
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to interpolate a value in a Maven plugin

jochen-2
On Wed, Dec 26, 2018 at 10:54 PM Karl Heinz Marbaise <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to interpolate a value in a Maven plugin

Karl Heinz Marbaise-3
Hi Jochen,
On 26/12/18 23:27, Jochen Wiedmann wrote:

> On Wed, Dec 26, 2018 at 10:54 PM Karl Heinz Marbaise <[hidden email]> 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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to interpolate a value in a Maven plugin

Robert Scholte-8
In reply to this post by jochen-2
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  
<[hidden email]> 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: [hidden email]
> For additional commands, e-mail: [hidden email]

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

Reply | Threaded
Open this post in threaded view
|

Re: How to interpolate a value in a Maven plugin

Maxim Solodovnik
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 <[hidden email]> 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
> <[hidden email]> 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: [hidden email]
> > For additional commands, e-mail: [hidden email]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

--
WBR
Maxim aka solomax
Reply | Threaded
Open this post in threaded view
|

Re: How to interpolate a value in a Maven plugin

jochen-2
In reply to this post by Robert Scholte-8
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 <[hidden email]> 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
> <[hidden email]> 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: [hidden email]
> > For additional commands, e-mail: [hidden email]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

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