rewrite-docs
rewrite-docs copied to clipboard
Running Rewrite on a Gradle Kotlin project without modifying the build
I took a look at this, but I'm not that familiar with Gradle or Kotlin 😅 . I was able to resolve some of the issues converting it to Kotlin -- but I'm struggling to figure out the syntax for how to apply the rewrite plugin.
I keep getting an Unresolved reference: rewrite error when I try and run gradle --init-script init.gradle.kts.
Things I've tried include:
rootProject {
apply<org.openrewrite.gradle.RewritePlugin>()
dependencies {
rewrite("org.openrewrite:rewrite-java")
}
rewrite {
activeRecipe("org.openrewrite.FindSpringUses")
}
}
rootProject {
apply {
plugin("org.openrewrite.gradle.RewritePlugin")
}
dependencies {
rewrite("org.openrewrite:rewrite-java")
}
rewrite {
activeRecipe("org.openrewrite.FindSpringUses")
}
}
rootProject {
plugins.apply("org.openrewrite.gradle.RewritePlugin")
dependencies {
rewrite("org.openrewrite:rewrite-java")
}
rewrite {
activeRecipe("org.openrewrite.FindSpringUses")
}
}
If anyone has figured this out please let me know :D
Also - for anyone looking at this in the future, Kotlin expects a url like this for the first part of the initscript as far as I can tell:
initscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2")
}
}
dependencies {
classpath("org.openrewrite:plugin:latest.release")
}
}