I unfortunately have auto-generated source and classes compiled outside of the
normal compiler scope that cannot be added to the source sets, so they are
added dynamically to the javadoc source and classpaths. Therefore, my
currently working solution is below:
task alljavadoc(type: Javadoc) {
dependsOn project.subprojects.collect { Project subproj ->
subproj.tasks.withType(Javadoc).collect { subproj.classes }
}
// NOTE: Some source and class trees are added dynamically (generated at
// build time), so must collect all of them at run time
doFirst { Javadoc task ->
task.project.subprojects.each { Project subproject ->
subproject.tasks.withType(Javadoc).each { Javadoc subtask ->
if (task.source == null)
{
task.source = subtask.source
}
else
{
task.source = task.source + subtask.source
}
if (task.classpath == null)
{
task.classpath = subtask.classpath
}
else
{
task.classpath = task.classpath + subtask.classpath
}
}
}
}
}
I considered using the simple source xyz form, but didn't like that it was
asymmetric with assigning classpath, so I made them look the "same".
-Spencer
--- On Fri, 6/4/10, Paul Speed <[email protected]> wrote:
From: Paul Speed <[email protected]>
Subject: Re: [gradle-user] Interesting new javadoc behavior
To: [email protected]
Date: Friday, June 4, 2010, 1:26 PM
This is what I use and it still works with preview 3:
task alldocs(type: Javadoc) {
title = "My Project version $version Project API Documentation"
destinationDir = new File(project.buildDir, 'docs/javadoc')
optionsFile = new File( 'build/tmp/javadoc.txt' )
subprojects.each { subproject ->
source subproject.sourceSets.main.java
if( classpath )
classpath += subproject.sourceSets.main.classes +
subproject.sourceSets.main.compileClasspath
else
classpath = subproject.sourceSets.main.classes +
subproject.sourceSets.main.compileClasspath
}
}
Note: I do have to do some funkiness to work around classpath being null in the
initial pass but source works like one might expect.
I don't know if there is a simpler gradle way to do this (and I've tried a few
simpler approaches.)
-Paul