public DefaultIsolatedAntBuilder( ClassPathRegistry classPathRegistry, ClassLoaderFactory classLoaderFactory) { this.classPathRegistry = classPathRegistry; this.classLoaderFactory = classLoaderFactory; this.libClasspath = new DefaultClassPath(); GroovySystemLoaderFactory groovySystemLoaderFactory = new GroovySystemLoaderFactory(); this.classLoaderCache = new ClassPathToClassLoaderCache(groovySystemLoaderFactory); List<File> antClasspath = Lists.newArrayList(classPathRegistry.getClassPath("ANT").getAsFiles()); // Need tools.jar for compile tasks File toolsJar = Jvm.current().getToolsJar(); if (toolsJar != null) { antClasspath.add(toolsJar); } antLoader = classLoaderFactory.createIsolatedClassLoader(new DefaultClassPath(antClasspath)); FilteringClassLoader loggingLoader = new FilteringClassLoader(getClass().getClassLoader()); loggingLoader.allowPackage("org.slf4j"); loggingLoader.allowPackage("org.apache.commons.logging"); loggingLoader.allowPackage("org.apache.log4j"); loggingLoader.allowClass(Logger.class); loggingLoader.allowClass(LogLevel.class); this.baseAntLoader = new CachingClassLoader(new MultiParentClassLoader(antLoader, loggingLoader)); // Need gradle core to pick up ant logging adapter, AntBuilder and such ClassPath gradleCoreUrls = classPathRegistry.getClassPath("GRADLE_CORE"); gradleCoreUrls = gradleCoreUrls.plus(classPathRegistry.getClassPath("GROOVY")); // Need Transformer (part of AntBuilder API) from base services gradleCoreUrls = gradleCoreUrls.plus(classPathRegistry.getClassPath("GRADLE_BASE_SERVICES")); this.antAdapterLoader = new URLClassLoader(gradleCoreUrls.getAsURLArray(), baseAntLoader); gradleApiGroovyLoader = groovySystemLoaderFactory.forClassLoader(this.getClass().getClassLoader()); antAdapterGroovyLoader = groovySystemLoaderFactory.forClassLoader(antAdapterLoader); // register finalizer for the root builder only! FINALIZERS.add(new Finalizer(this, FINALIZER_REFQUEUE)); }