title: How to compile groovy code first with Groovy Android Gradle Plugin
body: <p>I am trying to use <a href="https://github.com/groovy/groovy-android-gradle-plugin" rel="nofollow">https://github.com/groovy/groovy-android-gradle-plugin</a> with Android Studio 1.1.0:</p>
  
  <pre><code>buildscript {
      repositories {
          mavenCentral()
          jcenter()
      }
      dependencies {
          classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.5'
          classpath 'com.android.tools.build:gradle:1.0.1'
      }
  }
  </code></pre>
  
  <hr>
  
  <pre><code>./gradlew -v
  
  ------------------------------------------------------------
  Gradle 2.2.1
  ------------------------------------------------------------
  
  Build time:   2014-11-24 09:45:35 UTC
  Build number: none
  Revision:     6fcb59c06f43a4e6b1bcb401f7686a8601a1fb4a
  
  Groovy:       2.3.6
  Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
  JVM:          1.7.0_65 (Oracle Corporation 24.65-b04)
  OS:           Linux 3.13.0-24-generic amd64
  </code></pre>
  
  <hr>
  
  <pre><code>apply plugin: 'groovyx.grooid.groovy-android'
  ...
  dependencies {
      compile 'org.codehaus.groovy:groovy:2.4.0:grooid'
      compile 'com.android.support:multidex:1.0.0'
  }
  </code></pre>
  
  <hr>
  
  <p>I have some Groovy classes that extend from Android SDK classes and my application Java classes that extend from Groovy classes. Groovy classes are under src/main/groovy and Java classes are under src/main/java.</p>
  
  <p>Groovy:</p>
  
  <pre><code>package com.yavezu.client.android.fragment.models.object;
  import android.support.v4.app.Fragment;
  
  public abstract class ObjectFragment2&lt;E extends Base&gt; extends Fragment {}
  public abstract class ExistingObjectFragment2 &lt;E extends Base&gt; extends ObjectFragment2&lt;E&gt; {}
  </code></pre>
  
  <p>Java:</p>
  
  <pre><code>package com.yavezu.client.android.fragment.models.object;
  public abstract class ObjectViewFragment&lt;E extends Base&gt; extends ExistingObjectFragment2&lt;E&gt; {}
  </code></pre>
  
  <p>When I build my project I get the following error:</p>
  
  <pre><code>Error:(13, 66) error: cannot find symbol class ExistingObjectFragment2
  </code></pre>
  
  <p>It seems that gradle compiles java code first, then groovy code. But here I need the groovy code to be compiled first and then java code, because java code depends on groovy code.</p>
  
  <p>I see two possible solutions this:</p>
  
  <ol>
  <li>Put groovy code in a separate module and depend on it explicitly, but it looks like workaround, since I do not really need an extra module</li>
  <li>Put java code under src/main/groovy. This would probably make java code be compiled with groovyc (please, correct me if I am wrong), but I prefer pure java code to be compiled with javac (for compatibility and performance reasons)</li>
  </ol>
  
  <p>Is there a way to make groovy code compiled before java code in the same module?</p>