I moved a couple files from src/main/groovy/ to src/main/java/, followed by changing the associated file suffixes from .groovy to .java. My project would not build until I removed the .gradle/ cache in the project current working directory. The compiler complained that it could not find the files/classes that had moved.
Ok, I am able to reproduce this in a test project.
Here is my console output:
mb:gradle-rename-enum> find .
.
./build.gradle
./src
./src/main
./src/main/groovy
./src/main/groovy/somepackage
./src/main/groovy/somepackage/AScript.groovy
./src/main/groovy/somepackage/SomeEnum.groovy
./src/main/java
./src/main/java/somepackage
mb:gradle-rename-enum> gradle -q build
mb:gradle-rename-enum> mv -v src/main/groovy/somepackage/SomeEnum.groovy src/main/java/somepackage/SomeEnum.java
src/main/groovy/somepackage/SomeEnum.groovy -> src/main/java/somepackage/SomeEnum.java
mb:gradle-rename-enum> gradle -q build
startup failed:
/Users/petrovic/Projects/gradle-rename-enum/src/main/groovy/somepackage/AScript.groovy: 6: unable to resolve class SomeEnum
@ line 6, column 18.
SomeEnum someEnum = SomeEnum.A
^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
mb:gradle-rename-enum> rm -rf .gradle/
mb:gradle-rename-enum> gradle -q build
# no problems
gradle -v
------------------------------------------------------------
Gradle 1.2
------------------------------------------------------------
Gradle build time: Wednesday, September 12, 2012 10:46:02 AM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.6.0_37 (Apple Inc. 20.12-b01-434)
OS: Mac OS X 10.6.8 x86_64
Thanks for the sample project. I can reproduce the problem. It’s caused by Gradle’s compilation tasks deleting all class files they produced last time before they compile again. This prevents stale class files issues but causes some new issues like the one you discovered. I’ve created GRADLE-2574 for this.
Note that you can avoid this problem by using Java Groovy joint compilation - either put Java files into src/main/groovy, or configure src/main/java to be a Groovy source dir (and remove it as a Java source dir). Then ‘compileGroovy’ will compile both your Java and Groovy classes, and you can have arbitrary dependencies between them.