This falls neatly into the "what about ANTLR" camp :)

Roger

On Aug 19, 2010, at 7:04 PM, Adam Murdoch wrote:

> On 20/08/10 4:55 AM, Matthias Bohlen wrote:
>> 
>> Thanks for the hint! I configured it as follows:
>> 
>> sourceSets {
>>     generated {
>>         java {
>>             srcDirs = [ 'src/generated/java' ]
>>         }
>>     }
>>     main {
>>         java {
>>             srcDirs = [ 'src/main/java' ]
>>             compileClasspath += generated.classes
>>         }
>>     }
>> }
>> 
>> That solved the compile problem but the generated and compiled files are not 
>> packaged into the jar file.
> 
> I suspect you'll keep bumping into problems like this, because the generated 
> classes aren't really a separate source set, they're part of the main classes 
> of the project. I would suggest doing something     like:
> 
> task someGenerationTask(...) { 
>     destinationDir = "$buildDir/generated-src"
> }
> 
> compileJava {
>     dependsOn someGenerationTask
>     source someGenerationTask.destinationDir
> }
> 
> To make this kind of thing easier, we could add the concept of generated 
> source to the Gradle model, so you could just do something like:
> 
> task someGenerationTask(...) { 
>     destinationDir = "$buildDir/generated-src"
> }
> 
> sourceSets.main.java {
>     generatedSrcDir someGenerationTask.destinationDir
> }
> 
> 
>> 
>> Any ideas?
>> 
>> ---
>> 
>> Am 19.08.2010 um 19:52 schrieb Robert Fischer:
>> 
>>> This just solved an issue I was having, too.  Thanks!
>>> 
>>> ~~ Robert.
>>> 
>>> On 19 August 2010 12:45, Philip Crotwell <[email protected]> wrote:
>>> 
>>> This from the gradle users list might help:
>>> http://gradle.markmail.org/thread/fiy7lycws3fmqf52
>>> 
>>> Philip
>>> 
>>> 
>>> On Thu, Aug 19, 2010 at 12:33 PM, Matthias Bohlen <[email protected]> 
>>> wrote:
>>> Hi,
>>> 
>>> today, I created a separate source set for generated code:
>>> 
>>> sourceSets {
>>>     main {
>>>         java {
>>>             srcDirs = [ 'src/main/java' ]
>>>         }
>>>     }
>>>     generated {
>>>         java {
>>>             srcDirs = [ 'src/generated/java' ]
>>>         }
>>>     }
>>> }
>>> 
>>> I did this because I do not want to run Checkstyle on the generated code, 
>>> so I also said:
>>> 
>>> checkstyleGenerated.enabled = false
>>> 
>>> However, the compileJava task does not seem to know about the second source 
>>> set because I get compile errors when a symbol is referenced that is 
>>> defined in the generated code.
>>> 
>>> So: How do I add the "generated" source set to the compile and jar tasks?
>>> 
>>> Cheers
>>> Matthias
>>> 
>>> 
>>> 
>> 
> 
> 
> -- 
> Adam Murdoch
> Gradle Developer
> http://www.gradle.org
> CTO, Gradle Inc. - Gradle Training, Support, Consulting
> http://www.gradle.biz

Reply via email to