CLI: change argument naming convention
As in all other Unix/POSIX tools and JVM language compilers, multiple words comprising the argument name should be lowercase, separated by dashes
This commit is contained in:
@@ -37,7 +37,7 @@ public class Kotlin2JsCompilerTask : Task() {
|
||||
public var library: Path? = null
|
||||
public var outputPrefix: File? = null
|
||||
public var outputPostfix: File? = null
|
||||
public var sourcemap: Boolean = false
|
||||
public var sourceMap: Boolean = false
|
||||
|
||||
/**
|
||||
* {@link K2JsArgumentConstants.CALL} (default) if need generate a main function call (main function will be auto detected)
|
||||
@@ -84,7 +84,7 @@ public class Kotlin2JsCompilerTask : Task() {
|
||||
arguments.outputPostfix = outputPostfix?.canonicalPath
|
||||
|
||||
arguments.main = main
|
||||
arguments.sourcemap = sourcemap
|
||||
arguments.sourceMap = sourceMap
|
||||
|
||||
log("Compiling ${arguments.freeArgs} => [${arguments.outputFile}]");
|
||||
|
||||
|
||||
@@ -579,7 +579,7 @@
|
||||
<arg line="@{src}"/>
|
||||
<arg value="-d"/>
|
||||
<arg value="@{output}"/>
|
||||
<arg value="-noStdlib"/>
|
||||
<arg value="-no-stdlib"/>
|
||||
<arg value="-classpath"/>
|
||||
<arg value="@{classpath}"/>
|
||||
</java>
|
||||
|
||||
+5
-8
@@ -23,20 +23,17 @@ import org.jetbrains.annotations.Nullable;
|
||||
import static org.jetbrains.jet.cli.common.arguments.K2JsArgumentConstants.CALL;
|
||||
import static org.jetbrains.jet.cli.common.arguments.K2JsArgumentConstants.NO_CALL;
|
||||
|
||||
/**
|
||||
* NOTE: for now K2JSCompiler supports only minimal amount of parameters required to launch it from the plugin.
|
||||
*/
|
||||
public class K2JSCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "output", description = "Output file path")
|
||||
@ValueDescription("<path>")
|
||||
public String outputFile;
|
||||
|
||||
@Argument(value = "libraryFiles", description = "Path to zipped library sources or kotlin files separated by commas")
|
||||
@Argument(value = "library-files", description = "Path to zipped library sources or kotlin files separated by commas")
|
||||
@ValueDescription("<path[,]>")
|
||||
public String[] libraryFiles;
|
||||
|
||||
@Argument(value = "sourcemap", description = "Generate SourceMap")
|
||||
public boolean sourcemap;
|
||||
@Argument(value = "source-map", description = "Generate source map")
|
||||
public boolean sourceMap;
|
||||
|
||||
@Argument(value = "target", description = "Generate JS files for specific ECMA version (only ECMA 5 is supported)")
|
||||
@ValueDescription("<version>")
|
||||
@@ -47,11 +44,11 @@ public class K2JSCompilerArguments extends CommonCompilerArguments {
|
||||
@ValueDescription("{" + CALL + "," + NO_CALL + "}")
|
||||
public String main;
|
||||
|
||||
@Argument(value = "outputPrefix", description = "Path to file which will be added to the beginning of output file")
|
||||
@Argument(value = "output-prefix", description = "Path to file which will be added to the beginning of output file")
|
||||
@ValueDescription("<path>")
|
||||
public String outputPrefix;
|
||||
|
||||
@Argument(value = "outputPostfix", description = "Path to file which will be added to the end of output file")
|
||||
@Argument(value = "output-postfix", description = "Path to file which will be added to the end of output file")
|
||||
@ValueDescription("<path>")
|
||||
public String outputPostfix;
|
||||
|
||||
|
||||
+5
-9
@@ -19,10 +19,6 @@ package org.jetbrains.jet.cli.common.arguments;
|
||||
import com.sampullara.cli.Argument;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* Command line arguments for K2JVMCompiler
|
||||
*/
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "d", description = "Destination for generated class files")
|
||||
@ValueDescription("<directory|jar>")
|
||||
@@ -36,16 +32,16 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
||||
@ValueDescription("<path>")
|
||||
public String annotations;
|
||||
|
||||
@Argument(value = "includeRuntime", description = "Include Kotlin runtime in to resulting .jar")
|
||||
@Argument(value = "include-runtime", description = "Include Kotlin runtime in to resulting .jar")
|
||||
public boolean includeRuntime;
|
||||
|
||||
@Argument(value = "noJdk", description = "Don't include Java runtime into classpath")
|
||||
@Argument(value = "no-jdk", description = "Don't include Java runtime into classpath")
|
||||
public boolean noJdk;
|
||||
|
||||
@Argument(value = "noStdlib", description = "Don't include Kotlin runtime into classpath")
|
||||
@Argument(value = "no-stdlib", description = "Don't include Kotlin runtime into classpath")
|
||||
public boolean noStdlib;
|
||||
|
||||
@Argument(value = "noJdkAnnotations", description = "Don't include JDK external annotations into classpath")
|
||||
@Argument(value = "no-jdk-annotations", description = "Don't include JDK external annotations into classpath")
|
||||
public boolean noJdkAnnotations;
|
||||
|
||||
@Argument(value = "module", description = "Path to the module file to compile")
|
||||
@@ -55,7 +51,7 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "script", description = "Evaluate the script file")
|
||||
public boolean script;
|
||||
|
||||
@Argument(value = "kotlinHome", description = "Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery")
|
||||
@Argument(value = "kotlin-home", description = "Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery")
|
||||
@ValueDescription("<path>")
|
||||
public String kotlinHome;
|
||||
|
||||
|
||||
@@ -191,11 +191,11 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
||||
EcmaVersion ecmaVersion = EcmaVersion.defaultVersion();
|
||||
String moduleId = FileUtil.getNameWithoutExtension(new File(arguments.outputFile));
|
||||
if (arguments.libraryFiles != null) {
|
||||
return new LibrarySourcesConfig(project, moduleId, Arrays.asList(arguments.libraryFiles), ecmaVersion, arguments.sourcemap);
|
||||
return new LibrarySourcesConfig(project, moduleId, Arrays.asList(arguments.libraryFiles), ecmaVersion, arguments.sourceMap);
|
||||
}
|
||||
else {
|
||||
// lets discover the JS library definitions on the classpath
|
||||
return new ClassPathLibraryDefintionsConfig(project, moduleId, ecmaVersion, arguments.sourcemap);
|
||||
return new ClassPathLibraryDefintionsConfig(project, moduleId, ecmaVersion, arguments.sourceMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
||||
public void helloApp() throws Exception {
|
||||
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
|
||||
|
||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar));
|
||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-include-runtime", "hello.kt", "-d", jar));
|
||||
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
||||
public void helloAppFQMain() throws Exception {
|
||||
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
|
||||
|
||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar));
|
||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-include-runtime", "hello.kt", "-d", jar));
|
||||
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class CompilerSmokeTest extends KotlinIntegrationTestBase {
|
||||
public void helloAppVarargMain() throws Exception {
|
||||
String jar = tmpdir.getTmpDir().getAbsolutePath() + File.separator + "hello.jar";
|
||||
|
||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-includeRuntime", "hello.kt", "-d", jar));
|
||||
assertEquals("compilation failed", 0, runCompiler("hello.compile", "-include-runtime", "hello.kt", "-d", jar));
|
||||
runJava("hello.run", "-cp", jar, "Hello.HelloPackage");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
Usage: kotlinc-js <options> <source files>
|
||||
where possible options include:
|
||||
-output <path> Output file path
|
||||
-libraryFiles <path[,]> Path to zipped library sources or kotlin files separated by commas
|
||||
-sourcemap Generate SourceMap
|
||||
-library-files <path[,]> Path to zipped library sources or kotlin files separated by commas
|
||||
-source-map Generate source map
|
||||
-target <version> Generate JS files for specific ECMA version (only ECMA 5 is supported)
|
||||
-main {call,noCall} Whether a main function should be called; default 'call' (main function will be auto detected)
|
||||
-outputPrefix <path> Path to file which will be added to the beginning of output file
|
||||
-outputPostfix <path> Path to file which will be added to the end of output file
|
||||
-output-prefix <path> Path to file which will be added to the beginning of output file
|
||||
-output-postfix <path> Path to file which will be added to the end of output file
|
||||
-tags Demarcate each compilation message (error, warning, etc) with an open and close tag
|
||||
-verbose Enable verbose logging output
|
||||
-version Display compiler version
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
$TESTDATA_DIR$/simple2js.kt
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
-outputPostfix
|
||||
-output-postfix
|
||||
not/existing/path
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
$TESTDATA_DIR$/simple2js.kt
|
||||
-output
|
||||
$TEMP_DIR$/out.js
|
||||
-outputPrefix
|
||||
-output-prefix
|
||||
not/existing/path
|
||||
|
||||
@@ -3,13 +3,13 @@ where possible options include:
|
||||
-d <directory|jar> Destination for generated class files
|
||||
-classpath <path> Paths where to find user class files
|
||||
-annotations <path> Paths to external annotations
|
||||
-includeRuntime Include Kotlin runtime in to resulting .jar
|
||||
-noJdk Don't include Java runtime into classpath
|
||||
-noStdlib Don't include Kotlin runtime into classpath
|
||||
-noJdkAnnotations Don't include JDK external annotations into classpath
|
||||
-include-runtime Include Kotlin runtime in to resulting .jar
|
||||
-no-jdk Don't include Java runtime into classpath
|
||||
-no-stdlib Don't include Kotlin runtime into classpath
|
||||
-no-jdk-annotations Don't include JDK external annotations into classpath
|
||||
-module <path> Path to the module file to compile
|
||||
-script Evaluate the script file
|
||||
-kotlinHome <path> Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
|
||||
-kotlin-home <path> Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
|
||||
-tags Demarcate each compilation message (error, warning, etc) with an open and close tag
|
||||
-verbose Enable verbose logging output
|
||||
-version Display compiler version
|
||||
|
||||
@@ -1 +1 @@
|
||||
-wrongArgument
|
||||
-wrong-argument
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
Invalid argument: -wrongArgument
|
||||
Invalid argument: -wrong-argument
|
||||
Usage: kotlinc-jvm <options> <source files>
|
||||
where possible options include:
|
||||
-d <directory|jar> Destination for generated class files
|
||||
-classpath <path> Paths where to find user class files
|
||||
-annotations <path> Paths to external annotations
|
||||
-includeRuntime Include Kotlin runtime in to resulting .jar
|
||||
-noJdk Don't include Java runtime into classpath
|
||||
-noStdlib Don't include Kotlin runtime into classpath
|
||||
-noJdkAnnotations Don't include JDK external annotations into classpath
|
||||
-include-runtime Include Kotlin runtime in to resulting .jar
|
||||
-no-jdk Don't include Java runtime into classpath
|
||||
-no-stdlib Don't include Kotlin runtime into classpath
|
||||
-no-jdk-annotations Don't include JDK external annotations into classpath
|
||||
-module <path> Path to the module file to compile
|
||||
-script Evaluate the script file
|
||||
-kotlinHome <path> Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
|
||||
-kotlin-home <path> Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
|
||||
-tags Demarcate each compilation message (error, warning, etc) with an open and close tag
|
||||
-verbose Enable verbose logging output
|
||||
-version Display compiler version
|
||||
|
||||
@@ -89,8 +89,8 @@ public class ForTestCompileRuntime {
|
||||
) {
|
||||
List<String> args = KotlinPackage.arrayListOf(
|
||||
"-d", destDir.getPath(),
|
||||
"-noStdlib",
|
||||
"-noJdkAnnotations",
|
||||
"-no-stdlib",
|
||||
"-no-jdk-annotations",
|
||||
"-suppress", "warnings",
|
||||
"-annotations", JetTestUtils.getJdkAnnotationsJar().getAbsolutePath(),
|
||||
"-classpath", classPath
|
||||
|
||||
@@ -36,7 +36,6 @@ import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarInputStream;
|
||||
|
||||
public class CompileEnvironmentTest extends TestCase {
|
||||
|
||||
public void testSmokeWithCompilerJar() throws IOException {
|
||||
File tempDir = FileUtil.createTempDirectory("compilerTest", "compilerTest");
|
||||
|
||||
@@ -48,9 +47,9 @@ public class CompileEnvironmentTest extends TestCase {
|
||||
System.out,
|
||||
"-module", JetTestCaseBuilder.getTestDataPathBase() + "/compiler/smoke/Smoke.ktm",
|
||||
"-d", resultJar.getAbsolutePath(),
|
||||
"-noStdlib",
|
||||
"-no-stdlib",
|
||||
"-classpath", stdlib.getAbsolutePath(),
|
||||
"-noJdkAnnotations",
|
||||
"-no-jdk-annotations",
|
||||
"-annotations", jdkAnnotations.getAbsolutePath()
|
||||
);
|
||||
Assert.assertEquals("compilation completed with non-zero code", ExitCode.OK, rv);
|
||||
@@ -85,15 +84,16 @@ public class CompileEnvironmentTest extends TestCase {
|
||||
System.out,
|
||||
JetTestCaseBuilder.getTestDataPathBase() + "/compiler/smoke/Smoke.kt",
|
||||
"-d", out.getAbsolutePath(),
|
||||
"-noStdlib",
|
||||
"-no-stdlib",
|
||||
"-classpath", stdlib.getAbsolutePath(),
|
||||
"-noJdkAnnotations",
|
||||
"-no-jdk-annotations",
|
||||
"-annotations", jdkAnnotations.getAbsolutePath()
|
||||
);
|
||||
Assert.assertEquals(ExitCode.OK, exitCode);
|
||||
assertEquals(1, out.listFiles().length);
|
||||
assertEquals(2, out.listFiles()[0].listFiles().length);
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
FileUtil.delete(tempDir);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class KotlinCompilerRunner {
|
||||
) {
|
||||
try {
|
||||
messageCollector.report(CompilerMessageSeverity.INFO,
|
||||
"Using kotlinHome=" + environment.getKotlinPaths().getHomePath(),
|
||||
"Using kotlin-home = " + environment.getKotlinPaths().getHomePath(),
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
|
||||
Object rc = CompilerRunnerUtil.invokeExecMethod(compilerClassName, arguments, environment,
|
||||
|
||||
+3
-3
@@ -90,7 +90,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
public boolean isModified() {
|
||||
return ComparingUtils.isModified(generateNoWarningsCheckBox, isGenerateNoWarnings()) ||
|
||||
ComparingUtils.isModified(additionalArgsOptionsField, compilerSettings.getAdditionalArguments()) ||
|
||||
ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.sourcemap) ||
|
||||
ComparingUtils.isModified(generateSourceMapsCheckBox, k2jsCompilerArguments.sourceMap) ||
|
||||
isModified(outputPrefixFile, k2jsCompilerArguments.outputPrefix) ||
|
||||
isModified(outputPostfixFile, k2jsCompilerArguments.outputPostfix);
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
public void apply() throws ConfigurationException {
|
||||
setGenerateNoWarnings(generateNoWarningsCheckBox.isSelected());
|
||||
compilerSettings.setAdditionalArguments(additionalArgsOptionsField.getText());
|
||||
k2jsCompilerArguments.sourcemap = generateSourceMapsCheckBox.isSelected();
|
||||
k2jsCompilerArguments.sourceMap = generateSourceMapsCheckBox.isSelected();
|
||||
k2jsCompilerArguments.outputPrefix = StringUtil.nullize(outputPrefixFile.getText(), true);
|
||||
k2jsCompilerArguments.outputPostfix = StringUtil.nullize(outputPostfixFile.getText(), true);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
public void reset() {
|
||||
generateNoWarningsCheckBox.setSelected(isGenerateNoWarnings());
|
||||
additionalArgsOptionsField.setText(compilerSettings.getAdditionalArguments());
|
||||
generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.sourcemap);
|
||||
generateSourceMapsCheckBox.setSelected(k2jsCompilerArguments.sourceMap);
|
||||
outputPrefixFile.setText(k2jsCompilerArguments.outputPrefix);
|
||||
outputPostfixFile.setText(k2jsCompilerArguments.outputPostfix);
|
||||
}
|
||||
|
||||
+3
-4
@@ -32,13 +32,12 @@ import static org.jetbrains.k2js.test.utils.TranslationUtils.createJetFileList;
|
||||
import static org.jetbrains.k2js.test.utils.TranslationUtils.getConfig;
|
||||
|
||||
@SuppressWarnings("JUnitTestCaseWithNoTests")
|
||||
public final class SourcemapTest extends SingleFileTranslationTest {
|
||||
|
||||
public final class SourceMapTest extends SingleFileTranslationTest {
|
||||
@NotNull
|
||||
private final String filename;
|
||||
|
||||
@SuppressWarnings("JUnitTestCaseWithNonTrivialConstructors")
|
||||
public SourcemapTest(@NotNull String filename) {
|
||||
public SourceMapTest(@NotNull String filename) {
|
||||
super("sourcemap/");
|
||||
this.filename = filename;
|
||||
}
|
||||
@@ -74,7 +73,7 @@ public final class SourcemapTest extends SingleFileTranslationTest {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String filename) {
|
||||
SourcemapTest examplesTest = new SourcemapTest(filename);
|
||||
SourceMapTest examplesTest = new SourceMapTest(filename);
|
||||
examplesTest.setName(filename);
|
||||
return examplesTest;
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class KDocCompiler() : K2JVMCompiler() {
|
||||
}
|
||||
|
||||
protected override fun usage(target: PrintStream, extraHelp: Boolean) {
|
||||
target.println("Usage: KDocCompiler -docOutput <docOutputDir> -d [<outputDir>|<jarFileName>] [-stdlib <path to runtime.jar>] [<filename or dirname>|-module <module file>] [-includeRuntime]");
|
||||
target.println("Usage: KDocCompiler -docOutput <docOutputDir> -d [<directory>|<jar>] [-stdlib <path to runtime.jar>] [<path>|-module <module file>] [-include-runtime]");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user