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

Dependencies of plugins are not updated #4779

Closed
jonblack opened this issue Dec 12, 2024 · 4 comments · Fixed by #4798
Closed

Dependencies of plugins are not updated #4779

jonblack opened this issue Dec 12, 2024 · 4 comments · Fixed by #4798
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@jonblack
Copy link
Contributor

jonblack commented Dec 12, 2024

Using the following example recipe:

type: specs.openrewrite.org/v1beta/recipe
name: com.my.group.Example
displayName: Example
description: Example
recipeList:
  - org.openrewrite.maven.ChangePluginGroupIdAndArtifactId:
      oldGroupId: com.my.group
      oldArtifactId: app-plugin-artifact
      newGroupId: com.my.group.subgroup
  - org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId:
      oldGroupId: com.my.group
      oldArtifactId: app-plugin-artifact
      newGroupId: com.my.group.subgroup
  - org.openrewrite.maven.ChangeManagedDependencyGroupIdAndArtifactId:
      oldGroupId: com.my.group
      oldArtifactId: app-plugin-artifact
      newArtifactId: app-plugin-artifact
      newGroupId: com.my.group.subgroup

This fails to update the dependencies of plugins. For example:

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.app.myapp</groupId>
  <artifactId>awesome-app</artifactId>
  <version>1.0.0</version>

  <build>
    <plugins>
      <plugin>
        <groupId>com.app.plugins</groupId>
        <artifactId>cool-plugin</artifactId>
        <version>1.0.0</version>
        <dependencies>
          <dependency>
            <groupId>com.my.group</groupId>
            <artifactId>app-plugin-artifact</artifactId>
            <version>1.1.0</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>
</project>

I would expect at least one of these recipes to update the groupId of the plugin dependency. If there is a recipe that can do this, it's not clear to me which one it would be.

@jonblack jonblack added the bug Something isn't working label Dec 12, 2024
@timtebeek
Copy link
Contributor

hi @jonblack ! Long time no see; hope you're well! Had a brief look at the above; indeed looks like we do not yet change plugin dependencies; we'd need a similar change as was done here:

Of the options above, ChangeDependencyGroupIdAndArtifactId seems the best candidate. Would you be open to getting that started on a draft PR by copying this test to include your example above?

@Test
void changeDependencyGroupIdAndArtifactId() {
rewriteRun(
spec -> spec.recipe(new ChangeDependencyGroupIdAndArtifactId(
"javax.activation",
"javax.activation-api",
"jakarta.activation",
"jakarta.activation-api",
null,
null
)),
pomXml(
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
""",
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<version>1</version>
<dependencies>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>jakarta.activation</groupId>
<artifactId>jakarta.activation-api</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
</dependencyManagement>
</project>
"""
)
);
}

@jonblack
Copy link
Contributor Author

Hey @timtebeek! Small world! I'm good; very busy. How are you?

I've created the pull request with the test case that reproduces the issue. Sadly, I don't have time to work on a fix at the moment. Hopefully, this will help someone who can pick it up.

@timtebeek
Copy link
Contributor

timtebeek commented Dec 18, 2024

All is well here, thanks! I know some colleagues of yours were active as well. Hope the automations help your save time.

Thanks for the runnable exmaple! Indeed makes this easier to take on. Can't fit it in today but I'll try to find some time for this.

@timtebeek timtebeek self-assigned this Dec 18, 2024
@timtebeek
Copy link
Contributor

@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenRewrite Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants