You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by or...@io7m.com on 2017/01/03 18:25:51 UTC

Slightly more advanced resource filtering (templating)?

Hello.

I have a small project that contains a plugin for Blender[0]. Plugins
in Blender are Python files that must contain a hash value at the top
of the file containing version information. The version information has
to be numeric constants as Blender actually parses this data rather
than evaluating it in an interpreter.

https://github.com/io7m/smf/blob/develop/io7m-smfj-blender/src/main/resources/__init__.py

Right now, I'm having to remember to manually insert the right version
number each time I increment the Maven version. I'd much rather filter
the Python source file as a resource instead, but unfortunately I'd
need to transform the Maven version string:

  2.3.1 → (2, 3, 1)

Is there an existing plugin that can do this? I assume that it'd be
some sort of templating engine. Unfortunately, all of the search
results for that seem to be in regards to the site plugin.

M

[0] http://blender.org

Re: Slightly more advanced resource filtering (templating)?

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

have you taken a look at the build-helper-maven-plugin which has a goal 
parse-version which will result in appropriate properties which than can 
be used to achieve what you like.


Kind regards
Karl Heinz Marbaise

http://www.mojohaus.org/build-helper-maven-plugin/parse-version-mojo.html


On 03/01/17 19:25, org.apache.maven.user@io7m.com wrote:
> Hello.
>
> I have a small project that contains a plugin for Blender[0]. Plugins
> in Blender are Python files that must contain a hash value at the top
> of the file containing version information. The version information has
> to be numeric constants as Blender actually parses this data rather
> than evaluating it in an interpreter.
>
> https://github.com/io7m/smf/blob/develop/io7m-smfj-blender/src/main/resources/__init__.py
>
> Right now, I'm having to remember to manually insert the right version
> number each time I increment the Maven version. I'd much rather filter
> the Python source file as a resource instead, but unfortunately I'd
> need to transform the Maven version string:
>
>   2.3.1 \u2192 (2, 3, 1)
>
> Is there an existing plugin that can do this? I assume that it'd be
> some sort of templating engine. Unfortunately, all of the search
> results for that seem to be in regards to the site plugin.
>
> M
>
> [0] http://blender.org
>


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


Re: Slightly more advanced resource filtering (templating)?

Posted by Curtis Rueden <ct...@wisc.edu>.
Hi,

In addition to the suggestion of others to use parse-version, the
build-helper-maven-plugin also has the regex-property goal, which lets you
assign a property based on a regex. Here is an example:

<execution>
  <id>sanitize-version</id>
  <goals>
    <goal>regex-property</goal>
  </goals>
  <configuration>
    <name>sanitizedVersion</name>
    <value>${project.version}</value>
    <regex>^([0-9]+)\.([0-9]+)\.([0-9]+).*$</regex>
    <replacement>$1.$2.$3</replacement>
    <failIfNoMatch>false</failIfNoMatch>
  </configuration>
</execution>

Regards,
Curtis

--
Curtis Rueden
LOCI software architect - http://loci.wisc.edu/software
ImageJ2 lead, Fiji maintainer - http://imagej.net/User:Rueden


On Tue, Jan 3, 2017 at 12:32 PM, Guillaume Boué <gu...@orange.fr>
wrote:

> Hi,
>
> It sounds like you're looking for the parse-version goal of the
> build-helper-maven-plugin: http://www.mojohaus.org/build-
> helper-maven-plugin/parse-version-mojo.html. It can decompose the project
> version into several Maven properties. There is an example of usage here
> http://www.mojohaus.org/build-helper-maven-plugin/usage.html
> #Access_the_parsed_components_of_a_project_version.
>
> Guillaume
>
>
>
> Le 03/01/2017 à 19:25, org.apache.maven.user@io7m.com a écrit :
>
>> Hello.
>>
>> I have a small project that contains a plugin for Blender[0]. Plugins
>> in Blender are Python files that must contain a hash value at the top
>> of the file containing version information. The version information has
>> to be numeric constants as Blender actually parses this data rather
>> than evaluating it in an interpreter.
>>
>> https://github.com/io7m/smf/blob/develop/io7m-smfj-blender/
>> src/main/resources/__init__.py
>>
>> Right now, I'm having to remember to manually insert the right version
>> number each time I increment the Maven version. I'd much rather filter
>> the Python source file as a resource instead, but unfortunately I'd
>> need to transform the Maven version string:
>>
>>    2.3.1 → (2, 3, 1)
>>
>> Is there an existing plugin that can do this? I assume that it'd be
>> some sort of templating engine. Unfortunately, all of the search
>> results for that seem to be in regards to the site plugin.
>>
>> M
>>
>> [0] http://blender.org
>>
>
>
> ---
> L'absence de virus dans ce courrier électronique a été vérifiée par le
> logiciel antivirus Avast.
> https://www.avast.com/antivirus
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: Slightly more advanced resource filtering (templating)?

Posted by or...@io7m.com.
On 2017-01-03T19:32:59 +0100
Guillaume Boué <gu...@orange.fr> wrote:

> It sounds like you're looking for the parse-version goal of the 
> build-helper-maven-plugin: 

On 2017-01-03T19:36:16 +0100
Karl Heinz Marbaise <kh...@gmx.de> wrote:
> Hi,
> 
> have you taken a look at the build-helper-maven-plugin

On 2017-01-03T12:45:19 -0600
Curtis Rueden <ct...@wisc.edu> wrote:

> Hi,
> 
> In addition to the suggestion of others to use parse-version...

Thanks to all of you!

build-helper-maven-plugin looks to be exactly what I need.

M

Re: Slightly more advanced resource filtering (templating)?

Posted by Guillaume Boué <gu...@orange.fr>.
Hi,

It sounds like you're looking for the parse-version goal of the 
build-helper-maven-plugin: 
http://www.mojohaus.org/build-helper-maven-plugin/parse-version-mojo.html. 
It can decompose the project version into several Maven properties. 
There is an example of usage here 
http://www.mojohaus.org/build-helper-maven-plugin/usage.html#Access_the_parsed_components_of_a_project_version.

Guillaume


Le 03/01/2017 � 19:25, org.apache.maven.user@io7m.com a �crit :
> Hello.
>
> I have a small project that contains a plugin for Blender[0]. Plugins
> in Blender are Python files that must contain a hash value at the top
> of the file containing version information. The version information has
> to be numeric constants as Blender actually parses this data rather
> than evaluating it in an interpreter.
>
> https://github.com/io7m/smf/blob/develop/io7m-smfj-blender/src/main/resources/__init__.py
>
> Right now, I'm having to remember to manually insert the right version
> number each time I increment the Maven version. I'd much rather filter
> the Python source file as a resource instead, but unfortunately I'd
> need to transform the Maven version string:
>
>    2.3.1 \u2192 (2, 3, 1)
>
> Is there an existing plugin that can do this? I assume that it'd be
> some sort of templating engine. Unfortunately, all of the search
> results for that seem to be in regards to the site plugin.
>
> M
>
> [0] http://blender.org


---
L'absence de virus dans ce courrier �lectronique a �t� v�rifi�e par le logiciel antivirus Avast.
https://www.avast.com/antivirus


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