private static Collection<String> generateClasspath(CompileContext context, ModuleChunk chunk) { final Set<String> cp = new LinkedHashSet<String>(); // groovy_rt.jar // IMPORTANT! must be the first in classpath cp.addAll(getGroovyRtRoots()); for (File file : ProjectPaths.getCompilationClasspathFiles(chunk, chunk.containsTests(), false, false)) { cp.add(FileUtil.toCanonicalPath(file.getPath())); } for (GroovyBuilderExtension extension : JpsServiceManager.getInstance().getExtensions(GroovyBuilderExtension.class)) { cp.addAll(extension.getCompilationClassPath(context, chunk)); } return cp; }
public static JdkVersionDetector getInstance() { return JpsServiceManager.getInstance().getService(JdkVersionDetector.class); }
@NotNull private GroovycOutputParser runGroovycOrContinuation( CompileContext context, ModuleChunk chunk, JpsGroovySettings settings, Map<ModuleBuildTarget, String> finalOutputs, String compilerOutput, List<File> toCompile, boolean hasStubExcludes) throws Exception { GroovycContinuation continuation = takeContinuation(context, chunk); if (continuation != null) { if (Utils.IS_TEST_MODE || LOG.isDebugEnabled()) { LOG.info("using continuation for " + chunk); } return continuation.continueCompilation(); } final Set<String> toCompilePaths = getPathsToCompile(toCompile); JpsSdk<JpsDummyElement> jdk = getJdk(chunk); String version = jdk == null ? SystemInfo.JAVA_RUNTIME_VERSION : jdk.getVersionString(); boolean inProcess = "true".equals(System.getProperty("groovyc.in.process", "true")); boolean mayDependOnUtilJar = version != null && StringUtil.compareVersionNumbers(version, "1.6") >= 0; boolean optimizeClassLoading = !inProcess && mayDependOnUtilJar && ourOptimizeThreshold != 0 && toCompilePaths.size() >= ourOptimizeThreshold; Map<String, String> class2Src = buildClassToSourceMap(chunk, context, toCompilePaths, finalOutputs); final String encoding = context .getProjectDescriptor() .getEncodingConfiguration() .getPreferredModuleChunkEncoding(chunk); List<String> patchers = new ArrayList<String>(); for (GroovyBuilderExtension extension : JpsServiceManager.getInstance().getExtensions(GroovyBuilderExtension.class)) { patchers.addAll(extension.getCompilationUnitPatchers(context, chunk)); } Collection<String> classpath = generateClasspath(context, chunk); if (LOG.isDebugEnabled()) { LOG.debug("Optimized class loading: " + optimizeClassLoading); LOG.debug("Groovyc classpath: " + classpath); } final File tempFile = GroovycOutputParser.fillFileWithGroovycParameters( compilerOutput, toCompilePaths, finalOutputs.values(), class2Src, encoding, patchers, optimizeClassLoading ? StringUtil.join(classpath, File.pathSeparator) : ""); GroovycFlavor groovyc = inProcess ? new InProcessGroovyc(finalOutputs.values(), hasStubExcludes) : new ForkedGroovyc(optimizeClassLoading, chunk); GroovycOutputParser parser = new GroovycOutputParser(chunk, context); continuation = groovyc.runGroovyc(classpath, myForStubs, settings, tempFile, parser); setContinuation(context, chunk, continuation); return parser; }
public static JpsJavaExtensionService getInstance() { return JpsServiceManager.getInstance().getService(JpsJavaExtensionService.class); }