简体   繁体   English

Java模块没有`api`,必须使用`compile`?

[英]Java Module doesn't have `api`, and have to use `compile`?

As stated in https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations , we now have api and implementation . https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations中所述 ,我们现在有apiimplementation

In Android Module ie apply plugin: 'com.android.application' , we do have both. 在Android模块中,即apply plugin: 'com.android.application' ,我们两者都有。

However in a plain Java Module ie apply plugin: 'java' (Used by my Android App Module), I could only find implementation , but not api . 但是在普通的Java模块中,即apply plugin: 'java' (由我的Android App模块使用),我只能找到implementation ,但不能找到api

Hence in one of the dependent, I need to use compile , and can't use api . 因此在其中一个依赖项中,我需要使用compile ,而不能使用api
Is api inaccessible at Java Module? 在Java模块中api无法访问吗?

You have to use: 你必须使用:

apply plugin: 'java-library'

The key difference between the standard Java plugin and the Java Library plugin is that the latter introduces the concept of an API exposed to consumers . 标准Java插件和Java Library插件之间的主要区别在于后者引入了向消费者公开的API的概念

The plugin exposes two configurations that can be used to declare dependencies: api and implementation . 该插件公开了两种可用于声明依赖关系的配置: apiimplementation

More info here. 更多信息在这里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM