Just to add a little structure to the answers, these are the configs needed to generate Javadoc (using Gradle versions 4 and 5 ).
1. Define your sourceSet (may be optional if using the standard Maven directory structure). Assuming this directory structure:
βββ src β βββ main β βββ java βββ src β βββ test β βββ java
Define sourceSet like this
sourceSets { main { java { srcDirs =['src/main/java'] } test { java { srcDirs =['src/test/java'] } }
2. Configure the classpath that will be used when creating javadoc. error: package org.xxxx do this will result in errors similar to the following: error: package org.xxxx does not exist.
Assuming your dependency is defined as follows:
dependency { compile group: 'xxxx', name: 'yyyy', version: 'zzzz' testCompile group: 'aaaa', name: 'bbbb', version: 'cccc' }
define a javadoc task this way
tasks.withType(Javadoc){ source = sourceSet.main.java.srcDirs classpath +=configuration.compile destinationDir = reporting.file("myJavaDoc") //optional }
If you want to create a Java document for testing, the task will look like this:
tasks.withType(Javadoc){ source = sourceSet.test.java.srcDirs classpath +=configuration.compile classpath +=configuration.testCompile destinationDir = reporting.file("myJavaDoc") //optional }
papigee
source share