On 17/06/10 8:46 AM, Philip Crotwell wrote:
Hi

I just put an example plugin within buildSrc on the wiki that I
thought might be an example as well as useful on its own.
http://docs.codehaus.org/display/GRADLE/Plugins#Plugins-ExampleofasimplecustompluginwithinbuildSrc

I am not sure if this is a right place in the wiki for this to live, but...

Is there a gradle "best practice" for dealing with generated code? I
followed the lead of the antlr plugin and used "build/generated-src",
but somehow it feels a little arbitrary. Almost as if I am doing a
hack to push the generated code into the java plugin when it feels
like there should be a more general or defined way.

Is "build/generated-src" the standard place to put generated code?

There's no standard place, yet. There should be. I think each source set would have a conventional location where the generated source for that source set should go. A good default might be $buildDir/generated-src/$sourceSetName. Plus there'd be a property on SourceSet to specify this.

The idea would be that anything that ends up in the generated src dir for a source set would be included by the compileJava/compileGroovy/compileScala task for that source set. But it would not, for example, be included in a checkstyle check or as a source directory in an ide project.

Is there a better way to integrate generated code into the java plugin
other than making it a "dependsOn" of classes and a "from" of jar?

I'd try to avoid having to change anything which uses the classes, such as the jar task. So, perhaps something like:

apply plugin: 'java'

task mySourceGenTask(type: SomeTask) {
    destinationDir = "$buildDir/generated-src/main"
}

compileJava {
    dependsOn mySourceGenTask
    source mySourceGenTask.destinationDir
}


This way, running 'gradle classes' will generate the source and compile it along with the other source, and nothing else needs to change.


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
CTO, Gradle Inc. - Gradle Training, Support, Consulting
http://www.gradle.biz


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

   http://xircles.codehaus.org/manage_email


Reply via email to