This applies to 9 through 11. Use https://ant.apache.org/manual/Tasks/conditions.html#javaversion to fail the build explicitly if the Java buld time version is not met just like done with ant.version.required. 8.5.x is out of scope since Ant 1.9 does not support this task. When you build only once in a while you simply forget to switch to the required Java version and see obscure error messages. This we can do better with this task.
It is supported in Ant 1.9 as well (since 1.9.10): https://ant.apache.org/manual-1.9.x/Tasks/conditions.html Where do you want to place this test, and what version to check? Compilation is expected to be done with Java 11, but tests can be run with an earlier version, IIRC.
(In reply to Konstantin Kolinko from comment #1) > It is supported in Ant 1.9 as well (since 1.9.10): > https://ant.apache.org/manual-1.9.x/Tasks/conditions.html > > Where do you want to place this test, and what version to check? It should be tested right after https://github.com/apache/tomcat/blob/29aaefd2944d6ec50505c21d6fd0346a71360388/build.xml#L41-L54 > Compilation is expected to be done with Java 11, but tests can be run with > an earlier version, IIRC. This seems to be a good point, toolchains missing here. Should it go like: JAVA_VERSION=11 ant compile JAVA_VERSION=8 ant test ? Does one use this? One can also pass a JVM argument to <junit /> for another VM, not the one in PATH as far as I can see. Err, looking at https://github.com/apache/tomcat/blob/15927d179401cbc7f82ef8ae1b7c01148b1177f1/build.xml#L1976-L1980 this is not the case anymore. So Java 11 or bust. This is what I have seen as a failure for me when running Tomcat 9 with Java 8 at test time.
(In reply to Michael Osipov from comment #2) > > Compilation is expected to be done with Java 11, but tests can be run with > > an earlier version, IIRC. > > This seems to be a good point, toolchains missing here. > Should it go like: > JAVA_VERSION=11 ant compile > JAVA_VERSION=8 ant test > ? Does one use this? This is what I do for 8.5: build using Java 11 and run all testing using Java 8. I set JAVA_HOME and run "ant test". https://github.com/ChristopherSchultz/apache-tomcat-stuff/blob/master/bin/test-tomcat-release.sh > So Java 11 or bust. Java 11 is only required for the build. For testing you can: https://github.com/ChristopherSchultz/apache-tomcat-stuff/blob/master/bin/test-tomcat-release.sh#L269-L279
+1 to adding this version check. Anything that causes the build to fail earlier is a Good Thing if it's gonna fail, anyway.
(In reply to Christopher Schultz from comment #3) > (In reply to Michael Osipov from comment #2) > > > Compilation is expected to be done with Java 11, but tests can be run with > > > an earlier version, IIRC. > > > > This seems to be a good point, toolchains missing here. > > Should it go like: > > JAVA_VERSION=11 ant compile > > JAVA_VERSION=8 ant test > > ? Does one use this? > > This is what I do for 8.5: build using Java 11 and run all testing using > Java 8. > > I set JAVA_HOME and run "ant test". > > https://github.com/ChristopherSchultz/apache-tomcat-stuff/blob/master/bin/ > test-tomcat-release.sh > > > So Java 11 or bust. > > Java 11 is only required for the build. For testing you can: > > https://github.com/ChristopherSchultz/apache-tomcat-stuff/blob/master/bin/ > test-tomcat-release.sh#L269-L279 Wow, hacky. With this possible, how one enforce the build JDK version of 11 if you stil want to use 8 to test?
Fixed in: - main for 11.0.0-M13 and onwards - 10.1.x for 10.1.16 and onwards - 9.0.x for 9.0.83 and onwards - 8.5.x for 8.5.96 and onwards Chris, I have addded a property for 8.5 and 9.0 to disable this check to be able to run tests with older Java versions.
Also fixed in: * tomcat-native main for 2.0.7 and onwards