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

Compilation errors on "Running Rewrite without build tool plugins" #244

Closed
timtebeek opened this issue Nov 10, 2023 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@timtebeek
Copy link
Contributor

As reported on https://stackoverflow.com/questions/77460250/how-to-get-openrewrite-running-without-build-tool-plugins-i-e-standalone

The description at "Running Rewrite without build tool plugins" suggests that OpenRewrite can be run on any Java project without requiring that project being a Maven or Gradle project. However, I could not manage to get the described class `RunRewriteManually` to compile properly.

When building "as is" I get

.../src/main/java/com/wamas/core/rewrite/Rewrite.java:49: error: incompatible types: Stream<SourceFile> cannot be converted to List<CompilationUnit>
        List<J.CompilationUnit> cus = javaParser.parse(sourcePaths, projectDir, ctx);
                                                      ^
.../src/main/java/com/wamas/core/rewrite/Rewrite.java:53: error: incompatible types: List<CompilationUnit> cannot be converted to LargeSourceSet
        List<Result> results = recipe.run(cus, ctx).getResults();
                                          ^

Adding `.collect(Collectors.toList()` to the first statement doesn't improve it because the types don't match:

/src/main/java/com/wamas/core/rewrite/Rewrite.java:50: error: incompatible types: inference variable T has incompatible bounds
        List<J.CompilationUnit> cus = javaParser.parse(sourcePaths, projectDir, ctx).collect(Collectors.toList());
                                                                                            ^
    equality constraints: CompilationUnit
    lower bounds: SourceFile
  where T is a type-variable:
    T extends Object declared in method <T>toList()

This second case is more a Java than an OpenRewrite problem, but I just don't get the error cause.
@timtebeek timtebeek added the bug Something isn't working label Nov 10, 2023
@timtebeek
Copy link
Contributor Author

Picked up in

As indicated there we recommend folks use the Moderne CLI, especially when they do not use Maven nor Gradle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

1 participant