build-helper-maven-plugin
build-helper-maven-plugin copied to clipboard
`regex-property` goal doesn't interpret `<replacement>` correctly, corrupting output
I'm using org.codehaus.mojo:build-helper-maven-plugin:3.3.0
on Windows.
Let's say I want to use the regex-property
goal to replace some value with the build directory path:
<execution>
<id>test</id>
<phase>validate</phase>
<goals>
<goal>regex-property</goal>
</goals>
<configuration>
<name>bar</name>
<value>foo</value>
<regex>.*</regex>
<replacement>${project.build.directory}</replacement>
<failIfNoMatch>false</failIfNoMatch>
</configuration>
</execution>
I'm on Windows, and my ${project.build.directory}
happens to be something like C:\projects\foobar\target
.
Expected bar
: C:\projects\foobar\target
Actual bar
: C:projectsfoobartargetC:projectsfoobartarget
Not only has Build Helper Plugin removed all the backslashes, it has strangely duplicated the output!
I can only make a wild guess why this is happening. Perhaps the plugin is recursively evaluating the result until there are no unevaluated expressions. But the <replacement>
should not be evaluated as a regular expression; it should be evaluated as a normal Maven interpolation string (i.e. substituting any {$variable}
). I don't believe backslashes have any significance in normal interpolations strings, do they?
Why the output is being duplicated I have no idea.