Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

`AddLombokMapstructBinding` adds redundant dependency when `lombok-mapstruct-binding` is already configured in `maven-compiler-plugin` `annotationProcessorPaths`

オープン
#1,319 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 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 の本文から書いたものです。

説明

bug

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

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

openrewrite/rewrite-migrate-java のほかの issue

openrewrite/rewrite-migrate-java の issue をすべて見る

似ている issue

Java の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。