You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
According to gradle offcial doc,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!");
}
}
The text was updated successfully, but these errors were encountered:
HappyHacker123
changed the title
Some dependencies in jib-core are set to wrong dependency scope, leading to compilation error.
Some dependencies in jib-core are set to wrong dependency scope that may cause compilation error.
Apr 8, 2024
First of all, you are not supposed to use or access BlobHttpContent. The intention is that only those classes under the api directiory are the public surface of the jib-core library.
(However, I admit I may not be understanding the gist of this issue.)
Actually i'm mainly talking about the listed dependencies should be set to configuration api instead of implementation. The example of BlobHttpContent is just showing possible consequence of wrong configuration. Below are gradle official doc on api dependencies.
So when should you use the api configuration? An API dependency is one that contains at least one type that is exposed in the library binary interface, often referred to as its ABI (Application Binary Interface). This includes, but is not limited to:
types used in super classes or interfaces
types used in public method parameters, including generic parameter types (where public is something that is visible to compilers. I.e. , public, protected and package private members in the Java world)
types used in public fields
public annotation types
According to the doc, there are mainly four situations that the dependency should be set to api. So, in the above issue body, I'm listing where these dependencis meet one of these criteria and thus should be set to api.
Environment:
Description of the issue:
The following dependencies in jib-core are set to scoep implementation, but the expected scope should api.
According to gradle offcial doc,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.
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.
The text was updated successfully, but these errors were encountered: