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

Maven: UpgradePluginVersion does not work for plugins in pluginManagement #4137

Open
smurf667 opened this issue Apr 16, 2024 · 1 comment
Open
Labels
bug Something isn't working enhancement New feature or request

Comments

@smurf667
Copy link

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.

@smurf667 smurf667 added the bug Something isn't working label Apr 16, 2024
@timtebeek
Copy link
Contributor

Thanks for the suggestion! We recently made a similar change for dependencies and dependency management. Think we could do the same here, as indeed it would be surprising not to see any such changes.

@timtebeek timtebeek added the enhancement New feature or request label Apr 16, 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 enhancement New feature or request
Projects
Status: Backlog
Development

No branches or pull requests

2 participants