openrewrite / rewrite-gradle-plugin

OpenRewrite's Gradle plugin.
Apache License 2.0
60 stars 37 forks source link

Parse function bug #302

Closed k3code06 closed 5 months ago

k3code06 commented 5 months ago

What version of OpenRewrite are you using?

I am using



## Are you interested in [contributing a fix to OpenRewrite](https://github.com/openrewrite/.github/blob/main/CONTRIBUTING.md#contributing-fixes)?
<!-- Indicate if this is something you would like to work on, and how we can best support you in doing so. -->
shanman190 commented 5 months ago

So this appears like you are trying to mix old and new rewrite and rewrite-gradle-plugin. rewrite:8.x and rewrite-gradle-plugin:6.x make use of java.util.Stream for being able to process the data set while your variable declaration is wanting a List which is only valid for rewrite:7.x and rewrite-gradle-plugin:5.x.

k3code06 commented 5 months ago

I am using the latest version of rewrite and rewrite-gradle-plugin. The latest version of rewrite uses Stream while the rewrite-gradle-plugin uses List . This inconsistency leads to build failure. I am using both of them as dependency to override the RewritePlugin to get the list of all the recipes and then some modifications.

shanman190 commented 5 months ago

I think you might have misunderstood my statement, so I'll word it a different way.

rewrite rewrite-gradle-plugin Implementation
7.x 5.x java.util.List
8.x 6.x java.util.Stream

The rewrite-gradle-plugin repository in it's current state depends upon rewrite 8.x and uses java.util.Stream throughout the project. More specifically, nowhere in the 6.x releases does the result of jp.parse(..) be assigned to a java.util.List. You can see the current implementation here which as well shows the only invocation of jp.parse(..) within the current DefaultProjectParser. If you notice, the call is within a flatMap(..) which furthermore requires the return type to be java.util.Stream. https://github.com/openrewrite/rewrite-gradle-plugin/blob/b0cf73432d948d10bfe29007ae613bdb466da622/plugin/src/main/java/org/openrewrite/gradle/isolated/DefaultProjectParser.java#L727

shanman190 commented 5 months ago

@AnkitaJain06, this appears to be a dependency version bug within your extension and more of a question here in the correct usage of this plugin alongside the rewrite repository. As it seems like I've answered your question now, I'm going to go ahead and close out this ticket now. If there's anything else feel free to open a new issue or reach out in the OpenRewrite Slack workspace questions channel.