Problem: Publish javadoc and sources for a gradle project. The following code works well, even on Gradle 5.1.1:
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
However, in Gradle 5.1.1 the following statements are deprecated:
classifier = 'sources'
...
classifier = 'javadoc'
Looking at the javadoc for the evaluated method name reveals:
Deprecated. Use getArchiveClassifier()
Source: https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/bundling/AbstractArchiveTask.html#setClassifier-java.lang.String-
This doesn't make sense to me.
What change is required for my code to continue to work and not be deprecated?
Artifacts are temporary or final files or directories that are produced by the Android Gradle plugin during the build.
There are two general types of plugins in Gradle, binary plugins and script plugins.
Gradle dependencies are grouped into sets called configurations. Different configurations are used for building classpath for the major two tasks — compile classpath is used for compilation and runtime classpath is used for running the application.
Configuration inheritance and composition For example the testImplementation configuration extends the implementation configuration. The configuration hierarchy has a practical purpose: compiling tests requires the dependencies of the source code under test on top of the dependencies needed write the test class.
Following will not show deprecation warning:
archiveClassifier.set("sources")
archiveClassifier.set("javadoc")
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