-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation regarding rewrite.yml is misleading: documentation says the default location is rootDir while the actual default is projectDir #241
Comments
Thanks for the detailed report! Just to be sure: are you running from the root of the repository? Or is there a different folder involved? Appreciate your suggestions as well, for better API use such as 3, proper validation and warning as mentioned in 2, and the small tweaks to the documentation to better match reality, or have the plugin match the docs (and likely the Maven plugin and Moderne CLI). If there's anything you would like to pick up out of those items that'd be much appreciated; just let us know which ones you think are a good fit to contribute, and which other ones you'd like us to take a look at. Thanks again! |
In Gradle model, it should not matter. In multi-project build, every project has its directory, so by default |
Could you please clarify what you mean by "use API 3"? |
There I meant your suggestion outlined above as the third bullet point to switch from
|
For this, it's both. The OSS plugin is really only designed right now to be fully functional when applied at the root project. If you apply it at a subproject level, it may work but there may end up being missing information which would impact recipe execution.
So the problem here is a bit more tricky. By default OpenRewrite begins with a Intellij style. The user can opt to provide one or more parts of an overall style, but OpenRewrite ultimately requires a complete style. As an example, when OpenRewrite would load your style as defined it would only contain 2 of the 4 total configurations that represent a complete style definition. That's fine as you can tell because each user style can merge their overlays onto the defaults resulting in a final blended, but merged overall style. I do agree with you though that there should be some information telling you that the style failed to load and listing it within the discovered styles. Whether that failed to load is a warning message or a terminal error, I do not know.
So this could be, but something of note is that only the file handle is created during configuration time. The file isn't read until execution time, so the amount of IO should remain the same since OpenRewrite also doesn't have access to the
This one can be interesting, but in general if the context is used within defining a |
https://docs.openrewrite.org/reference/gradle-plugin-configuration#multi-module-gradle-projects says the plugin can be applied to individual projects.
Frankly speaking, I find this behaviour surprising, and it violates Gradle best practices. Ideally, there should be two plugins: the first one would be "per project plugin" that configures a specific project only, and the second plugin could be a helper one that applies the first plugin to all the projects. |
Have you considered adding a runtime check, and using tasks.register vs tasks.create depending on the runtime Gradle version? |
...
Well, user asked OpenRewrite must not ignore missing styles in |
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:
rootDir
is the default location: https://docs.openrewrite.org/reference/gradle-plugin-configuration#configuring-the-rewrite-dslIn practice, the default location is
projectDir/rewrite.yml
:rewrite-gradle-plugin/plugin/src/main/java/org/openrewrite/gradle/DefaultRewriteExtension.java
Line 74 in 0daa455
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 allA 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#L39The documentation should probably prefer Kotlin DSL syntax rather than Java DSL as people rarely use Gradle Plugins from Java.
In other words
rootProject
should be preferred overgetRootProject()
What is the smallest, simplest way to reproduce the problem?
Add the following
rewrite.yml
to the root dirConfigure Gradle plugin:
What did you see instead?
What is the full stack trace of any errors you encountered?
Available Styles:
does not listio.github.pgjdbc.style.Style
Are you interested in contributing a fix to OpenRewrite?
May be
The text was updated successfully, but these errors were encountered: