redhat-developer / redhat-developer/vscode-java

Wrong classpath with Gradle `compileOnly` like instructions

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

まだ誰も着手していません。

upstream
主要言語
TypeScript
スター
2.3k
フォーク
546
平均マージ
20時間 1分
マージ済み PR(30日)
11

説明

We need to use the compileOnly in a gradle modules.
The expected behaviour is to have the dependency available at the compile time, but not at runtimes.

It's useful to create spring boot auto-configurations that load only if the dependency is present in the consumer module.

We have this declaration in a library:

dependencies {
  compileOnly 'org.springframework.boot:spring-boot-starter-security'
}

In the application module we have this declaration:

dependencies {
  implementation project(':libs:my-lib')
}

Running the following command, the project works as expected. The spring-boot-starter-security is not loaded.

./gradlew bootRun

But if we run the following configuration, the dependency is in classpath at runtime and the auto-configuration is applied at wrong.

{
  "configurations": [
    {
      "type": "java",
      "name": "Spring Boot-Application",
      "request": "launch",
      "cwd": "${workspaceFolder}",
      "mainClass": "com.mycompany.Application",
      "projectName": "application",
      "args": ""
    }
  ]
}

There is also dependency problems in test but I can't exactly explain what. There is some BeanDefinitionOverrideException that are not present running the ./gradlew test command.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

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

調査の方向性

示されている compileOnly 依存関係を使ってプロジェクトを再現し、./gradlew bootRun と .vscode/launch.json の Java 起動構成を比較します。VS Code の起動とテスト実行用に組み立てられた classpath を追跡します。compileOnly 依存関係がコンパイル時には利用可能なまま、実行時には存在せず、Gradle の動作と一致すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java, spring-boot, vscode
領域
build-system, devtools
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

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

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