redhat-developer / redhat-developer/vscode-java

Wrong classpath with Gradle `compileOnly` like instructions

Đang mở
#3,934 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

upstream
Ngôn ngữ chính
TypeScript
Star
2.3k
Fork
546
Merge trung bình
20 giờ 1 phút
Pull request đã merge (30 ngày)
11

Mô tả

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện dự án với dependency compileOnly được nêu, đồng thời so sánh ./gradlew bootRun với cấu hình khởi chạy Java trong .vscode/launch.json. Truy vết classpath được lắp ráp cho lần khởi chạy VS Code và các lần chạy kiểm thử; được xem là hoàn tất khi các dependency compileOnly vẫn khả dụng trong quá trình biên dịch nhưng vắng mặt khi chạy, phù hợp với hành vi của Gradle.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java, spring-boot, vscode
Lĩnh vực
build-system, devtools
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.