Skip to content
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

Recipes in project dependencies not detected / usable #229

Open
murdos opened this issue Oct 18, 2021 · 1 comment
Open

Recipes in project dependencies not detected / usable #229

murdos opened this issue Oct 18, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@murdos
Copy link
Contributor

murdos commented Oct 18, 2021

According to documentation, https://docs.openrewrite.org/tutorials/authoring-declarative-yaml-recipes#updating-downstream-projects, the maven plugin should detect recipes in directory /src/main/resources/META-INF/rewrite of project dependencies (as opposed to dependencies added to rewrite plugin in configuration).

However it doesn't currently work.
This can easily be reproduced with the following simple pom.xml :

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.example</groupId>
  <artifactId>check-dependency-bug</artifactId>
  <version>1.0-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>org.openrewrite.recipe</groupId>
      <artifactId>rewrite-migrate-java</artifactId>
      <version>0.10.0</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.openrewrite.maven</groupId>
        <artifactId>rewrite-maven-plugin</artifactId>
        <version>4.13.0</version>
        <configuration>
          <activeRecipes>
            <recipe>org.openrewrite.java.migrate.Java8toJava11</recipe>
          </activeRecipes>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

results in :

[INFO] --- rewrite-maven-plugin:4.13.0:run (default-cli) @ check-dependency-bug ---
[INFO] Using active recipe(s) [org.openrewrite.java.migrate.Java8toJava11]
[INFO] Using active styles(s) []
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by nonapi.io.github.classgraph.utils.ReflectionUtils$StandardReflectionDriver$1 (file:/home/amino/.m2/repository/io/github/classgraph/classgraph/4.8.123/classgraph-4.8.123.jar) to method sun.management.RuntimeImpl.getInputArguments()
WARNING: Please consider reporting this to the maintainers of nonapi.io.github.classgraph.utils.ReflectionUtils$StandardReflectionDriver$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  3.848 s
[INFO] Finished at: 2021-10-18T21:33:45+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.openrewrite.maven:rewrite-maven-plugin:4.13.0:run (default-cli) on project check-dependency-bug: Execution default-cli of goal org.openrewrite.maven:rewrite-maven-plugin:4.13.0:run failed: Recipes not found: org.openrewrite.java.migrate.Java8toJava11 -> [Help 1]
[ERROR]

NB : referencing a java recipe doesn't work either, e.g. with org.openrewrite.java.migrate.guava.NoGuavaAtomicsNewReference

@jkschneider
Copy link
Member

jkschneider commented Oct 18, 2021

Thanks @murdos . For context, in an earlier iteration all recipes were added to one of the regular dependency scopes. And we tried to keep dependencies really thin in rewrite jars to limit the potential for conflict resolution having an impact. But ultimately, the increased dependency isolation into the rewrite plugin configuration wound up being functionally necessary.

That shouldn't preclude us from also scanning Rewrite recipes where they happen to exist in regular dependency scopes. So I suggest we just do both going forward. Scanning from regular dependency scopes also permits framework authors to pack recipes into their own releases.

@pway99 pway99 moved this to Icebox in OpenRewrite Mar 1, 2022
@tkvangorder tkvangorder added the enhancement New feature or request label Mar 1, 2022
@tkvangorder tkvangorder moved this from Icebox to Backlog in OpenRewrite Mar 1, 2022
@tkvangorder tkvangorder moved this from Backlog to Ice Box in OpenRewrite Apr 8, 2022
@tkvangorder tkvangorder moved this from Request for help to Backlog in OpenRewrite Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

3 participants