Steve Appling wrote:
I'm trying to update the root build.gradle to handle some of my recent changes and am running past my understanding of source sets.

The javadoc task currently has:
srcDirs = subprojects.inject([]) {list, project -> list + project.source.main.java.srcDirs + project.source.main.groovy.srcDirs}

I have changed a sub-project to not be a groovy project and am trying to build up the correct set of sources for javadoc, but I can't figure out how to test what kind of sources are in a SourceSet. If I reference project.source.main.groovy I get an exception on non-groovy projects.


The intended solution is that tasks such as javadoc or checkstyle which operate on Java source use the SourceSet.allJava property, which is a FileTree containing all Java source files regardless of the type of project, and where the source comes from. Something like:

javadoc {
   subprojects.each {
       source it.source.main.allJava
   }
}

At the moment, Javadoc does not accept a FileCollection as source (it will soon), so we're stuck with reverse engineering the source directories. You could do something like:

srcDirs = subprojects.inject([]) {list, project ->
   if ( project.source.main.hasProperty('groovy') {
       list.addAll(project.source.main.groovy.srcDirs)
   }
   list.addAll(project.source.main.java.srcDirs)
}

project.source.main.groovy is not always valid - actually, I don't understand why it is ever valid, getGroovy is not a part of the SourceSet interface but is injected dynamically in some way that I couldn't follow. SourceSet.getJava is always part of the interface, but seems odd for a Groovy project.


Some documentation is coming, but, basically, SourceSet is extended by plugins using exactly the same mechanism they use to extend Project. The groovy plugin mixes in GroovySourceSet to each source set. This is where the groovy property comes from.


Adam


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to