openrewrite / rewrite-gradle-plugin

OpenRewrite's Gradle plugin.
Apache License 2.0
65 stars 40 forks source link

Add `rewrite-gradle-plugin` to `rewrite-recipe-bom` #123

Open jkschneider opened 2 years ago

jkschneider commented 2 years ago

Before doing this, also publish rewrite-gradle-plugin to maven central so that corp environment procurement processes don't need to request against Gradle plugin portal.

shanman190 commented 2 years ago

I would think that rewrite-gradle-plugin would be a consumer of rewrite-recipe-bom. That would make it a bit awkward, I would think, to then make it something aligned by the bom.

escardin commented 2 years ago

We declare all our dependencies and versions in a kotlin file we then reference everywhere else. We can specify the gradle plugin version independently, but because the versions of rewrite and the plugin don't match, it becomes extra work to look everything up and ensure everything is compatible. Using a single BOM makes it easy for us to ensure compatibilty.

shanman190 commented 2 years ago

That definitely makes sense. As of right now, I think that rewrite has cut it down to 2 versions (from a lot): the rewrite-recipes-bom and rewrite-gradle-plugin.

rewrite-recipes-bom provides version alignment for rewrite proper and all recipe jars. Then rewrite-gradle-plugin which has become mostly independent.

For this to work as described, you'd have to use the platform bom in two places. The first would be for the plugin classpath itself via buildscript.dependencies, buildSrc, an included build, or an external plugin. The second would be in the rewriteDependencies configuration in the project.dependencies.

As a counter example, the below is possible today with the latest versions -- using just the two dependency versions as described previously -- and would be:

plugins {
    id("org.openrewrite.rewrite") version "5.24.0"
}

dependencies {
    "rewrite"(platform("org.openrewrite.recipe:rewrite-recipe-bom:1.5.0"))
    "rewrite"("org.openrewrite.recipe:rewrite-testing-frameworks")
    // remaining additional recipe jars as desired
}
escardin commented 2 years ago

Yep we already use buildscript dependencies, but without the jar being published to central I think it was an issue. I don't mind repeating the reference in code if I have peace of mind that everything aligns properly. It's also not the end of the world to keep the plugin separate, mostly just a hassle to have to track down both.