摇篮:DefaultAndroidSourceDirectorySet使用toString()方法,以文件已被德precated [英] Gradle: DefaultAndroidSourceDirectorySet to File using toString() method has been deprecated
问题描述
我要更新的摇篮插件在Android库项目。新版 0.10.4
。该摇篮包装是 1.10
。下面的警告出现,当我运行 ./ gradlew安装
上的项目。
I want to update the Gradle plug-in of an Android library project. The new version is 0.10.4
. The Gradle wrapper is at 1.10
. The following warning appears when I run ./gradlew install
on the project.
Converting class com.android.build.gradle.internal.api. \
DefaultAndroidSourceDirectorySet to File using toString() method has
been deprecated and is scheduled to be removed in Gradle 2.0.
Please use java.io.File, java.lang.String, java.net.URL, or java.net.URI instead.
我不知道,但标线应原因:
I am not sure but the marked lines should the cause:
// build.gradle
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java // <----
}
task androidJavadocsJar(type: Jar) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}
task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java // <----
}
我怎么能改写code摆脱警告?
How can I rewrite the code to get rid of the warning?
推荐答案
android.sourceSets.main.java
没有你所期望的类型。你传递给它的东西,需要一个文件[]
,但它实际上有型 com.android.build.gradle.internal.api .DefaultAndroidSourceDirectorySet
。如果你看一下对于Android的 API sourceSets
你会发现有一个 sourceDirs
方法,返回你想要的。因此,建立这样的任务:
android.sourceSets.main.java
doesn't have the type you expect. You're passing it to something that expects a File[]
, but it actually has the type com.android.build.gradle.internal.api.DefaultAndroidSourceDirectorySet
. If you look at the API for Android sourceSets
at you'll find that there's a sourceDirs
method that returns what you want. So set up your tasks like this:
task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
}
这篇关于摇篮:DefaultAndroidSourceDirectorySet使用toString()方法,以文件已被德precated的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!