To present an alternative view... You do not have to define separate
source sets if you do not want to.  Gradle is extremely flexible in this
regard.

That is the approach I took, for example, when writing the Gradle Antlr
plugin.  There I simply add a new "directory" to the main source set (I
put directory in quotes because i ended up using a convention object for
various reasons that sorta makes a virtual directory).  If you are not
familiar with Antlr, it essentially reads some text files and produces
java sources, which of course then need to get compiled.  The plugin
adds the Antlr output directory to the main source set java sources in
addition to src/main/java

Have a peek at the Antlr plugin source[1] if you are interested in this
approach.  You do not have to make it a plugin, nor even a separate Task
class; you could do all this directly in your build script.

[1]
http://github.com/gradle/gradle/blob/master/subprojects/gradle-antlr/src/main/groovy/org/gradle/api/plugins/antlr/AntlrPlugin.java

On Mon, 2010-07-12 at 18:09 -0400, Philip Crotwell wrote:
> I have 2 source sets in my project, main and version. The java code in
> version is generated via a task and so needs to be separate from main.
> 
> But I want to be able to use a class in version from within main, much
> as you can use main from within test. How do I tell the main sourceSet
> that it "depends on" version. I have tried several variants on:
> 
> project.sourceSets.main.compileClasspath.add(project.sourceSets.version)
> --> Cause: Could not find method add() for arguments [source set
> version] on configuration ':TauP:compile'.
> 
> project.sourceSets.main.compileClasspath.add(project.sourceSets.version.classesDir)
> --> Cause: Could not find method add() for arguments
> [/export/home/crotwell/dev/seis/TauP/build/classes/version] on
> configuration ':TauP:compile'.
> 
> And so on, but I can't seem to get it to work. What is the appropriate
> way to create a compile dependency from one sourceSet on another.
> 
> thanks,
> Philip
> 
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
> 
>     http://xircles.codehaus.org/manage_email
> 
> 

-- 
Steve Ebersole <[email protected]>
http://hibernate.org


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

    http://xircles.codehaus.org/manage_email


Reply via email to