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

标签 java android gradle android-gradle-plugin gradle-plugin

https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html#new_configurations 中所述,我们现在有 apiimplementation

在 Android 模块中,即 apply plugin: 'com.android.application',我们两者都有。

然而,在普通的 Java 模块中,即 apply plugin: 'java'(由我的 Android 应用程序模块使用),我只能找到 implementation,但找不到 api.

因此在其中一个依赖中,我需要使用compile,而不能使用api
api 是否无法在 Java 模块中访问?

最佳答案

你必须使用:

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.

The plugin exposes two configurations that can be used to declare dependencies: api and implementation.

更多info here.

关于Java 模块没有 `api` ,必须使用 `compile` ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46111131/

相关文章:

java - 不允许在 Java 方法覆盖上使用父类(super class)型的原因是什么?

java - 引用 mongodb 列表中的元素

Android 文字覆盖图片

java - 停止 Eclipse/Gradle 生成 .project 和 .settings/

Java TLS 1.2 相互认证超时结束

java - 如何获取放置文档的 JTextField 名称?

以编程方式进行 Android Premium 访问管理

android - 我怎么知道我的标记是否在街上

android - Gradle:升级到 Gradle 2.2.1 后,android.variantFilter 导致构建失败

gradle - 从 Gradle 中的依赖项 jar 或 war 文件复制资源