[英]How to force Gradle to re-compile all subprojects sources?
I have a multi-modules Gradle project. 我有一个多模块Gradle项目。
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). 我使用Java 8编译了所有内容,只是为了发现我的项目无法在Java 8中运行(某些Groovy或Swing问题),所以我将Java改回了Java 7,但是现在当我尝试运行时,即使进行了
gradle clean run
我认为会重新编译所有内容的run
( run
取决于jar
),我得到了Unsupported major.minor version 52.0
,根据经验,这意味着我的类文件使用的Java版本比我尝试使用的版本更高(或某些类)文件使用不兼容的Java版本进行编译)。
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. 看起来强迫Gradle重新编译子项目的唯一方法是更改某些源文件...但是由于我有很多子项目,所以这太不方便了。 Is there some way to force Gradle to re-compile everything even without any changes?
有什么方法可以强制Gradle重新编译所有内容,即使没有任何更改?
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! 原来是其他原因导致了我的问题...我已经使用
update-alternatives --config java
更改了Java版本,但是不幸的是,这并没有改变Gradle似乎用于编译的JAVA_HOME
...但是我使用的插件使用运行代码并不关心JAVA_HOME
而只使用系统java ...,因为JAVA_HOME
和/usr/bin/java
具有不同的版本,这就是造成我的问题的原因!
Sorry if anyone wasted any time on this... but hope this might actually help anyone else in the future :) 抱歉,如果有人在此上浪费了任何时间...但是希望这将来可能对其他人有所帮助:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.