- Then run this from IJ using 'classpath of module' setting to match the proper module for pl/pc/cc etc. (this is so the global loaders will be in the classpath)
324782
public static void main( String[] args ) throws FileNotFoundException {
    String error = GosucArg.parseArgs( args );
    if( error != null ) {
      System.err.println( error );
      return;
    }
    String strFile = GosucArg.PROJECT.getValue();
    Gosuc gosuc = new Gosuc( strFile, maybeGetCustomParser() );
    gosuc.initializeGosu();
    gosuc.compile( (String)null, Collections.singletonList( "-all" ) );
  }
604259
protected void loadClasses(Path pluginPath, PluginClassLoader pluginClassLoader) {
        for (String directory : pluginClasspath.getClassesDirectories()) {
            File file = pluginPath.resolve(directory).toFile();
            if (file.exists() && file.isDirectory()) {
                pluginClassLoader.addFile(file);
            }
        }
    }
1110497
def load(self, *modules):
        
        for module in modules:
            if isinstance(module, six.string_types):
                try:
                    module = get_object(module)
                except Exception as e:
                    self.errors[module] = e
                    continue
            self.modules[module.__package__] = module
            for (loader, module_name, is_pkg) in pkgutil.walk_packages(
                module.__path__
            ):
                full_name = "{}.{}".format(_package(module), module_name)
                try:
                    self.modules[full_name] = get_object(full_name)
                    if is_pkg:
                        self.load(self.modules[full_name])
                except Exception as e:
                    self.errors[full_name] = e
378626
private static LookupResult findByClassLoading(String name, CompilationUnit compilationUnit, GroovyClassLoader loader) {
        Class cls;
        try {
            // NOTE: it's important to do no lookup against script files
            // here since the GroovyClassLoader would create a new CompilationUnit
            cls = loader.loadClass(name, false, true);
        } catch (ClassNotFoundException cnfe) {
            LookupResult lr = tryAsScript(name, compilationUnit, null);
            return lr;
        } catch (CompilationFailedException cfe) {
            throw new GroovyBugError("The lookup for " + name + " caused a failed compilation. There should not have been any compilation from this call.", cfe);
        }
        //TODO: the case of a NoClassDefFoundError needs a bit more research
        // a simple recompilation is not possible it seems. The current class
        // we are searching for is there, so we should mark that somehow.
        // Basically the missing class needs to be completely compiled before
        // we can again search for the current name.
        /*catch (NoClassDefFoundError ncdfe) {
            cachedClasses.put(name,SCRIPT);
            return false;
        }*/
        if (cls == null) return null;
        //NOTE: we might return false here even if we found a class,
        //      because  we want to give a possible script a chance to
        //      recompile. This can only be done if the loader was not
        //      the instance defining the class.
        ClassNode cn = ClassHelper.make(cls);
        if (cls.getClassLoader() != loader) {
            return tryAsScript(name, compilationUnit, cn);
        }
        return new LookupResult(null,cn);
    }
702653
public static Proto loadFromClasspath(String path, Proto importer) throws Exception
    {
        URL resource = getResource(path, DefaultProtoLoader.class);
        if (resource == null)
            return null;

        Proto proto = new Proto(resource, DEFAULT_INSTANCE, importer);
        ProtoUtil.loadFrom(resource, proto);
        return proto;
    }
464896
public function setupPackageAutoloaders()
    {
        $pla = \Concrete\Core\Package\PackageList::get();
        $pl = $pla->getPackages();
        $cl = ClassLoader::getInstance();
        /** @var \Package[] $pl */
        foreach ($pl as $p) {
            \Config::package($p);
            if ($p->isPackageInstalled()) {
                $pkg = $this->make('Concrete\Core\Package\PackageService')->getClass($p->getPackageHandle());
                if (is_object($pkg) && (!$pkg instanceof \Concrete\Core\Package\BrokenPackage)) {
                    $cl->registerPackage($pkg);
                    $this->packages[] = $pkg;
                }
            }
        }
    }
656550
private String buildClassPath()
  {
    String classPath = null;//_classPath;

    if (classPath != null) {
      return classPath;
    }

    if (classPath == null && _loader instanceof DynamicClassLoader) {
      classPath = ((DynamicClassLoader) _loader).getClassPath();
    }
    else { // if (true || _loader instanceof URLClassLoader) {
      StringBuilder sb = new StringBuilder();
      sb.append(CauchoUtil.getClassPath());

      if (_loader != null)
        buildClassPath(sb, _loader);

      classPath = sb.toString();
    }
    //else if (classPath == null)
      //classPath = CauchoSystem.getClassPath();

    String srcDirName = getSourceDirName();
    String classDirName = getClassDirName();

    char sep = CauchoUtil.getPathSeparatorChar();

    if (_extraClassPath != null)
      classPath = classPath + sep + _extraClassPath;

    // Adding the srcDir lets javac and jikes find source files
    if (! srcDirName.equals(classDirName))
      classPath = srcDirName + sep + classPath;
    classPath = classDirName + sep + classPath;

    return classPath;
  }
512883
private GroovyClassLoader initGroovyLoader() {
        GroovyClassLoader groovyClassLoader =
                AccessController.doPrivileged(new PrivilegedAction<ScriptClassLoader>() {
                    public ScriptClassLoader run() {
                        if (parentLoader instanceof GroovyClassLoader) {
                            return new ScriptClassLoader((GroovyClassLoader) parentLoader);
                        } else {
                            return new ScriptClassLoader(parentLoader, config);
                        }
                    }
                });
        for (URL root : roots) groovyClassLoader.addURL(root);
        return groovyClassLoader;
    }
623200
private final String nGetLoaderPath() {
		ClassLoader currentLoader = this;
		final StringBuffer buffer = new StringBuffer();
		buffer.append(this.name);

		while ((currentLoader = currentLoader.getParent()) != null) {
			if (currentLoader.getClass() == CClassLoader.class) {
				buffer.insert(0, "/");
				buffer.insert(0, ((CClassLoader) currentLoader).name);
			} else {
				break;
			}
		}

		return buffer.toString();
	}
318717
static InternalConfig load() throws JsonParseException, JsonMappingException, IOException {
        // First try loading via the class by using a relative path
        URL url = ClassLoaderHelper.getResource(DEFAULT_CONFIG_RESOURCE_RELATIVE_PATH, true, InternalConfig.class); // classesFirst=true
        if (url == null) { // Then try with the absolute path
            url = ClassLoaderHelper.getResource(DEFAULT_CONFIG_RESOURCE_ABSOLUTE_PATH, InternalConfig.class);
        }
        InternalConfigJsonHelper config = loadfrom(url);
        InternalConfigJsonHelper configOverride;
        URL overrideUrl = ClassLoaderHelper.getResource("/" + CONFIG_OVERRIDE_RESOURCE, InternalConfig.class);
        if (overrideUrl == null) { // Try without a leading "/"
            overrideUrl = ClassLoaderHelper.getResource(CONFIG_OVERRIDE_RESOURCE, InternalConfig.class);
        }
        if (overrideUrl == null) {
            log.debug("Configuration override " + CONFIG_OVERRIDE_RESOURCE + " not found.");
            configOverride = new InternalConfigJsonHelper();
        } else {
            configOverride = loadfrom(overrideUrl);
        }
        InternalConfig merged = new InternalConfig(config, configOverride);
        merged.setDefaultConfigFileLocation(url);
        merged.setOverrideConfigFileLocation(overrideUrl);
        return merged;
    }
201685
def _import_module(module_path, classnames):
    
    try:
        imported_module = __import__(module_path, fromlist=classnames)
        return imported_module
    except ImportError:
        # In case of an ImportError, the module being loaded generally does not exist. But an
        # ImportError can occur if the module being loaded exists and another import located inside
        # it failed.
        #
        # In order to provide a meaningfull traceback, the execution information can be inspected in
        # order to determine which case to consider. If the execution information provides more than
        # a certain amount of frames, this means that an ImportError occured while loading the
        # initial Python module.
        __, __, exc_traceback = sys.exc_info()
        frames = traceback.extract_tb(exc_traceback)
        if len(frames) > 1:
            raise
73351
private final void init(boolean useClassLoader) {
		final CYaHPConverter converter = this;
		System.out.println("Initializing...");
		long time = System.currentTimeMillis();
		
		if (!useClassLoader) {
			System.out.println("init time: "+(System.currentTimeMillis()-time));
			return;
		}

		// if classloader is init return.
		if (CClassLoader.getRootLoader().isInit()) {
			return;
		} // end if
		// ensure the temporary files are delete on exit.
		Runtime.getRuntime().addShutdownHook(new Thread() {
				public void run() {
					try {
						converter.finalize();
					} // end try
					catch (final Throwable e) {}
				} // end run()
			} // end new
		);

		ClassLoader loader = this.getClass().getClassLoader();
		CClassLoaderConfig config = new CClassLoaderConfig();
		config.addLoaderInfo("/main",
			new CClassLoaderConfig.CLoaderInfo(true, true, false, false));
		config.addFile("/main", loader.getResource("itext-yahp.jar"));
		config.addFile("/main", loader.getResource("tidy-yahp.jar"));
		config.addFile("/main", loader.getResource("log4j-yahp.jar"));
		config.addFile("/main", loader.getResource("shanijar-yahp.jar"));
		config.addFile("/main", loader.getResource("xmlapi-yahp.jar"));
		config.addFile("/main", loader.getResource("yahp-internal.jar"));
		config.addFile("/main", loader.getResource("commonio-yahp.jar"));
		config.addFile("/main", loader.getResource("commonlog-yahp.jar"));
		config.addFile("/main", loader.getResource("core-renderer-yahp.jar"));
		config.addFile("/main", loader.getResource("jaxen-yahp.jar"));
		CClassLoader.init(config);
		try {
			URL url = CClassLoader.getRootLoader().getResource("log4j.properties");
			if (url != null) {
				ClassLoader cx = Thread.currentThread().getContextClassLoader();
				try {
					Thread.currentThread().setContextClassLoader(CClassLoader.getRootLoader());
					Class pc = CClassLoader.getRootLoader().loadClass("org.apache.log4j.PropertyConfigurator");
					Method configure = pc.getDeclaredMethod("configure", new Class[]{URL.class});
					configure.invoke(null, new Object[]{url});
				}
				finally {
					Thread.currentThread().setContextClassLoader(cx);
				}
			}
		}
		catch(Exception ignore){}
		System.out.println("init time: "+(System.currentTimeMillis()-time));
	}
