Пример #1
0
  @NotNull
  public static CompilerConfiguration compilerConfigurationForTests(
      @NotNull ConfigurationKind configurationKind,
      @NotNull TestJdkKind jdkKind,
      @NotNull List<File> classpath,
      @NotNull List<File> javaSource) {
    CompilerConfiguration configuration = new CompilerConfiguration();
    JvmContentRootsKt.addJavaSourceRoots(configuration, javaSource);
    if (jdkKind == TestJdkKind.MOCK_JDK) {
      JvmContentRootsKt.addJvmClasspathRoot(configuration, findMockJdkRtJar());
    } else if (jdkKind == TestJdkKind.ANDROID_API) {
      JvmContentRootsKt.addJvmClasspathRoot(configuration, findAndroidApiJar());
    } else {
      JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRoots());
    }

    if (configurationKind.getWithRuntime()) {
      JvmContentRootsKt.addJvmClasspathRoot(
          configuration, ForTestCompileRuntime.runtimeJarForTests());
    }
    if (configurationKind.getWithReflection()) {
      JvmContentRootsKt.addJvmClasspathRoot(
          configuration, ForTestCompileRuntime.reflectJarForTests());
    }

    JvmContentRootsKt.addJvmClasspathRoots(configuration, classpath);

    configuration.put(MODULE_NAME, "compilerConfigurationForTests");

    return configuration;
  }
Пример #2
0
 public static void compileKotlinWithJava(
     @NotNull List<File> javaFiles,
     @NotNull List<File> ktFiles,
     @NotNull File outDir,
     @NotNull Disposable disposable,
     @Nullable File javaErrorFile)
     throws IOException {
   if (!ktFiles.isEmpty()) {
     compileKotlinToDirAndGetAnalysisResult(ktFiles, outDir, disposable, ALL, false);
   } else {
     boolean mkdirs = outDir.mkdirs();
     assert mkdirs : "Not created: " + outDir;
   }
   if (!javaFiles.isEmpty()) {
     compileJavaFiles(
         javaFiles,
         Arrays.asList(
             "-classpath",
             outDir.getPath() + File.pathSeparator + ForTestCompileRuntime.runtimeJarForTests(),
             "-d",
             outDir.getPath()),
         javaErrorFile);
   }
 }