code: public void setThreadContextLoader() {
          if (isContextLoaderSaved) {
              throw new BuildException("Context loader has not been reset");
          }
          if (LoaderUtils.isContextLoaderAvailable()) {
              savedContextLoader = LoaderUtils.getContextClassLoader();
              ClassLoader loader = this;
              if (project != null && "only".equals(project.getProperty("build.sysclasspath"))) {
                  loader = this.getClass().getClassLoader();
              }
              LoaderUtils.setContextClassLoader(loader);
              isContextLoaderSaved = true;
          }
      }
docs: Sets the current thread's context loader to this classloader, storing
  the current loader value for later resetting.