154646
@GwtIncompatible("Unnecessary")
  protected int doRun() throws IOException {
    Compiler.setLoggingLevel(Level.parse(config.loggingLevel));

    compiler = createCompiler();
    B options = createOptions();
    setRunOptions(options);

    List<SourceFile> externs = createExterns(options);
    List<JSModule> modules = null;
    Result result = null;

    rootRelativePathsMap = constructRootRelativePathsMap();

    boolean writeOutputToFile = !config.jsOutputFile.isEmpty();
    List<String> outputFileNames = new ArrayList<>();
    if (writeOutputToFile) {
      outputFileNames.add(config.jsOutputFile);
    }

    boolean createCommonJsModules = false;
    if (options.processCommonJSModules
        && (config.module.size() == 1 && "auto".equals(config.module.get(0)))) {
      createCommonJsModules = true;
      config.module.remove(0);
    }

    List<JsModuleSpec> jsModuleSpecs = new ArrayList<>();
    for (int i = 0; i < config.module.size(); i++) {
      jsModuleSpecs.add(JsModuleSpec.create(config.module.get(i), i == 0));
    }
    List<JsonFileSpec> jsonFiles = null;

    if (config.jsonStreamMode == JsonStreamMode.IN ||
        config.jsonStreamMode == JsonStreamMode.BOTH) {
      jsonFiles = parseJsonFilesFromInputStream();

      ImmutableMap.Builder<String, SourceMapInput> inputSourceMaps
          = new ImmutableMap.Builder<>();
      ImmutableMap.Builder<String, String> inputPathByWebpackId = new ImmutableMap.Builder<>();

      boolean foundJsonInputSourceMap = false;
      for (JsonFileSpec jsonFile : jsonFiles) {
        if (jsonFile.getSourceMap() != null && jsonFile.getSourceMap().length() > 0) {
          String sourceMapPath = jsonFile.getPath() + ".map";
          SourceFile sourceMap = SourceFile.fromCode(sourceMapPath,
              jsonFile.getSourceMap());
          inputSourceMaps.put(jsonFile.getPath(), new SourceMapInput(sourceMap));
          foundJsonInputSourceMap = true;
        }
        if (jsonFile.getWebpackId() != null) {
          inputPathByWebpackId.put(jsonFile.getWebpackId(), jsonFile.getPath());
        }
      }

      if (foundJsonInputSourceMap) {
        inputSourceMaps.putAll(options.inputSourceMaps);
        options.inputSourceMaps = inputSourceMaps.build();
      }

      compiler.initWebpackMap(inputPathByWebpackId.build());
    } else {
      ImmutableMap<String, String> emptyMap = ImmutableMap.of();
      compiler.initWebpackMap(emptyMap);
    }

    compiler.initWarningsGuard(options.getWarningsGuard());

    List<SourceFile> inputs =
        createSourceInputs(jsModuleSpecs, config.mixedJsSources, jsonFiles, config.moduleRoots);
    if (!jsModuleSpecs.isEmpty()) {
      if (isInTestMode()) {
        modules = modulesSupplierForTesting.get();
      } else {
        if (JsonStreamMode.IN.equals(config.jsonStreamMode)
            || JsonStreamMode.NONE.equals(config.jsonStreamMode)) {
          for (JsModuleSpec m : jsModuleSpecs) {
            checkModuleName(m.getName());
          }
        }
        modules = createJsModules(jsModuleSpecs, inputs);
      }
      for (JSModule m : modules) {
        outputFileNames.add(getModuleOutputFileName(m));
      }

      compiler.initModules(externs, modules, options);
    } else {
      compiler.init(externs, inputs, options);
    }

    if (options.printConfig) {
      compiler.printConfig(System.err);
    }


    String saveAfterChecksFilename = config.getSaveAfterChecksFileName();
    String continueSavedCompilationFilename = config.getContinueSavedCompilationFileName();
    if (config.skipNormalOutputs) {
      // TODO(bradfordcsmith): Should we be ignoring possible init/initModules() errors here?
      compiler.orderInputsWithLargeStack();
    } else if (compiler.hasErrors()) {
      // init() or initModules() encountered an error.
      compiler.generateReport();
      result = compiler.getResult();
    } else if (options.getInstrumentForCoverageOnly()) {
      result = instrumentForCoverage();
    } else if (saveAfterChecksFilename != null) {
      result = performStage1andSave(saveAfterChecksFilename);
    } else if (continueSavedCompilationFilename != null) {
      result = restoreAndPerformStage2(continueSavedCompilationFilename);
      if (modules != null) {
        modules = ImmutableList.copyOf(compiler.getModules());
      }
    } else {
      result = performFullCompilation();
    }

    if (createCommonJsModules) {
      // For CommonJS modules construct modules from actual inputs.
      modules = ImmutableList.copyOf(compiler.getModules());
      for (JSModule m : modules) {
        outputFileNames.add(getModuleOutputFileName(m));
      }
    }

    for (String outputFileName : outputFileNames) {
      if (compiler.getSourceFileByName(outputFileName) != null) {
        compiler.report(
            JSError.make(OUTPUT_SAME_AS_INPUT_ERROR, outputFileName));
        return 1;
      }
    }

    return processResults(result, modules, options);
  }
