openrewrite / openrewrite/rewrite
Maven: UpgradePluginVersion does not work for plugins in pluginManagement
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.7k
- Forks
- 571
- Avg merge
- 13h 12m
- Merged PRs (30d)
- 261
Description
What version of OpenRewrite are you using?
I am using org.openrewrite.maven:rewrite-maven-plugin:5.28.0
How are you running OpenRewrite?
I am using the Maven plugin, and my project is a single module project. I am using the following pom.xml file:
<?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 https://maven.apache.org/maven-
v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>demo</groupId>
<artifactId>demo</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<info.version>3.4.5</info.version>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>${info.version}</version>
</plugin>
<plugin>
<groupId>org.sonarsource.scanner.maven</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>3.10.0.2594</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<!-- put the plugin here and the update will be performed...
<plugin><groupId>org.sonarsource.scanner.maven</groupId><artifactId>sonar-maven-plugin</artifactId><version>3.10.0.2594</version></plugin>
-->
</plugins>
</build>
</project>
As a sibling to pom.xml the following rewrite.yml exists:
---
type: specs.openrewrite.org/v1beta/recipe
name: demo
displayName: Upgrade Maven plugin versions
recipeList:
- org.openrewrite.maven.UpgradePluginVersion:
groupId: org.apache.maven.plugins
artifactId: maven-project-info-reports-plugin
newVersion: latest.release
- org.openrewrite.maven.UpgradePluginVersion:
groupId: org.sonarsource.scanner.maven
artifactId: sonar-maven-plugin
newVersion: latest.release
What is the smallest, simplest way to reproduce the problem?
See the setup above; I am running mvn org.openrewrite.maven:rewrite-maven-plugin:5.28.0:run -Drewrite.activeRecipes=demo
What did you expect to see?
I expected the recipe to update both the property and the version of the plugins declared in <pluginManagement/>.
What did you see instead?
No modification occurred, the plugins are not updated.
Note when I declare a plugin in <plugins/> instead, an update is performed. I am using <pluginManagement/> because my ultimate use would be also in multi-module projects.
What is the full stack trace of any errors you encountered?
No errors, no stracktrace, just no expected updated plugin versions.
Are you interested in contributing a fix to OpenRewrite?
Sorry, I can't.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided pom.xml and rewrite.yml by running the documented Maven rewrite-maven-plugin command. Start from org.openrewrite.maven.UpgradePluginVersion and compare handling of build/pluginManagement with build/plugins. Done means both pluginManagement entries are updated, including the referenced property where applicable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100