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 // <----
}
How can I rewrite the code to get rid of the warning?
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
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With