GoogleContainerTools / GoogleContainerTools/jib
Some dependencies in jib-core are set to wrong dependency scope that may cause compilation error.
- Dominant language
- Java
- Stars
- 14.5k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Environment**:
- *Jib version:* 0.27.0
- *Build tool:* Gradle 8.4.0
**Description of the issue**:
The following dependencies in **jib-core** are set to scoep **implementation**, but the expected scope should **api**.
```
implementation dependencyStrings.JACKSON_DATABIND
implementation dependencyStrings.GUAVA
implementation dependencyStrings.COMMONS_COMPRESS
implementation dependencyStrings.GOOGLE_HTTP_CLIENT
```
According to [gradle offcial doc](https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_recognizing_dependencies),if a library contains classes that are exposed in the library binary interface, its dependency scope should be **api**. The above depedencies all contain classes exposed in binary interface as offical doc goes, I list one example of each dependency below.
- Class **JsonDeserializer** in **JACKSON_DATABIND** is **extended** by jib-core/src/main/java/com/google/cloud/tools/jib/image/json/DescriptorDigestDeserializer.java
- Class **ListMultimap** in **GUAVA** is used as **public method parameter** in jib-core/src/main/java/com/google/cloud/tools/jib/configuration/BuildContext.java
- Class **TarArchiveEntry** in **COMMONS_COMPRESS** is used as **public method parameter** in jib-core/src/main/java/com/google/cloud/tools/jib/tar/TarStreamBuilder.java
- Class **HttpContent** in **GOOGLE_HTTP_CLIENT** is **implemented** in jib-core/src/main/java/com/google/cloud/tools/jib/http/BlobHttpContent.java
**Expected behavior**:
The dependencies scope should be changed to **api**. Otherwise it can lead to compilation failures in consumers, as mentioned in offical doc. I will give an example to reproduce below.
**Steps to reproduce**:
Import jib-core as a dependency in a project and try to access BlobHttpContent like the below class. Compilation will fail due to GOOGLE_HTTP_CLIENT is set to implementation and not api.
```
import com.google.cloud.tools.jib.http.BlobHttpContent;
public class Main extends BlobHttpContent {
public Main(Blob blob, String contentType) {
super(blob, contentType);
}
public static void main(String[] args) {
System.out.println("Hello world!");
}
}
```
```
implementation("com.google.cloud.tools:jib-core:0.27.0")
```
Contributor guide
Assessment
This issue has not been assessed yet.