openrewrite / rewrite-maven-plugin

OpenRewrite's Maven plugin.
https://openrewrite.github.io/rewrite-maven-plugin/plugin-info.html
Apache License 2.0
130 stars 68 forks source link

Run specific recipe regardless of the configuration in activeRecipes #314

Closed yeikel closed 2 years ago

yeikel commented 2 years ago

Is there any way to run specific recipe regardless of what we have configured in activeRecipes?

I tried

mvn rewrite:run -DactiveRecipe=org.openrewrite.java.testing.junit5.JUnit4to5Migration

But it still ran the rules I have in my configuration. In fact, it ignored the specific recipe and only applied what I have in my configuration

pway99 commented 2 years ago

Yes, Just pass arguments for both the rewrite.activeRecipes and activeRecipes params. Give this a try: mvn rewrite:run -DactiveRecipes="" -Drewrite.activeRecipes=org.openrewrite.java.testing.junit5.JUnit4to5Migration

pway99 commented 2 years ago

@yeikel #317 makes this a bit more intuitive:

mvn rewrite:run -Drewrite.activeRecipes=org.openrewrite.java.testing.junit5.JUnit4to5Migration
yeikel commented 2 years ago

@yeikel #317 makes this a bit more intuitive:

mvn rewrite:run -Drewrite.activeRecipes=org.openrewrite.java.testing.junit5.JUnit4to5Migration

Thank you. I'll try it out as soon as it is released

yeikel commented 2 years ago
mvn rewrite:run -Drewrite.activeRecipes=org.openrewrite.java.testing.junit5.JUnit4to5Migration

I was able to confirm that this working as expected now. Thank you @pway99

delanym commented 2 years ago

Please remove the incorrect reference in https://docs.openrewrite.org/reference/recipes/java/cleanup/commonstaticanalysis

pway99 commented 2 years ago

thanks @delanym, I updated the doc.

Recipes can also be activated directly from the command line by adding the argument -Drewrite.activeRecipes=org.openrewrite.java.cleanup.CommonStaticAnalysis