Consider shading the JGit dependency in Grade plugin
- Ngôn ngữ chính
- Java
- Star
- 5.6k
- Fork
- 559
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 43
Mô tả
### Summary
In Gradle, all plugins share the same classpath. This makes it very hard, if not impossible, to use plugins which depend on different incompatible versions of the same library. This is the case with Spotless and [GitPublish](https://github.com/ajoberstar/gradle-git-publish):
1. Spotless [depends](https://github.com/diffplug/spotless/blob/5244a7e9d8958785b159bd8420f67e8ba36a91a3/lib-extra/build.gradle#L15) on 5.7.0.202003110725-r
2. GitPublish [depends](https://github.com/ajoberstar/grgit/blob/09e307a859033ca9591b3159672857a7b4709dde/grgit-core/build.gradle#L18) on the "latest release" version, which for the latest version of the plugin itself [is](https://mvnrepository.com/artifact/org.ajoberstar.grgit/grgit-core/4.0.1) 5.6.0.201912101111-r
Downgrading the JGit dependency in Spotless, I believe, is not an option, but maybe you could consider shading this dependency, building it into the Gradle plugin JAR file? I believe that the official Gradle guidelines [recommend](https://guides.gradle.org/designing-gradle-plugins/#minimizing_the_use_of_external_libraries) minimizing the number of external dependencies, and shading is one of the ways to mitigate issues like this one.
### Gradle version
Happens with any Gradle version, including the latest one, 6.4.1
### Spotless version
4.0.1
### Operating system and version
Probably not relevant, but macOS 10.15.3
### Spotless configuration
Having something as simple as
```kotlin
spotless {
scala {
scalafmt("2.3.2").configFile(layout.projectDirectory.file(".scalafmt.conf"))
}
}
```
in the build configuration will reproduce the issue,.
### Console errors
In all my test cases any Spotless tasks don't cause errors; exceptions can be observed when the GitPublish plugin is used, and they are generic class linkage errors which happen when binary incompatible libraries with the same class names are present in the one classpath.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện xung đột với Spotless 4.0.1, GitPublish và cấu hình Scala scalafmt được nêu, sau đó kiểm tra thiết lập dependency JGit của Gradle plugin. So sánh kết quả với hướng dẫn của Gradle về việc giảm thiểu các dependency của plugin bên ngoài. Công việc được xem là hoàn tất khi GitPublish và Spotless có thể cùng tồn tại mà không gặp các lỗi liên kết lớp chung đã được báo cáo do các phiên bản JGit không tương thích.
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
- Lĩnh vực
- build-system
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- 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
- 25/100