Skip to content

Recipes in project dependencies not detected / usable #229

Description

@murdos

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions