Open SimonVerhoeven opened 1 year ago
Thanks for pointing this out! You've found a neat implementation detail around how we handle preconditions in declarative recipes; the message you saw originates here. Since the class is package private the best I could do for now is recognize such recipes by their message, and then skip them.
So the issue here is that the bellwether is shown on the Yaml tab:
That's an implementation detail; not something for folks to implement. Might mean we need to move this to https://github.com/openrewrite/rewrite-recipe-markdown-generator
There it shows up in the yaml tab as
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.spring.boot3.EnableVirtualThreads
displayName: Enable Virtual Threads on Java 21
description: Set `spring.threads.virtual.enabled` to `true` in `application.properties` or `application.yml`.
recipeList:
- org.openrewrite.config.DeclarativeRecipe$PreconditionBellwether
- org.openrewrite.java.spring.AddSpringProperty
Compare that to how the recipe is actually implemented: https://github.com/openrewrite/rewrite-spring/blob/b76e03437143632ec9d42ffc0a5e7af2b88f11c9/src/main/resources/META-INF/rewrite/spring-boot-32.yml#L63-L73
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.spring.boot3.EnableVirtualThreads
displayName: Enable Virtual Threads on Java 21
description: Set `spring.threads.virtual.enabled` to `true` in `application.properties` or `application.yml`.
preconditions:
- org.openrewrite.java.search.HasJavaVersion:
version: 21.X
recipeList:
- org.openrewrite.java.spring.AddSpringProperty:
property: spring.threads.virtual.enabled
value: true
As discussed on the above PR: it would be better to show the configured precondition & recipe arguments in the bellwether. So right now what we show is:
No bellwether (good), no precondition (missed opportunity, it's in the bellwether), no arguments to AddSpringProperty, (leading to a broken yaml recipe)
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.spring.boot3.EnableVirtualThreads
displayName: Enable Virtual Threads on Java 21
description: Set `spring.threads.virtual.enabled` to `true` in `application.properties` or `application.yml`.
recipeList:
- org.openrewrite.java.spring.AddSpringProperty
As per the source
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.spring.boot3.EnableVirtualThreads
displayName: Enable Virtual Threads on Java 21
description: Set `spring.threads.virtual.enabled` to `true` in `application.properties` or `application.yml`.
preconditions:
- org.openrewrite.java.search.HasJavaVersion:
version: 21.X
recipeList:
- org.openrewrite.java.spring.AddSpringProperty:
property: spring.threads.virtual.enabled
value: true
As mentioned in this issue, I believe that changes will need to be made in rewrite itself (specifically RecipeDescriptor) to allow for Preconditions to be made available to the docs.
For recipes such as https://docs.openrewrite.org/recipes/java/spring/boot3/enablevirtualthreads which contain a precondition (in this case
org.openrewrite.java.search.HasJavaVersion
the recipe list showsPrecondition bellwether
which links to https://github.com/openrewrite/rewrite-docs/blob/master/reference/recipes/config/declarativerecipe$preconditionbellwether.md rather than the expected HasJavaVersion recipe + link.