- unpack attached zip
- ensure CompileAntScript.xml references the version of groovy you have locally
- ensure JAVA_HOME is referencing JDK 11
- execute CompileAntScript.xml via Ant (ensure it is executed by JDK 11)
[compile] \groovy\issue\TestCompile.java:3: error: package org.apache.commons.lang3 does not exist
[compile] import static org.apache.commons.lang3
Try running same ant script via JDK 8 and it will compile successfully.
Looking into groovy codebase it seems there is a bug/issue in how org.codehaus.groovy.tools.javac.JavacJavaCompiler.java accumulates classpath entries which should be passed to javac:
It iterates over hierarchy of classloaders and assumes AppClassLoader is an instance of URLClassLoader. This assumption was correct in Java 8 but is not correct in Java 11 (https://blog.codefx.org/java/java-11-migration-guide/ - ‘Casting to URLClassLoader’ chapter). Thus most of jars are not passed to javac as classpath and compilation fails.