Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

regex-property goal doesn't interpret <replacement> correctly, corrupting output #155

Open
garretwilson opened this issue Oct 28, 2022 · 0 comments
Labels

Comments

@garretwilson
Copy link

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.

@github-actions github-actions bot added the Stale label Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant