Developer's Diary
Software development, with Terry Ebdon
09-Jul-2020 Gradle broken

Mixed compilation

I recently tried a mixed language project, using Java and Groovy. Gradle seemed to get very confused when source code for both languages was present. I assumed this was due to joint compilation not being correctly configured. i.e. it was using both the Java compiler and the Groovy compiler, instead of using groovyc for both. It might not be that simple; I may be a fundamental Gradle problem.

New Groovy projects fail

This morning I created a template Groovy app, using gradle init. It builds and the tests run. The gradle run then fails with a class not found error. This is the same issue I had with the Java + Groovy project. The main *.class files are being deleted after the build task runs. (So how does the test succeed?) They do exist in the distribution zip though, and unzipping that into a temp folder giver a running app. This is exactly the same issue I had with my mixed language project. I dropped back to Java 8 and saw the same problem.

Old vs New

I then switched to my previously working Trk21 project. The gradle run works fine, and I could see the *.class files had been recreated. Switching between gradlew and gradle commands, which use different versions of Gradle, made no difference. Also the Trk21 distribution zip is fine. Well that's all a bit odd.

25-JUN-2020 👈 Top of page 👉 10-JUL-2020

© 2020 Terry Ebdon.

Find me coding on GitHub, networking on LinkedIn, answering questions on Stack Exchange and hanging out on twitter.