boolean (boolean forStubs, String argsPath, @Nullable String configScript, @Nullable String targetBytecode, @Nullable Queue<? super Object> mailbox, @NotNull PrintStream out, @NotNull PrintStream err) { File argsFile = new File(argsPath); CompilerConfiguration config = createCompilerConfiguration(targetBytecode); config.setClasspath(""); //noinspection deprecation,ImplicitDefaultCharsetUsage config.setOutput(new PrintWriter(err)); config.setWarningLevel(WarningMessage.PARANOIA); final List<GroovyCompilerMessage> compilerMessages = new ArrayList<>(); final List<CompilationUnitPatcher> patchers = new ArrayList<>(); final List<File> srcFiles = new ArrayList<>(); final Map<String, File> class2File = new HashMap<>(); final String[] finalOutputRef = new String[1]; fillFromArgsFile(argsFile, config, patchers, compilerMessages, srcFiles, class2File, finalOutputRef, err); if (srcFiles.isEmpty()) return true; String[] finalOutputs = finalOutputRef[0].split(File.pathSeparator); if (forStubs) { Map<String, Object> options = new HashMap<>(); options.put(STUB_DIR, config.getTargetDirectory()); options.put("keepStubs", Boolean.TRUE); config.setJointCompilationOptions(options); if (mailbox != null) { config.setTargetDirectory(finalOutputs[0]); } } try { boolean asm = !"false".equals(System.getProperty(GroovyRtConstants.GROOVYC_ASM_RESOLVING_ONLY)); config.getOptimizationOptions().put("asmResolving", asm); config.getOptimizationOptions().put("classLoaderResolving", !asm); } catch (NoSuchMethodError ignored) { // old groovyc's don't have optimization options } if (configScript != null && !configScript.isEmpty()) { try { applyConfigurationScript(new File(configScript), config, err); } catch (LinkageError ignored) { } } out.println(GroovyRtConstants.PRESENTABLE_MESSAGE + "Groovyc: loading sources…"); renameResources(finalOutputs, "", TEMP_RESOURCE_SUFFIX); final List<OutputItem> compiledFiles; try { final AstAwareResourceLoader resourceLoader = new AstAwareResourceLoader(class2File); final GroovyCompilerWrapper wrapper = new GroovyCompilerWrapper(compilerMessages, forStubs); final CompilationUnit unit = createCompilationUnit( forStubs, config, buildClassLoaderFor(config, resourceLoader), mailbox, wrapper, out, err ); unit.addPhaseOperation(new CompilationUnit.SourceUnitOperation() { @Override public void call(SourceUnit source) throws CompilationFailedException { File file = new File(source.getName()); for (ClassNode aClass : source.getAST().getClasses()) { resourceLoader.myClass2File.put(aClass.getName(), file); } } @Override @SuppressWarnings("RedundantMethodOverride") public void doPhaseOperation(CompilationUnit unit) throws CompilationFailedException { super.doPhaseOperation(unit); } }, Phases.CONVERSION); addSources(forStubs, srcFiles, unit); runPatchers(patchers, compilerMessages, unit, resourceLoader, srcFiles); out.println(GroovyRtConstants.PRESENTABLE_MESSAGE + "Groovyc: compiling…"); compiledFiles = wrapper.compile(unit, forStubs && mailbox == null ? Phases.CONVERSION : Phases.ALL); } finally { renameResources(finalOutputs, TEMP_RESOURCE_SUFFIX, ""); out.println(GroovyRtConstants.CLEAR_PRESENTABLE); } out.println(); reportCompiledItems(out, compiledFiles); int errorCount = 0; for (GroovyCompilerMessage message : compilerMessages) { if (GroovyCompilerMessageCategories.ERROR.equals(message.getCategory())) { if (errorCount > 100) { continue; } errorCount++; } printMessage(out, message); } return false; }