protected GroovyClassLoader buildClassLoaderFor() {
ClassLoader parent = getIncludeantruntime()
? getClass().getClassLoader()
: new AntClassLoader(new RootLoader(new URL[0], null), getProject(), getClasspath());
if (parent instanceof AntClassLoader) {
AntClassLoader antLoader = (AntClassLoader) parent;
String[] pathElm = antLoader.getClasspath().split(File.pathSeparator);
List<String> classpath = configuration.getClasspath();
/*
* Iterate over the classpath provided to groovyc, and add any missing path
* entries to the AntClassLoader. This is a workaround, since for some reason
* 'directory' classpath entries were not added to the AntClassLoader' classpath.
*/
for (String cpEntry : classpath) {
boolean found = false;
for (String path : pathElm) {
if (cpEntry.equals(path)) {
found = true;
break;
}
}
/*
* fix for GROOVY-2284
* seems like AntClassLoader doesn't check if the file
* may not exist in the classpath yet
*/
if (!found && new File(cpEntry).exists())
antLoader.addPathElement(cpEntry);
}
}
GroovyClassLoader loader = new GroovyClassLoader(parent, configuration);
// in command line we don't need to do script lookups