rewrite
rewrite copied to clipboard
Groovy Parser Error breaks custom gradle task
Here's a minimal project that reproduces the issue: https://github.com/edward3h/gradle_rewrite_bug
I have a custom task defined in build.gradle and ran the org.openrewrite.java.cleanup.Cleanup recipe. It changes the custom task in a way that breaks Gradle build.
diff --git a/build.gradle b/build.gradle
index 05f1221..e4ef94f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -27,7 +27,7 @@ task install {
dependsOn installDist
doLast {
ant.mkdir(dir: "${rootDir}/bin")
- ant.symlink(resource: "${(installDist.outputs.files as List).first()}/bin/${application.applicationName}", link: "${rootDir}/bin/${application.applicationName}")
+ ant.symlink(resource: "${(installDist.outputs.files as List)installDist.outputs}bin${application////}bin${application.filesfirst}/bin/",link, link: "${rootDir}/bin/${application.applicationName}")
}
}
@@ -39,4 +39,4 @@ clean.dependsOn cleanBin
rewrite {
activeRecipe("org.openrewrite.java.cleanup.Cleanup")
-}
\ No newline at end of file
+}
Workaround: exclude build.gradle from rewrite
diff --git a/build.gradle b/build.gradle
index 05f1221..f488ca0 100644
--- a/build.gradle
+++ b/build.gradle
@@ -39,4 +39,5 @@ clean.dependsOn cleanBin
rewrite {
activeRecipe("org.openrewrite.java.cleanup.Cleanup")
-}
\ No newline at end of file
+ exclusion('**/build.gradle')
+}
@edward3h, thanks so much for the sample project!
this looks like a groovy parsing error, its showing up in the EmptyNewlineAtEndOfFile recipe because it changes the file. check out the TypeCast expression below:
