Gradle can only figure out a task dependency automatically if you pass a ‘Buildable’ to the consuming task. ‘javadoc.destinationDir’ returns a ‘java.io.File’ which doesn’t implement ‘Buildable’. Here is how to fix this:
task jarJavadoc(type: Jar) {
from javadoc // same as: from javadoc.outputs.files