# Groovy plugin and mixed Groovy/Java code

**URL:** <https://discuss.gradle.org/t/groovy-plugin-and-mixed-groovy-java-code/5313>\
**Category:** Old Forum Archive\
**Created:** [November 9, 2011, 8:24pm UTC](https://discuss.gradle.org/t/groovy-plugin-and-mixed-groovy-java-code/5313 "2011-11-09T20:24:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mauromol](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mauromol/32/994_2.png) [@mauromol](https://discuss.gradle.org/u/mauromol)\
**Post date:** [November 9, 2011, 8:24pm UTC](https://discuss.gradle.org/t/groovy-plugin-and-mixed-groovy-java-code/5313/1 "2011-11-09T20:24:00Z")

</div>

Is the groovy plugin (apply plugin: ‘groovy’) supposed to compile Groovy code in src/main/groovy requiring Java code compiled from src/main/java in the classpath?

I mean, suppose I have: src/main/java/ClassA.java src/main/groovy/ClassB.groovy

If ClassB imports and uses ClassA, is Gradle supposed to build this project correctly? Or am I forced to put ClassA in src/main/groovy in this case?

I would expect that the standard Java compiler compiles src/main/java/ClassA.java (unless it requires any class from src/main/groovy, of course), while the Groovy compiler, which is run after the Java compiler, compiles the Groovy code in src/main/groovy having the result of the javac compilation from the previous step in the compile classpath.

However, I find myself in a situation in which the Groovy compilation of ClassB fails because it can’t resolve ClassA, which has been compiled immediately before.

Thanks in advance, Mauro.

---

<div class="post-metadata">

**Author:** ![adammurdoch](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/adammurdoch/32/17_2.png) [@adammurdoch](https://discuss.gradle.org/u/adammurdoch)\
**Post date:** [November 9, 2011, 9:24pm UTC](https://discuss.gradle.org/t/groovy-plugin-and-mixed-groovy-java-code/5313/2 "2011-11-09T21:24:00Z")

</div>

Have a look at GRADLE-1190, which describes what you currently need to do to make this work.

---

<div class="post-metadata">

**Author:** ![adammurdoch](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/adammurdoch/32/17_2.png) [@adammurdoch](https://discuss.gradle.org/u/adammurdoch)\
**Post date:** [November 9, 2011, 9:26pm UTC](https://discuss.gradle.org/t/groovy-plugin-and-mixed-groovy-java-code/5313/3 "2011-11-09T21:26:00Z")

</div>

Actually, I misread your question. What you describe should work out of the box. Do you have an error message that shows the problem?

---

<div class="post-metadata">

**Author:** ![mauromol](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/mauromol/32/994_2.png) [@mauromol](https://discuss.gradle.org/u/mauromol)\
**Post date:** [November 10, 2011, 9:06am UTC](https://discuss.gradle.org/t/groovy-plugin-and-mixed-groovy-java-code/5313/4 "2011-11-10T09:06:00Z")

</div>

I was able to extract a simple test case that reproduces my problem. Hence I opened GRADLE-1909.
