简体   繁体   中英

How to force Gradle to re-compile all subprojects sources?

I have a multi-modules Gradle project.

I compiled everything with Java 8 just to find out that my project does not work in Java 8 (some Groovy or Swing issue), so I changed my java back to Java 7, but now when I try to run, even after doing gradle clean run which I thought would re-compile everything ( run depends on jar ), I get Unsupported major.minor version 52.0 which from experience means my class files were compiled with a Java version higher than I am trying to run it with (or some class files were compiled with incompatible java versions).

Looks like the only way to force Gradle to recompile a subproject is to change some source file... but as I have quite a few subprojects, this is too inconvenient. Is there some way to force Gradle to re-compile everything even without any changes?

It turns out it was something else causing my problem... I had changed my Java version using update-alternatives --config java , but unfortunately this does not change JAVA_HOME which Gradle seems to use for compilation... but the plugin I was using to run the code does not care about JAVA_HOME and just uses the system java... as JAVA_HOME and /usr/bin/java have different versions, that's what was causing my issue!

Sorry if anyone wasted any time on this... but hope this might actually help anyone else in the future :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM