Task of type Javadoc is always up to date

I have a task of type Javadoc like this:

class CreateJavadocsTask extends Javadoc{
@TaskAction
def action1()
{
project.source = project.android.sourceSets.main.java.srcDirs
options.linkSource true
classpath += project.files(project.android.getBootClasspath().join(File.pathSeparator))
failOnError false
}

}

This task gives an error that task is up to date as it has no source files:

Baloe is the stacktrace :

Using incremental javac compilation. Incremental java compilation is an incubating feature. Not using incremental javac compilation. Using incremental javac compilation. Not using incremental javac compilation. Using incremental javac compilation. All projects evaluated. [buildinfo] Not using buildInfo properties file for this build. Selected primary task ‘createJavadocs12’ from project : Tasks to be executed: [task ‘:bluetooth:createJavadocs12’] :bluetooth:createJavadocs12 (Thread[main,5,main]) started. :bluetooth:createJavadocs12 Skipping task ‘:bluetooth:createJavadocs12’ as it has no source files. :bluetooth:createJavadocs12 UP-TO-DATE :bluetooth:createJavadocs12 (Thread[main,5,main]) completed. Took 0.034 secs.

I think the problem is that the source is set during the execution of the task. I don’t get why you’re trying to create a separate class for something that already exists? What you can do is to create a simple task either within a plugin or within a build file like that:

task createJavaDocs(type:Javadoc) {
source sourceSets.main.java
classpath …
}

Furthermore the source should be a fileTree collection (in order to be able to get all files with getFiles())

Best