diff --git a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java index 05129b028e8..239c7461da2 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java +++ b/compiler/cli/cli-common/src/org/jetbrains/jet/cli/common/arguments/K2JVMCompilerArguments.java @@ -24,6 +24,10 @@ import org.jetbrains.annotations.NotNull; */ @SuppressWarnings("UnusedDeclaration") public class K2JVMCompilerArguments extends CommonCompilerArguments { + @Argument(value = "d", description = "Destination for generated class files") + @ValueDescription("") + public String destination; + @Argument(value = "jar", description = "Resulting .jar file path") @ValueDescription("") public String jar; diff --git a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java index 709c20898e9..fddc961ef28 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java @@ -117,8 +117,19 @@ public class K2JVMCompiler extends CLICompiler { try { configureEnvironment(configuration, arguments); - File jar = arguments.jar != null ? new File(arguments.jar) : null; - File outputDir = arguments.outputDir != null ? new File(arguments.outputDir) : null; + String destination = arguments.destination; + + File jar; + File outputDir; + if (destination != null) { + boolean isJar = destination.endsWith(".jar"); + jar = isJar ? new File(destination) : null; + outputDir = isJar ? null : new File(destination); + } + else { + jar = arguments.jar != null ? new File(arguments.jar) : null; + outputDir = arguments.outputDir != null ? new File(arguments.outputDir) : null; + } if (arguments.module != null) { MessageCollector sanitizedCollector = new FilteringMessageCollector(messageCollector, in(CompilerMessageSeverity.VERBOSE)); @@ -129,14 +140,15 @@ public class K2JVMCompiler extends CLICompiler { } if (outputDir != null) { - messageCollector.report(CompilerMessageSeverity.WARNING, "The '-output' option is ignored because '-module' is specified", + messageCollector.report(CompilerMessageSeverity.WARNING, + "The '-d' option with a directory destination is ignored because '-module' is specified", CompilerMessageLocation.NO_LOCATION); } File directory = new File(arguments.module).getAbsoluteFile().getParentFile(); - KotlinToJVMBytecodeCompiler.compileModules(configuration, moduleScript.getModules(), - directory, jar, - arguments.includeRuntime); + KotlinToJVMBytecodeCompiler.compileModules( + configuration, moduleScript.getModules(), directory, jar, arguments.includeRuntime + ); } else if (arguments.script) { List scriptArgs = arguments.freeArgs.subList(1, arguments.freeArgs.size()); diff --git a/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java b/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java index 519c2994d6b..891f431f2b6 100644 --- a/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java +++ b/compiler/integration-tests/src/org/jetbrains/kotlin/CompilerSmokeTest.java @@ -27,7 +27,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase { public void compileAndRunHelloApp() throws Exception { String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar"; - assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-jar", jar)); + assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar)); runJava("hello.run", "-cp", jar, "Hello.HelloPackage"); } @@ -35,7 +35,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase { public void compileAndRunHelloAppFQMain() throws Exception { String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar"; - assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-jar", jar)); + assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar)); runJava("hello.run", "-cp", jar, "Hello.HelloPackage"); } @@ -43,7 +43,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase { public void compileAndRunHelloAppVarargMain() throws Exception { String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar"; - assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-jar", jar)); + assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar)); runJava("hello.run", "-cp", jar, "Hello.HelloPackage"); } @@ -51,7 +51,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase { public void compileAndRunModule() throws Exception { String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar"; - assertEquals("compilation failed", 0, runCompiler("Smoke.compile", "-module", "Smoke.ktm", "-jar", jar)); + assertEquals("compilation failed", 0, runCompiler("Smoke.compile", "-module", "Smoke.ktm", "-d", jar)); runJava("Smoke.run", "-cp", jar + File.pathSeparator + getKotlinRuntimePath(), "Smoke.SmokePackage", "1", "2", "3"); } @@ -59,14 +59,14 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase { public void compilationFailed() throws Exception { String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar"; - runCompiler("hello.compile", "hello.kt", "-jar", jar); + runCompiler("hello.compile", "hello.kt", "-d", jar); } @Test public void syntaxErrors() throws Exception { String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "smoke.jar"; - runCompiler("test.compile", "test.kt", "-jar", jar); + runCompiler("test.compile", "test.kt", "-d", jar); } @Test diff --git a/compiler/testData/cli/jvm/classpath.args b/compiler/testData/cli/jvm/classpath.args index 76f5eeb4053..80f62e61324 100644 --- a/compiler/testData/cli/jvm/classpath.args +++ b/compiler/testData/cli/jvm/classpath.args @@ -1,3 +1,3 @@ $TESTDATA_DIR$/classpath.kt --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/conflictingOverloads.args b/compiler/testData/cli/jvm/conflictingOverloads.args index 7e9dfcea5a3..7a88a051805 100644 --- a/compiler/testData/cli/jvm/conflictingOverloads.args +++ b/compiler/testData/cli/jvm/conflictingOverloads.args @@ -1,3 +1,3 @@ $TESTDATA_DIR$/conflictingOverloads.kt --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/diagnosticsOrder.args b/compiler/testData/cli/jvm/diagnosticsOrder.args index 539695486ca..1d9c2d3c909 100644 --- a/compiler/testData/cli/jvm/diagnosticsOrder.args +++ b/compiler/testData/cli/jvm/diagnosticsOrder.args @@ -1,4 +1,4 @@ $TESTDATA_DIR$/diagnosticsOrder1.kt $TESTDATA_DIR$/diagnosticsOrder2.kt --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/help.args b/compiler/testData/cli/jvm/help.args index e4e7bd57105..97f455ac44e 100644 --- a/compiler/testData/cli/jvm/help.args +++ b/compiler/testData/cli/jvm/help.args @@ -1 +1 @@ --help \ No newline at end of file +-help diff --git a/compiler/testData/cli/jvm/help.out b/compiler/testData/cli/jvm/help.out index 07b188b8a5e..b9015b7214c 100644 --- a/compiler/testData/cli/jvm/help.out +++ b/compiler/testData/cli/jvm/help.out @@ -1,5 +1,6 @@ Usage: kotlinc-jvm where possible options include: + -d Destination for generated class files -jar Resulting .jar file path -output Output directory path for .class files -classpath Paths where to find user class files diff --git a/compiler/testData/cli/jvm/inline/off.args b/compiler/testData/cli/jvm/inline/off.args index 51777fa3cd4..e903efa52a7 100644 --- a/compiler/testData/cli/jvm/inline/off.args +++ b/compiler/testData/cli/jvm/inline/off.args @@ -1,3 +1,3 @@ -inline off --help \ No newline at end of file +-help diff --git a/compiler/testData/cli/jvm/inline/off.out b/compiler/testData/cli/jvm/inline/off.out index 07b188b8a5e..b9015b7214c 100644 --- a/compiler/testData/cli/jvm/inline/off.out +++ b/compiler/testData/cli/jvm/inline/off.out @@ -1,5 +1,6 @@ Usage: kotlinc-jvm where possible options include: + -d Destination for generated class files -jar Resulting .jar file path -output Output directory path for .class files -classpath Paths where to find user class files diff --git a/compiler/testData/cli/jvm/inline/on.args b/compiler/testData/cli/jvm/inline/on.args index e08990757fc..e9f8ee4a108 100644 --- a/compiler/testData/cli/jvm/inline/on.args +++ b/compiler/testData/cli/jvm/inline/on.args @@ -1,3 +1,3 @@ -inline on --help \ No newline at end of file +-help diff --git a/compiler/testData/cli/jvm/inline/on.out b/compiler/testData/cli/jvm/inline/on.out index 07b188b8a5e..b9015b7214c 100644 --- a/compiler/testData/cli/jvm/inline/on.out +++ b/compiler/testData/cli/jvm/inline/on.out @@ -1,5 +1,6 @@ Usage: kotlinc-jvm where possible options include: + -d Destination for generated class files -jar Resulting .jar file path -output Output directory path for .class files -classpath Paths where to find user class files diff --git a/compiler/testData/cli/jvm/inline/wrong.args b/compiler/testData/cli/jvm/inline/wrong.args index 58a06826806..5b16e6872f1 100644 --- a/compiler/testData/cli/jvm/inline/wrong.args +++ b/compiler/testData/cli/jvm/inline/wrong.args @@ -1,2 +1,2 @@ -inline -wrong \ No newline at end of file +wrong diff --git a/compiler/testData/cli/jvm/inline/wrong.out b/compiler/testData/cli/jvm/inline/wrong.out index 86951a49e25..cd0cad5b6c1 100644 --- a/compiler/testData/cli/jvm/inline/wrong.out +++ b/compiler/testData/cli/jvm/inline/wrong.out @@ -1,6 +1,7 @@ Wrong value for inline option: 'wrong'. Should be 'on'/'off' or 'true'/'false' Usage: kotlinc-jvm where possible options include: + -d Destination for generated class files -jar Resulting .jar file path -output Output directory path for .class files -classpath Paths where to find user class files diff --git a/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.args b/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.args index 0e82a6f807c..55378d30b86 100644 --- a/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.args +++ b/compiler/testData/cli/jvm/multipleTextRangesInDiagnosticsOrder.args @@ -1,3 +1,3 @@ $TESTDATA_DIR$/multipleTextRangesInDiagnosticsOrder.kt --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/nonExistingClassPathAndAnnotationsPath.args b/compiler/testData/cli/jvm/nonExistingClassPathAndAnnotationsPath.args index 327c77342f4..a9acdc9d834 100644 --- a/compiler/testData/cli/jvm/nonExistingClassPathAndAnnotationsPath.args +++ b/compiler/testData/cli/jvm/nonExistingClassPathAndAnnotationsPath.args @@ -3,5 +3,5 @@ $TESTDATA_DIR$/simple.kt not/existing/path -annotations yet/another/not/existing/path --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/nonExistingSourcePath.args b/compiler/testData/cli/jvm/nonExistingSourcePath.args index 22686fad711..6508f5f88cd 100644 --- a/compiler/testData/cli/jvm/nonExistingSourcePath.args +++ b/compiler/testData/cli/jvm/nonExistingSourcePath.args @@ -1,3 +1,3 @@ not/existing/path --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/signatureClash.args b/compiler/testData/cli/jvm/signatureClash.args index aff3e8edf91..209627d7b7b 100644 --- a/compiler/testData/cli/jvm/signatureClash.args +++ b/compiler/testData/cli/jvm/signatureClash.args @@ -1,3 +1,3 @@ $TESTDATA_DIR$/signatureClash.kt --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/simple.args b/compiler/testData/cli/jvm/simple.args index dcd428eee26..8b185ce8136 100644 --- a/compiler/testData/cli/jvm/simple.args +++ b/compiler/testData/cli/jvm/simple.args @@ -1,3 +1,3 @@ $TESTDATA_DIR$/simple.kt --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/suppressAllWarningsLowercase.args b/compiler/testData/cli/jvm/suppressAllWarningsLowercase.args index 4939309f3d7..ce6db8c95ce 100644 --- a/compiler/testData/cli/jvm/suppressAllWarningsLowercase.args +++ b/compiler/testData/cli/jvm/suppressAllWarningsLowercase.args @@ -1,5 +1,5 @@ $TESTDATA_DIR$/../warnings.kt -suppress warnings --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/suppressAllWarningsMixedCase.args b/compiler/testData/cli/jvm/suppressAllWarningsMixedCase.args index da78a29e104..d10a31176c5 100644 --- a/compiler/testData/cli/jvm/suppressAllWarningsMixedCase.args +++ b/compiler/testData/cli/jvm/suppressAllWarningsMixedCase.args @@ -1,5 +1,5 @@ $TESTDATA_DIR$/../warnings.kt -suppress WaRnInGs --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/wrongAbiVersion.args b/compiler/testData/cli/jvm/wrongAbiVersion.args index c6220651a44..0cc655dfe8c 100644 --- a/compiler/testData/cli/jvm/wrongAbiVersion.args +++ b/compiler/testData/cli/jvm/wrongAbiVersion.args @@ -1,5 +1,5 @@ $TESTDATA_DIR$/wrongAbiVersion.kt -classpath $TESTDATA_DIR$/wrongAbiVersionLib --output +-d $TEMP_DIR$ diff --git a/compiler/testData/cli/jvm/wrongArgument.args b/compiler/testData/cli/jvm/wrongArgument.args index 432b203f156..e327439d84d 100644 --- a/compiler/testData/cli/jvm/wrongArgument.args +++ b/compiler/testData/cli/jvm/wrongArgument.args @@ -1 +1 @@ --wrongArgument \ No newline at end of file +-wrongArgument diff --git a/compiler/testData/cli/jvm/wrongArgument.out b/compiler/testData/cli/jvm/wrongArgument.out index abd6e5c9793..dd11745c274 100644 --- a/compiler/testData/cli/jvm/wrongArgument.out +++ b/compiler/testData/cli/jvm/wrongArgument.out @@ -1,6 +1,7 @@ Invalid argument: -wrongArgument Usage: kotlinc-jvm where possible options include: + -d Destination for generated class files -jar Resulting .jar file path -output Output directory path for .class files -classpath Paths where to find user class files diff --git a/compiler/testData/cli/jvm/wrongKotlinSignature.args b/compiler/testData/cli/jvm/wrongKotlinSignature.args index e9d7639ff43..05eebd95c7b 100644 --- a/compiler/testData/cli/jvm/wrongKotlinSignature.args +++ b/compiler/testData/cli/jvm/wrongKotlinSignature.args @@ -1,5 +1,5 @@ $TESTDATA_DIR$/wrongKotlinSignature.kt -classpath $TESTDATA_DIR$/wrongKotlinSignatureLib --output +-d $TEMP_DIR$ diff --git a/compiler/tests/org/jetbrains/jet/MockLibraryUtil.java b/compiler/tests/org/jetbrains/jet/MockLibraryUtil.java index 1df01ad5bea..c24d2c435af 100644 --- a/compiler/tests/org/jetbrains/jet/MockLibraryUtil.java +++ b/compiler/tests/org/jetbrains/jet/MockLibraryUtil.java @@ -37,7 +37,7 @@ import java.util.List; import java.util.regex.Pattern; import java.util.zip.ZipOutputStream; -import static junit.framework.Assert.assertEquals; +import static org.junit.Assert.assertEquals; public class MockLibraryUtil { @@ -98,7 +98,7 @@ public class MockLibraryUtil { //noinspection IOResourceOpenedButNotSafelyClosed Enum invocationResult = (Enum) execMethod.invoke( compilerObject, new PrintStream(outStream), - new String[] {sourcesPath, "-output", outDir.getAbsolutePath(), "-classpath", sourcesPath} + new String[] {sourcesPath, "-d", outDir.getAbsolutePath(), "-classpath", sourcesPath} ); assertEquals(new String(outStream.toByteArray()), ExitCode.OK.name(), invocationResult.name()); diff --git a/compiler/tests/org/jetbrains/jet/codegen/forTestCompile/ForTestCompileRuntime.java b/compiler/tests/org/jetbrains/jet/codegen/forTestCompile/ForTestCompileRuntime.java index 84a44315ffc..9cf40b5a16d 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/forTestCompile/ForTestCompileRuntime.java +++ b/compiler/tests/org/jetbrains/jet/codegen/forTestCompile/ForTestCompileRuntime.java @@ -88,7 +88,7 @@ public class ForTestCompileRuntime { @NotNull String... src ) { List args = KotlinPackage.arrayListOf( - "-output", destDir.getPath(), + "-d", destDir.getPath(), "-noStdlib", "-noJdkAnnotations", "-suppress", "warnings", diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileEnvironmentTest.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileEnvironmentTest.java index 37614329756..ee2e3171c11 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileEnvironmentTest.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/CompileEnvironmentTest.java @@ -44,13 +44,15 @@ public class CompileEnvironmentTest extends TestCase { File stdlib = ForTestCompileRuntime.runtimeJarForTests(); File jdkAnnotations = JetTestUtils.getJdkAnnotationsJar(); File resultJar = new File(tempDir, "result.jar"); - ExitCode rv = new K2JVMCompiler().exec(System.out, - "-module", JetTestCaseBuilder.getTestDataPathBase() + "/compiler/smoke/Smoke.ktm", - "-jar", resultJar.getAbsolutePath(), - "-noStdlib", - "-classpath", stdlib.getAbsolutePath(), - "-noJdkAnnotations", - "-annotations", jdkAnnotations.getAbsolutePath()); + ExitCode rv = new K2JVMCompiler().exec( + System.out, + "-module", JetTestCaseBuilder.getTestDataPathBase() + "/compiler/smoke/Smoke.ktm", + "-d", resultJar.getAbsolutePath(), + "-noStdlib", + "-classpath", stdlib.getAbsolutePath(), + "-noJdkAnnotations", + "-annotations", jdkAnnotations.getAbsolutePath() + ); Assert.assertEquals("compilation completed with non-zero code", ExitCode.OK, rv); FileInputStream fileInputStream = new FileInputStream(resultJar); try { @@ -81,9 +83,8 @@ public class CompileEnvironmentTest extends TestCase { File jdkAnnotations = JetTestUtils.getJdkAnnotationsJar(); ExitCode exitCode = new K2JVMCompiler().exec( System.out, - JetTestCaseBuilder.getTestDataPathBase() + - "/compiler/smoke/Smoke.kt", - "-output", out.getAbsolutePath(), + JetTestCaseBuilder.getTestDataPathBase() + "/compiler/smoke/Smoke.kt", + "-d", out.getAbsolutePath(), "-noStdlib", "-classpath", stdlib.getAbsolutePath(), "-noJdkAnnotations", diff --git a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt index ec4148c4472..a29b8d52893 100644 --- a/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt +++ b/libraries/tools/kdoc/src/main/kotlin/org/jetbrains/kotlin/doc/KDocCompiler.kt @@ -34,7 +34,7 @@ class KDocCompiler() : K2JVMCompiler() { } protected override fun usage(target : PrintStream) { - target.println("Usage: KDocCompiler -docOutput [-output |-jar ] [-stdlib ] [|-module ] [-includeRuntime]"); + target.println("Usage: KDocCompiler -docOutput -d [|] [-stdlib ] [|-module ] [-includeRuntime]"); } }