`AddLombokMapstructBinding` adds redundant dependency when `lombok-mapstruct-binding` is already configured in `maven-compiler-plugin` `annotationProcessorPaths`
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 72/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- java
- 領域
- build-system
調査の方向性
Start by reading rewrite-migrate-java/src/main/resources/META-INF/rewrite/java-version-17.yml and the AddLombokMapstructBindingMavenDependencyOnly recipe it invokes. Trace how it checks Maven dependencies and how AddAnnotationProcessor handles maven-compiler-plugin annotation processor paths. Done means running the recipe leaves the POM unchanged when lombok-mapstruct-binding is already configured in annotationProcessorPaths, while still adding it when needed.
索引モデルが issue の本文から書いたものです。
説明
What version of OpenRewrite are you using?
I am using
- rewrite-maven-plugin: 6.50.0
- release: 8.93.0
How are you running OpenRewrite?
I am using the Maven plugin on a multi-module Maven project:
mvn org.openrewrite.maven:rewrite-maven-plugin:6.49.0:run -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-migrate-java:3.46.0 -Drewrite.activeRecipes=org.openrewrite.java.migrate.UpgradeToJava17
What is the smallest, simplest way to reproduce the problem?
Create a Maven POM that uses both Lombok and MapStruct, and has lombok-mapstruct-binding properly configured inside maven-compiler-plugin <annotationProcessorPaths>:
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>example-service</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.36</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.6.3</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>
Run recipe org.openrewrite.java.migrate.AddLombokMapstructBinding (or org.openrewrite.java.migrate.UpgradeToJava17 / UpgradeToJava21).
What did you expect to see?
No changes to pom.xml. lombok-mapstruct-binding is already configured in <annotationProcessorPaths> of maven-compiler-plugin. Per Lombok and MapStruct documentation, it belongs in javac's annotation processor classpath, not as a project compile/runtime dependency in <dependencies>.
What did you see instead?
The recipe blindly injects lombok-mapstruct-binding as a compile-scope project dependency into <dependencies>:
<dependencies>
+ <dependency>
+ <groupId>org.projectlombok</groupId>
+ <artifactId>lombok-mapstruct-binding</artifactId>
+ <version>0.2.0</version>
+ </dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Root Cause
In rewrite-migrate-java/src/main/resources/META-INF/rewrite/java-version-17.yml:
name: org.openrewrite.java.migrate.AddLombokMapstructBinding
recipeList:
- org.openrewrite.gradle.AddDependency: ...
- org.openrewrite.java.migrate.AddLombokMapstructBindingMavenDependencyOnly
- org.openrewrite.maven.AddAnnotationProcessor:
groupId: org.projectlombok
artifactId: lombok-mapstruct-binding
version: 0.2.0
- org.openrewrite.java.migrate.AddMapstructAnnotationProcessorPath
AddLombokMapstructBinding calls AddLombokMapstructBindingMavenDependencyOnly, which only checks if lombok-mapstruct-binding is present under <dependencies> (DoesNotIncludeDependency). It does not check whether lombok-mapstruct-binding is already configured in maven-compiler-plugin <annotationProcessorPaths>. Consequently, projects that already use modern <annotationProcessorPaths> get a redundant compile dependency injected into <dependencies>.
- 主要言語
- Java
- スター
- 159
- フォーク
- 130
- 平均マージ
- 7時間 49分
- マージ済み PR(30日)
- 60
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openrewrite/rewrite-migrate-java のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
openrewrite/rewrite-migrate-java#1305 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
openrewrite/rewrite-migrate-java#1314 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
openrewrite/rewrite-migrate-java#1310 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
openrewrite/rewrite-migrate-java#1307 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 55/100
openrewrite/rewrite-migrate-java#1304 ·
メンテナーはふだん 1 日以内に返信
openrewrite/rewrite-migrate-java の issue をすべて見る
似ている issue
-
human-required sync-failed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
Azure/osdu-spi-file#63 ·
メンテナーはふだん 1 日以内に返信
-
frontend quick win
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
CodeForPhilly/benefit-decision-toolkit#571 ·
メンテナーはふだん 1 日以内に返信
-
approved
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
checkstyle/checkstyle#22129 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
Add Hardcharger JDBC driver対応中かも @prmoore77 が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信