Skip to content

Commit

Permalink
Prevent OpenRewrite from adding unwanted dependencies to jakarta-anno…
Browse files Browse the repository at this point in the history
…tations

* Would be added by org.openrewrite.java.migrate.javax.AddCommonAnnotationsDependencies via UpgradeToJava21
* See openrewrite/rewrite#4211
  • Loading branch information
gjoseph committed Dec 18, 2024
1 parent ec88d92 commit 6c36608
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<configuration>
<configLocation>${maven.multiModuleProjectDirectory}/src/openrewrite/rewrite.yml</configLocation>
<failOnDryRunResults>true</failOnDryRunResults>
<failOnInvalidActiveRecipes>true</failOnInvalidActiveRecipes>
<exportDatatables>true</exportDatatables>
<activeRecipes>
<recipe>org.openrewrite.java.migrate.UpgradeToJava21</recipe>
<recipe>org.openrewrite.java.migrate.guava.NoGuavaJava21</recipe>
<recipe>net.incongru.tichu.rewrite.RecipeBook</recipe>
</activeRecipes>
</configuration>
</plugin>
Expand Down
23 changes: 23 additions & 0 deletions src/openrewrite/rewrite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
type: specs.openrewrite.org/v1beta/recipe
name: net.incongru.tichu.rewrite.RecipeBook
recipeList:
- org.openrewrite.java.migrate.UpgradeToJava21
- org.openrewrite.java.migrate.guava.NoGuavaJava21
- net.incongru.tichu.rewrite.RemoveJakartaAnnotationDependency

---
type: specs.openrewrite.org/v1beta/recipe
name: net.incongru.tichu.rewrite.RemoveJakartaAnnotationDependency
description: |
Somewhere in the depths of UpgradeToJava21 via Java8toJava11,
dependencies to jakarta.annotation:jakarta.annotation-api are
added because we use javax.annotation..*. Except, we only use
@Nonnull and @Nullable, which are _not_ in this jar. Since
individual recipes can't be disabled when they're declared
within others, here's a recipe that does the inverse.
See https://github.com/openrewrite/rewrite/discussions/4211
recipeList:
- org.openrewrite.java.dependencies.RemoveDependency:
groupId: jakarta.annotation
artifactId: jakarta.annotation-api

0 comments on commit 6c36608

Please sign in to comment.