Skip to content

Incompatibility with Maven Polyglot leads to ParseError #649

@laeubi

Description

@laeubi

What version of OpenRewrite are you using?

I am using

  • Maven plugin v5.9.1

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a multi module project.

<plugins>
	<plugin>
		<groupId>org.openrewrite.maven</groupId>
		<artifactId>rewrite-maven-plugin</artifactId>
		<version>5.9.1</version>
		<configuration>
			<activeRecipes>
				<recipe>org.eclipse.ui.PlatformUISetHelp</recipe>
			</activeRecipes>
		</configuration>
	</plugin>
</plugins>

The project is hosted here:
https://github.com/eclipse-platform/eclipse.platform

What is the smallest, simplest way to reproduce the problem?

I added the above snippet to the root pom.xml
I created a rewrite.yml like this:

---
type: specs.openrewrite.org/v1beta/recipe
name: org.eclipse.ui.PlatformUISetHelp
displayName: Replace calls of PlatformUI.getWorkbench().getHelpSystem() with PlatformUI.getWorkbench().getHelpSystem().setHelp(...) with e4 safe PlatformUI.setHelp(...) variant
recipeList:
  - org.openrewrite.java.SimplifyMethodChain:
      methodPatternChain: ['org.eclipse.ui.PlatformUI getWorkbench()', 'org.eclipse.ui.IWorkbench getHelpSystem()', 'org.eclipse.ui.help.IWorkbenchHelpSystem setHelp(..)']
      newMethodName: setHelp
      matchOverrides: false

then I go to debug/org.eclipse.debug.ui in the project and call mvn rewrite:run

What is the full stack trace of any errors you encountered?

[INFO] --- rewrite:5.9.1:run (default-cli) @ org.eclipse.debug.ui ---
[INFO] Using active recipe(s) [org.eclipse.ui.PlatformUISetHelp]
[INFO] Using active styles(s) []
[INFO] Validating active recipes...
[INFO] Project [[bundle] Debug UI] Resolving Poms...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  21.543 s (Wall Clock)
[INFO] Finished at: 2023-11-01T17:27:01+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:5.9.1:run (default-cli) on project org.eclipse.debug.ui: A type incompatibility occurred while executing org.openrewrite.maven:rewrite-maven-plugin:5.9.1:run: class org.openrewrite.tree.ParseError cannot be cast to class org.openrewrite.xml.tree.Xml$Document (org.openrewrite.tree.ParseError and org.openrewrite.xml.tree.Xml$Document are in unnamed module of loader org.codehaus.plexus.classworlds.realm.ClassRealm @75c258f9)

Are you interested in contributing a fix to OpenRewrite?

This might be because the project uses a polyglot build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions