build-helper-maven-plugin icon indicating copy to clipboard operation
build-helper-maven-plugin copied to clipboard

Enhancement: Apply multiple regex replacements to a single property

Open JonathanLennox opened this issue 5 years ago • 2 comments

I'd like to be able to define a property by applying multiple possible regex replacements to a value.

Specifically, I'd like to be able to, in Maven, canonicalize the Java "arch" parameter in the same way as JNA does in its Platform.getNativeLibraryResourcePrefix(), as follows:

${os.arch}: amd64|x86_64 -> x86-64 i[3-6]86 -> x86 powerpc -> ppc arm.* -> arm

(If there's already a way to do this with the existing regex-properties rule, it's not clear to me how to do it; consider this a doc enhancement request if so.)

JonathanLennox avatar Aug 08 '19 13:08 JonathanLennox

This would be nice to have, i agree

tehhowch avatar Oct 19 '23 16:10 tehhowch

As I understand you want to have a multiple regex value in regex-property goal.

It should be not more complicated to implements.

At first in: https://github.com/mojohaus/build-helper-maven-plugin/blob/master/src/main/java/org/codehaus/mojo/buildhelper/RegexPropertyMojo.java

try to change:

    @Parameter(required = true)
    private String regex;

to

    @Parameter(required = true)
    private Set<String> regex;

and follow required changing in the rest code until project will build and all ITs pass.

simply test

mvn verify

and with ITs

mvn verify -P run-its

slawekjaranowski avatar May 16 '24 15:05 slawekjaranowski