【发布时间】:2016-05-03 04:17:27
【问题描述】:
我有时看到的 android gradle 文件中的 apt 依赖范围是什么?
一个例子看起来像这样?
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 20
buildToolsVersion '20.0.0'
defaultConfig {
applicationId "org.ligboy.test.card.module1"
minSdkVersion 14
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
final DAGGER_VERSION = '2.0.2'
dependencies {
compile "com.google.dagger:dagger:${DAGGER_VERSION}"
apt "com.google.dagger:dagger-compiler:${DAGGER_VERSION}"//what is this scope
provided 'org.glassfish:javax.annotation:10.0-b28'
}
在顶层 build.gradle 文件中,它有这个全局依赖:
buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
注意依赖部分有一个合适的范围?我只知道编译、打包和提供的范围。编译 在编译时和包中包含依赖项,前提是只在编译时包含库并在 打包时间,因此它不包含在最终构建中。而包是相反的,它包含包中的依赖项,而不是在编译时。 但是什么是 apt 依赖范围,我们显然需要 com.neenbedankt.android-apt 才能工作,所以我知道它是基于 android 的。
更新: 为什么我不能使用 provided 依赖范围而不是 apt 范围?它们有何不同?
我在dagger dependency scopes 上为需要更多信息的人创建了一个教程。
【问题讨论】:
标签: android gradle android-gradle-plugin