use of org.jetbrains.kotlin.cli.jvm.K2JVMCompiler in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method testReleaseCompilerAgainstPreReleaseLibrary.
public void testReleaseCompilerAgainstPreReleaseLibrary() throws Exception {
File destination = new File(tmpdir, "library.jar");
doTestPreReleaseKotlinLibrary(new K2JVMCompiler(), "library", destination, destination);
}
use of org.jetbrains.kotlin.cli.jvm.K2JVMCompiler in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method compileKotlin.
@NotNull
private Pair<String, ExitCode> compileKotlin(@NotNull CLICompiler<?> compiler, @NotNull String fileName, @NotNull File output, @NotNull List<String> additionalOptions, @NotNull File... classpath) {
List<String> args = new ArrayList<String>();
File sourceFile = new File(getTestDataDirectory(), fileName);
assert sourceFile.exists() : "Source file does not exist: " + sourceFile.getAbsolutePath();
args.add(sourceFile.getPath());
if (compiler instanceof K2JSCompiler) {
if (classpath.length > 0) {
args.add("-libraries");
args.add(StringsKt.join(Arrays.asList(classpath), File.pathSeparator));
}
args.add("-output");
args.add(output.getPath());
args.add("-meta-info");
} else if (compiler instanceof K2JVMCompiler) {
if (classpath.length > 0) {
args.add("-classpath");
args.add(StringsKt.join(Arrays.asList(classpath), File.pathSeparator));
}
args.add("-d");
args.add(output.getPath());
} else {
throw new UnsupportedOperationException(compiler.toString());
}
args.addAll(additionalOptions);
return AbstractCliTest.executeCompilerGrabOutput(compiler, args);
}
use of org.jetbrains.kotlin.cli.jvm.K2JVMCompiler in project kotlin by JetBrains.
the class CompileEnvironmentTest method testSmokeWithCompilerOutput.
public void testSmokeWithCompilerOutput() throws IOException {
File tempDir = FileUtil.createTempDirectory("compilerTest", "compilerTest");
try {
File out = new File(tempDir, "out");
File stdlib = ForTestCompileRuntime.runtimeJarForTests();
ExitCode exitCode = new K2JVMCompiler().exec(System.out, KotlinTestUtils.getTestDataPathBase() + "/compiler/smoke/Smoke.kt", "-d", out.getAbsolutePath(), "-no-stdlib", "-classpath", stdlib.getAbsolutePath());
Assert.assertEquals(ExitCode.OK, exitCode);
File[] files = out.listFiles();
Arrays.sort(files);
assertEquals(2, files.length);
//META-INF
assertEquals(1, files[0].listFiles().length);
// SmokeKt
assertEquals(1, files[1].listFiles().length);
} finally {
FileUtil.delete(tempDir);
}
}
use of org.jetbrains.kotlin.cli.jvm.K2JVMCompiler in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method compileLibrary.
private File compileLibrary(@NotNull String sourcePath, List<String> additionalOptions, @NotNull File... extraClassPath) {
File destination = new File(tmpdir, sourcePath + ".jar");
compileLibrary(new K2JVMCompiler(), sourcePath, destination, additionalOptions, extraClassPath);
return destination;
}
use of org.jetbrains.kotlin.cli.jvm.K2JVMCompiler in project kotlin by JetBrains.
the class CompileKotlinAgainstCustomBinariesTest method testReleaseCompilerAgainstPreReleaseLibrarySkipVersionCheck.
public void testReleaseCompilerAgainstPreReleaseLibrarySkipVersionCheck() throws Exception {
File destination = new File(tmpdir, "library.jar");
doTestPreReleaseKotlinLibrary(new K2JVMCompiler(), "library", destination, destination, "-Xskip-metadata-version-check");
}
Aggregations