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

maven4 regression bug: script2.groovy: 1: unexpected char: '\' @ line 1, column 40. #34

Open
hohwille opened this issue Dec 9, 2024 · 2 comments

Comments

@hohwille
Copy link

hohwille commented Dec 9, 2024

I have tested maven4 update (4.0.0-rc1) and found that groovy-maven-plugin stops working after this update:

Execution default of goal org.codehaus.gmaven:groovy-maven-plugin:2.1.1:execute failed: startup failed:
[ERROR] script2.groovy: 1: unexpected char: '\' @ line 1, column 40.
[ERROR]    def parts = "1.5.12.0-SNAPSHOT".split("\.")
[ERROR]                                           ^
[ERROR]

With maven 3.9 (e.g. 3.9.6 or 3.9.9) this used to work fine.
Configuration:

<plugin>
  <groupId>org.codehaus.gmaven</groupId>
  <artifactId>groovy-maven-plugin</artifactId>
  <executions>
    <execution>
      <phase>generate-resources</phase>
      <goals>
        <goal>execute</goal>
      </goals>
      <configuration>
        <source><![CDATA[
          def versionSegments = "${project.version}".split("\\.")
          ...
          ]]>
        </source>
      </configuration>
    </execution>
  </executions>
</plugin>

Can you confirm this bug? Is this really a bug of groovy-maven-plugin or is there a general bug in maven 4.0 resolving backslashes in POM (CDATA sections)?

p.s.: Using double quotes vs. single quotes for the regex string literal does not make any difference. It works with 3.9 and fails with 4.0.

@jdillon
Copy link
Member

jdillon commented Dec 10, 2024

I haven't been able to verify, but it seems highly likely that the CDATA handling in Maven 4 is problematic. Though do you see the same behavior with w/o CDATA, maybe CDATA is not the real issue here, the issue is that its attempting to do string escaping when its interpolating?

@hohwille
Copy link
Author

I haven't been able to verify, but it seems highly likely that the CDATA handling in Maven 4 is problematic. Though do you see the same behavior with w/o CDATA, maybe CDATA is not the real issue here, the issue is that its attempting to do string escaping when its interpolating?

Thanks for your analysis and feedback.
I assume you are correct and this is a bug in maven 4 and not in your plugin. See also:
https://issues.apache.org/jira/browse/MANTRUN-243

I now created https://issues.apache.org/jira/browse/MNG-8456 and IMHO you can close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants