public void setThreadContextLoader() { if (this.isContextLoaderSaved) { throw new BuildException("Context loader has not been reset"); } if (LoaderUtils.isContextLoaderAvailable()) { this.savedContextLoader = LoaderUtils.getContextClassLoader(); ClassLoader loader = this; if (this.project != null && "only".equals(this.project.getProperty("build.sysclasspath"))) { loader = this.getClass().getClassLoader(); } LoaderUtils.setContextClassLoader(loader); this.isContextLoaderSaved = true; } }