I want to generate my JavaDocs into a given directory in my project root, I know that the destinationDir property exists, but how do I use it also given that my build.gradle exists within a directory inside of my project root. I provided a small diagram below:
/projectRoot
/lib
/build/docs/javaDocs <--- JavaDocs here by default
build.gradle
/docs <---- Need JavaDocs here
Taking a look at the documentation for JavaDocs in gradle, here. I knew that the destinationDir property existed so I attempted to set it like the provided example. This didn't have the intended affect and instead generated nothing, or is it going something outside of my project directory?
tasks.withType(Javadoc).configureEach {
exclude ('com/nest/egg/**')
options.addStringOption("charset", "utf-8")
options.addStringOption("docencoding", "utf-8")
options.addStringOption("encoding", "utf-8")
destinationDir = reporting.file("docs") // Also tried "/docs", "docs/"
}
You need to pass a Java
Fileobject todestinationDirspecifying your desired location1. So you can write:Here you are using Gradle's
ProjectLayoutobject. Eachdir()call gives you a GradleDirectoryso you must finally callasFileto finally get the JavaFileobject that you need.1I am not sure what object you are using when you call
reporting.file("docs")but theProjectLayoutobject gives you all you need.