I'm trying to use gradle on some existing Groovy/Java projects that were
created using the Groovy Eclipse plugin.  Since those projects don't
separate groovy and java classes in the src directory, I just mapped the
project like:

sourceSets {
    main {
        java {
            srcDir 'src'
        }
        groovy {
            srcDir 'src'
        }
    }
    test {
        java {
            srcDir 'tests'
        }
        groovy {
            srcDir 'tests'
        }
    }
}

I have both Java and Groovy classes in my src and tests directories.  When I
run "gradle build", everything seems to work okay.  Is that a reasonable
approach?  It seems a lot easier than trying to rewrite the project
structure.

Ken

On Fri, Apr 23, 2010 at 8:28 PM, Adam Murdoch <[email protected]> wrote:

>
>
> On 23/04/10 10:08 AM, Roger Studner wrote:
>
>> This is a problem i'm sure has been solved over and over.. I just can't =
>> find it via da googles :)
>>
>> src
>> main
>>  java
>>   com
>>    AClass
>>    BClass
>>  groovy
>>   com
>>    SomeOtherClass
>>
>> SomeOtherClass refers to AClass.. but BClass refers to SomeOtherClass
>>
>> Since it performs compileJava and then compileGroovy, it is a chicken =
>> and egg problem.
>>
>> Right now I solve this by putting 100% of my code under src/main/groovy
>>
>>
>>
>
> This is what the groovy plugin convention expects, which may or may not be
> a good idea.
>
> You can do something like this, so you can put java source under
> src/main/java and groovy source under src/main/groovy, and still get the
> joint compilation:
>
> sourceSets.main.java.srcDirs = [] // ie there's no stand-alone java source
> sourceSets.main.groovy.srcDir 'src/main/java' // ie include the 'java' dir
> as groovy source
>
> It's a little awkward.
>
> Perhaps it would be better if you could declare dependencies between source
> sets, something like:
>
> sourceSets.main {
>    java {
>        dependsOn groovy // a cycle -> Gradle does joint compilation
>    }
>    groovy {
>        dependsOn java  // this is the default
>    }
> }
>
> Or perhaps if you could add one source set to another, something like:
>
> sourceSets.main {
>    groovy {
>        from java // include in joint compilation
>    }
> }
>
>
> --
> Adam Murdoch
> Gradle Developer
> http://www.gradle.org
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>   http://xircles.codehaus.org/manage_email
>
>
>


-- 
Kenneth A. Kousen
President
Kousen IT, Inc.

Email: [email protected]
Site: http://www.kousenit.com
Blog: http://kousenit.wordpress.com
Twitter: @kenkousen

Reply via email to