openrewrite / rewrite

Automated mass refactoring of source code.
https://docs.openrewrite.org
Apache License 2.0
2.03k stars 300 forks source link

Failed to parse pom: Cannot construct instance of "org.openrewrite.maven.tree.ProfileActivation" #1427 #1487

Closed josemariavillar closed 2 years ago

josemariavillar commented 2 years ago

Good afternoon,

Unfortunately the problem I reported in issue 1427 has not been solved, I have validated the solution with version 4.21.0-SNAPSHOT of the rewrite-maven-plugin and the same error still occurs.

[INFO] --- rewrite-maven-plugin:4.21.0-SNAPSHOT:dryRun (default-cli) @ test-project ---
[INFO] Using active recipe(s) [com.yourorg.UpgradePom]
[INFO] Using active styles(s) []
[INFO] Validating active recipes...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  27.037 s
[INFO] Finished at: 2022-03-22T13:26:56+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:4.21.0-SNAPSHOT:dryRun (default-cli) on project test-project: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.21.0-SNAPSHOT:dryRun
failed: Failed to parse pom: Cannot construct instance of `org.openrewrite.maven.tree.ProfileActivation` (although at least one Creator exists): no default no-arguments constructor found
[ERROR]  at [Source: (FileInputStream); line: 4972, column: 10] (through reference chain: org.openrewrite.maven.internal.RawPom["profiles"]->org.openrewrite.maven.internal.RawPom$Profiles["profile"]->java.util.ArrayList[6]->org.open
rewrite.maven.internal.RawPom$Profile["activation"])
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

You can reproduce the error in the following attached example:

https://github.com/josemariavillar/test_project/tree/failed_parse_pom

tkvangorder commented 2 years ago

@josemariavillar You are very thorough, thank you. 8)

We had fixed an issue where the activation was expressed as an empty tag:

                        <profile>
                              <id>repo-incode-work</id>
                              <activation/>
                            </profile>

However, this fix did not cover the edge case when there is an opening and closing activation tag:

                        <profile>
                              <id>repo-incode-work</id>
                              <activation>
                              </activation>
                            </profile>

🤷

This has now been corrected, I will also open an issue with the Jackson team, as there really should be no difference between the two.

josemariavillar commented 2 years ago

@tkvangorder I have tried it and it works, thank you very much!