Description
What version of OpenRewrite are you using?
org.openrewrite.rewrite.gradle.plugin:6.4.3
How are you running OpenRewrite?
./gradlew rewriteDiscover
The are four issues:
- Documentation says
rootDir
is the default location: https://docs.openrewrite.org/reference/gradle-plugin-configuration#configuring-the-rewrite-dsl
// These are default values, shown for example. It isn't necessary to supply these values manually:
configFile = project.getRootProject().file("rewrite.yml")
In practice, the default location is projectDir/rewrite.yml
:
-
I would expect OpenRewrite to fail when the user provides a non-existent style. It took me a while to realize that my
rewrite.yml
was not loaded at all -
A better alternative to
File configFile
would be https://docs.gradle.org/current/dsl/org.gradle.api.resources.TextResourceFactory.html (since Gradle 2.2) as it would reduce IO during the configuration time. In other words, if user does not execute OpenRewrite tasks, users won't need executing IO forrewrite.yml
. See https://github.com/gradle/gradle/blob/bb4604586434a1c781ff3996ffaff66d079cb43c/platforms/jvm/code-quality/src/main/groovy/org/gradle/api/plugins/quality/CheckstyleExtension.java#L39 -
The documentation should probably prefer Kotlin DSL syntax rather than Java DSL as people rarely use Gradle Plugins from Java.
In other wordsrootProject
should be preferred overgetRootProject()
What is the smallest, simplest way to reproduce the problem?
Add the following rewrite.yml
to the root dir
---
# See reference at https://docs.openrewrite.org/concepts-explanations/styles#declarative-styles
type: specs.openrewrite.org/v1beta/style
name: io.github.pgjdbc.style.Style
styleConfigs:
- org.openrewrite.java.style.TabsAndIndentsStyle:
# See https://github.com/openrewrite/rewrite/issues/3666
# For now, it should be the same as in .editorconfig
useTabCharacter: false
tabSize: 2
indentSize: 2
continuationIndent: 4
- org.openrewrite.java.style.SpacesStyle:
# See https://github.com/openrewrite/rewrite/blob/1d0aeec11e2d7f239f2f656bfd964b17ca8e4d17/rewrite-java/src/main/java/org/openrewrite/java/style/SpacesStyle.java#L26C14-L26C25
other:
afterForSemicolon: true
Configure Gradle plugin:
plugins {
id("org.openrewrite.rewrite")
}
dependencies {
rewrite(platform("org.openrewrite.recipe:rewrite-recipe-bom:2.4.1"))
rewrite("org.openrewrite.recipe:rewrite-static-analysis")
}
rewrite {
activeStyle("io.github.pgjdbc.style.Style")
activeRecipe("org.openrewrite.java.OrderImports")
activeRecipe("org.openrewrite.staticanalysis.MissingOverrideAnnotation")
}
What did you see instead?
Available Styles:
org.openrewrite.java.IntelliJ
org.openrewrite.kotlin.IntelliJ
com.netflix.genie.Style
org.openrewrite.java.SpringFormat
com.netflix.eureka.Style
org.openrewrite.java.GoogleJavaFormat
What is the full stack trace of any errors you encountered?
Available Styles:
does not list io.github.pgjdbc.style.Style
Are you interested in contributing a fix to OpenRewrite?
May be
Metadata
Metadata
Assignees
Type
Projects
Status