`gradle-plugin-runtime` is an `implementation` dependency of a plugin, so a build that uses the plugin class doesn't compile

Đang mở Phù hợp với người mới
#126 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
65/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, kotlin
Lĩnh vực
build-system

Hướng nghiên cứu

Bắt đầu từ DevKitGradlePlugin, tại configureDependencies, nơi issue trích lệnh gọi main.implementationConfigurationName(...) thêm gradle-plugin-runtime. Chuyển phụ thuộc này sang cấu hình api để nó nằm trong apiElements, rồi kiểm tra metadata của module đã xuất bản (hoặc các test của plugin Gradle trong dự án) để xác nhận gradle-plugin-runtime xuất hiện trong biến thể apiElements chứ không chỉ trong runtimeElements. Hoàn thành khi một convention plugin phụ thuộc vào plugin đã xuất bản bằng implementation biên dịch được khi tham chiếu DevKitSupportPlugin, như trường hợp Library-API-Watchdog.

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

Mô tả

Steps:

  1. A Gradle plugin project applies the dev kit Gradle plugin. Its plugin class extends DevKitSupportPlugin:

    public class WatchdogSupportPlugin : DevKitSupportPlugin(PluginInfo.PLUGIN_INFO)
    
  2. A convention plugin of another build depends on the published plugin with implementation and uses the plugin class:

    plugins.withType<WatchdogSupportPlugin>().configureEach { /* ... */ }
    

    The same in Java: project.getPlugins().apply(WatchdogSupportPlugin.class);

What happens: the compilation of the convention plugin fails. javac reports "cannot access DevKitSupportPlugin", and the Kotlin compiler reports "Cannot access class" for DevKitSupportPlugin.

What must happen: the convention plugin compiles. The apiElements variant of the published plugin has gradle-plugin-runtime, because the public supertype of the plugin class is in that module.

Cause: DevKitGradlePlugin.configureDependencies adds the module to implementation, so the published module metadata has it in runtimeElements only.

// 0.0.4-dev-403
main.implementationConfigurationName(
    addRuntimeDependency.ifTrue { "$DEV_KIT_GROUP:gradle-plugin-runtime:$DEV_KIT_VERSION" }
)

Versions: dev kit 0.0.4-dev-403.

Found in https://github.com/Kotlin/Library-API-Watchdog/pull/94.

Ngôn ngữ chính
Kotlin
Star
34
Fork
1
Merge trung bình
1 ngày 9 giờ
Pull request đã merge (30 ngày)
3

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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.

Issue khác của Kotlin/compiler-plugin-dev-kit

Tất cả issue của Kotlin/compiler-plugin-dev-kit

Issue tương tự

Thêm issue về Kotlin

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.