![gradle not compiling java gradle not compiling java](https://codefresh.io/docs/images/learn-by-example/java/gradle-ci-pipeline.png)
I am still at at loss as to why this happens and more importantly how to prevent the classpath leakage.Īny gradle gurus please feel free to chime in here, I would be very interested in getting to the bottom of this issue.Ĭompiling and testing for Java 6 or Java 7 Like you stated, the above compilation should have failed, but didn't. What I mean by this is that it seems that even though you compile using the java 6 executable, the java 8 classpath and APIs leak into the compilation process. However, it also seems to me that the classpaths leak. In other words, it seems to me that using the forkOptions.executable on the compile task works and the classes are indeed compiled using java 6. Java 6 uses major version 50 Java 7 uses major version 51 Java 8 uses major version 52 Java 9 uses major version 53 Java 10 uses major version 54 Java 11 uses major version 55 On linux you can check this using a command line hex editor on the class files: It seems that the class does get compiled using java 6. > Configure project : * * * * * * * * * * * * * * * * java version notice * * * * * * * * * * * * * * * * NOTE : the gradle process and the source compilationĪre using different versions of java : gradle process uses : 1.8 source complilation uses : 1.6 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * BUILD SUCCESSFUL in 1 s Java - version - experiment ~ > gradle build
![gradle not compiling java gradle not compiling java](https://miro.medium.com/max/866/1*uzqs23whsEhlscWH_WsvDA.png)
Java - version - experiment ~ > gradle - v
![gradle not compiling java gradle not compiling java](https://aws1.discourse-cdn.com/gradle/original/2X/a/a82346deadd6984c2494c1784d3eee8800b4d185.png)
PATH updated - JAVA_HOME = / usr / lib / jvm / java - 8 - oracle Java - version - experiment ~ > setjava java - 8 - oracle Java - version - experiment ~ > export JAVA_HOME_6 = / usr / lib / jvm / java - 6_121 - oracle Apply plugin : 'groovy' repositories Īnd I dropped the class in your question into a file at: