Skip to content

AddCommonAnnotationsDependencies duplicates dependency when scope is not compile #728

@evie-lau

Description

@evie-lau

What version of OpenRewrite are you using?

I am using

  • rewrite-migrate-java: 3.10.0-SNAPSHOT

How are you running OpenRewrite?

I was able to recreate this issue on a smaller scale using the test in AddCommonAnnotationsDependenciesTest

What is the smallest, simplest way to reproduce the problem?

In the AddCommonAnnotationsDependenciesTest, add the following into the pom.xml before. This seems to work with any scope that is not compile.

<dependencies>
  <dependency>
      <groupId>javax.annotation</groupId>
      <artifactId>javax.annotation-api</artifactId>
      <scope>provided</scope>
      <version>1.3.2</version>
    </dependency>
</dependencies>

What did you expect to see?

Expected just the original dependency to get upgraded to Jakarta.

<dependency>
	<groupId>jakarta.annotation</groupId>
	<artifactId>jakarta.annotation-api</artifactId>
	<scope>provided</scope>
	<version>1.3.5</version>
</dependency>

What did you see instead?

The original dependency with the non-compile scope is upgraded, and also a new duplicate dependency is added without the scope.

<dependency>
	<groupId>jakarta.annotation</groupId>
	<artifactId>jakarta.annotation-api</artifactId>
	<version>1.3.5</version>
</dependency>
<dependency>
	<groupId>jakarta.annotation</groupId>
	<artifactId>jakarta.annotation-api</artifactId>
	<scope>provided</scope>
 	<version>1.3.5</version>
</dependency>

Are you interested in contributing a fix to OpenRewrite?

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions