Groovy & Java cross compilation

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Groovy & Java cross compilation

Rob Fletcher
Hi

I have a project with a single Java class and a whole bunch of Groovy
classes. The Java class contains no reference to any Groovy classes
but several Groovy classes reference the Java class. I found that
compilation would fail unless I keep the Java class under
src/main/groovy. Is that the expected behaviour? I thought that would
only be the case if there are circular dependencies.

I'm using Gradle 1.1 by the way. The project is here:
https://github.com/robfletcher/betamax

Regards,
Rob

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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Groovy & Java cross compilation

Rajiv Narula
In our case the dependency was revers , and we did it as follows
Maybe this gives you a clue?



sourceSets{
    main{
        java { srcDirs = [] } // no source dirs
        groovy { srcDir 'src/main/java' } // includes all .groovy and .java files under src
        resources{
            srcDir 'src/main/java'
            srcDir 'src/main/resources'
        }
    }


On Mon, Aug 6, 2012 at 12:38 PM, Robert Fletcher <[hidden email]> wrote:
Hi

I have a project with a single Java class and a whole bunch of Groovy
classes. The Java class contains no reference to any Groovy classes
but several Groovy classes reference the Java class. I found that
compilation would fail unless I keep the Java class under
src/main/groovy. Is that the expected behaviour? I thought that would
only be the case if there are circular dependencies.

I'm using Gradle 1.1 by the way. The project is here:
https://github.com/robfletcher/betamax

Regards,
Rob

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

    http://xircles.codehaus.org/manage_email





--
-Rajiv
www.rajivnarula.com
Reply | Threaded
Open this post in threaded view
|

Re: Groovy & Java cross compilation

Luke Daley-2
In reply to this post by Rob Fletcher

On 06/08/2012, at 5:38 PM, Robert Fletcher wrote:

> Hi
>
> I have a project with a single Java class and a whole bunch of Groovy
> classes. The Java class contains no reference to any Groovy classes
> but several Groovy classes reference the Java class. I found that
> compilation would fail unless I keep the Java class under
> src/main/groovy. Is that the expected behaviour?

Yes.

> I thought that would only be the case if there are circular dependencies.

Is there something in the documentation that says this? If so we should fix it.

The Java compile step does not feed into the Groovy compile step (that I can see), so you'll need to put the Java source in the 'groovy' dir to use it from Groovy.

--
Luke Daley
Principal Engineer, Gradleware
http://gradleware.com


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

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Groovy & Java cross compilation

Rob Fletcher
On Mon, Aug 6, 2012 at 6:33 PM, Luke Daley <[hidden email]> wrote:
>
> Is there something in the documentation that says this? If so we should fix it.
>

I think I picked up that impression from a blog post I read when I was
googling for a solution. If that's expected I have no problem with it,
I just found it surprising.

Rob

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

    http://xircles.codehaus.org/manage_email