code: @SuppressWarnings("unchecked")
      public Set<GroovyClass> compile() throws ScriptCompilationException {
          final CompilerConfiguration conf = compileConfig != null ? compileConfig: CompilerConfiguration.DEFAULT;
          conf.setTolerance(0);
          conf.setVerbose(true);
          conf.setTargetDirectory(targetDir.toFile());
          final ClassLoader buildParentClassloader = parentClassLoader != null ?
              parentClassLoader : Thread.currentThread().getContextClassLoader();
          GroovyClassLoader groovyClassLoader = AccessController.doPrivileged(new PrivilegedAction<GroovyClassLoader>() {
              public GroovyClassLoader run() {
                  return new GroovyClassLoader(buildParentClassloader, conf, false);
              }
          });
  
          CompilationUnit unit = new CompilationUnit(conf, null, groovyClassLoader);
          Set<String> scriptExtensions = conf.getScriptExtensions();
          try {
              for (ScriptArchive scriptArchive : scriptArchives) {
                  Set<String> entryNames = scriptArchive.getArchiveEntryNames();
                  for (String entryName : entryNames) {
                      for (String extension : scriptExtensions) {
                          if (entryName.endsWith(extension)) {
                              // identified groovy file
                              unit.addSource(scriptArchive.getEntry(entryName));
                          }
                      }
                  }
              }
          } catch (IOException e) {
              throw new ScriptCompilationException("Exception loading source files", e);
          }
          for (Path sourceFile : sourceFiles) {
              unit.addSource(sourceFile.toFile());
          }
          try {
              unit.compile(Phases.OUTPUT);
          } catch (CompilationFailedException e) {
             throw new ScriptCompilationException("Exception during script compilation", e);
          }
          return new HashSet<GroovyClass>(unit.getClasses());
      }
docs: Compile the given source and load the resultant classes into a new {@link ClassNotFoundException}
  @return initialized and laoded classes
  @throws ScriptCompilationException