Recently I created gradle task to build JavaDoc. It was working flawlessly.
After a while I decided to clean the mess in my file structure and moved my classes in separate packages according to their purpose. I fixed some errors that came with it and now my app works like before, but after that my JavaDoc task stopped working (the project builds and works as intended).
I tested this build with previous file structure (all files in 1 package) and Javadoc compiled successfully.
I think it comes down to my poor knowledge of gradle, but I can't figure out how to get JavaDoc task working with my new file structure.
My build.gradle:
task javadoc(type: Javadoc) {
source = android.sourceSets.main.java.srcDirs
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += configurations.javadocDeps
options.memberLevel = JavadocMemberLevel.PRIVATE
afterEvaluate {
classpath += files(android.getBootClasspath())
def aarDependencies = classpath.filter { it.name.endsWith('.aar') }
classpath -= aarDependencies
aarDependencies.each { aar ->
def outputPath = "$buildDir/tmp/aarJar/${aar.name.replace('.aar', '.jar')}"
classpath += files(outputPath)
dependsOn task(name: "extract ${aar.name}").doLast {
extractEntry(aar, 'classes.jar', outputPath)
}
}
}
}
private static def extractEntry(archive, entryPath, outputPath) {
if (!archive.exists()) {
throw new GradleException("archive $archive not found")
}
def zip = new ZipFile(archive)
zip.entries().each {
if (it.name == entryPath) {
def path = Paths.get(outputPath)
if (!Files.exists(path)) {
Files.createDirectories(path.getParent())
Files.copy(zip.getInputStream(it), path)
}
}
}
zip.close()
}