710486
private void setClassPath() throws IOException {
    String fullPath = file.getAbsolutePath();
    String rootPath = fullPath.substring(0, fullPath.lastIndexOf(classFile.getRelativePath()));
    List<File> classPath = new ArrayList<>();
    classPath.add(new File(rootPath));
    parserEnv.fileManager().setLocation(StandardLocation.CLASS_PATH, classPath);
  }
1347050
public static void compile(Class<?> cls, File outputPath) {
        if (outputPath == null) {
            throw new NullPointerException("Param 'outputPath' is null.");
        }
        if (!outputPath.isDirectory()) {
            throw new RuntimeException("Param 'outputPath' value should be a path directory. path=" + outputPath);
        }

    }
730723
function (parent,config,modulePath,npmPath,classesSource)
	{
		this.e.log&&this.e.log('Constructing new `'+this.className+'`...','system');

		if (modulePath==undefined)
			modulePath = cwd;

		try {
			this.setParent(parent);
		} catch (e)
		{
			if (e)
				console.log(this);
		}

		this.setModulePath(path.resolve(path.resolve(parent.modulePath,modulePath))+'/');

		this.preinit.apply(this,arguments); 

		this.npmPath = npmPath || [];
		this.importClasses(classesSource);

		var defaultConfig = cwd+sourcePath+'config/'+className.split('_')[0]+'Config.json';
		if (fs.existsSync(defaultConfig))
			this.configureFromFile(defaultConfig);
		if (fs.existsSync(this.modulePath + this.configFile))
			this.configureFromFile(this.modulePath + this.configFile);
		if (config)
			this.setConfig(config);

		_debug = this.getConfig('debug')===true;

		this.importPackages();
		this.importFromConfig();

		Object.defineProperty(this,'c',{ value: this.getComponent('classBuilder').classes, enumerable:false, writable: false });
		this.c.module = self;

		this.preloadEvents();
		this.preloadComponents();

		this.setEvents({ 'ready': {} });
		var ready=this.getEvent('ready');
		ready.once(function (e) {
			self.startComponents();
			self.prepareModels();
			self.prepareScripts();

			self.init.apply(self,arguments);
			self.run.apply(self,arguments);
			_initialized=true;
		});
	}
296746
function linkDeclarativeModule(load, loads, loader) {
      if (load.module)
        return;

      var module = load.module = getOrCreateModuleRecord(load.name);
      var moduleObj = load.module.module;

      var registryEntry = load.declare.call(__global, function(name, value) {
        // NB This should be an Object.defineProperty, but that is very slow.
        //    By disaling this module write-protection we gain performance.
        //    It could be useful to allow an option to enable or disable this.

        // bulk export object
        if (typeof name == 'object') {
          for (var p in name)
            moduleObj[p] = name[p];
        }
        // single export name / value pair
        else {
          moduleObj[name] = value;
        }

        for (var i = 0, l = module.importers.length; i < l; i++) {
          var importerModule = module.importers[i];
          if (importerModule.setters) {
            var importerIndex = importerModule.dependencies.indexOf(module);
            if (importerIndex != -1) {
              var setter = importerModule.setters[importerIndex];
              setter(moduleObj);
            }
          }
        }
        return value;
      }, {id: load.name});

      // setup our setters and execution function
      load.module.setters = registryEntry.setters;
      load.module.execute = registryEntry.execute;

      // now link all the module dependencies
      // amending the depMap as we go
      for (var i = 0, l = load.dependencies.length; i < l; i++) {
        var depName = load.dependencies[i].value;
        var depModule = getOrCreateModuleRecord(depName);

        depModule.importers.push(module);

        // if not already a module in the registry, try and link it now
        if (!loader.modules[depName]) {

          // get the dependency load record
          for (var j = 0; j < loads.length; j++) {
            if (loads[j].name != depName)
              continue;

            // only link if already not already started linking (stops at circular / dynamic)
            if (!loads[j].module)
              linkDeclarativeModule(loads[j], loads, loader);
          }
        }

        console.assert(depModule, 'Dependency module not found!');

        module.dependencies.push(depModule);

        // run the setter for this dependency
        if (module.setters[i])
          module.setters[i](depModule.module);
      }

      load.status = 'linked';
    }