Change format of -X arguments to require value after '='
Report a warning when an argument is passed in the old form (with the whitespace) #KT-17264 Fixed
This commit is contained in:
+3
@@ -104,6 +104,9 @@ public abstract class CommonCompilerArguments implements Serializable {
|
|||||||
|
|
||||||
public List<String> unknownExtraFlags = new SmartList<>();
|
public List<String> unknownExtraFlags = new SmartList<>();
|
||||||
|
|
||||||
|
// Names of extra (-X...) arguments which have been passed in an obsolete form ("-Xaaa bbb", instead of "-Xaaa=bbb")
|
||||||
|
public List<String> extraArgumentsPassedInObsoleteForm = new SmartList<>();
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static CommonCompilerArguments createDefaultInstance() {
|
public static CommonCompilerArguments createDefaultInstance() {
|
||||||
DummyImpl arguments = new DummyImpl();
|
DummyImpl arguments = new DummyImpl();
|
||||||
|
|||||||
+8
-9
@@ -22,16 +22,15 @@ import java.util.*
|
|||||||
|
|
||||||
@JvmOverloads
|
@JvmOverloads
|
||||||
fun <A : CommonCompilerArguments> parseArguments(args: Array<String>, arguments: A, ignoreInvalidArguments: Boolean = false) {
|
fun <A : CommonCompilerArguments> parseArguments(args: Array<String>, arguments: A, ignoreInvalidArguments: Boolean = false) {
|
||||||
val unparsedArgs = parseCommandLineArguments(args, arguments)
|
parseCommandLineArguments(args, arguments)
|
||||||
val (unknownExtraArgs, unknownArgs) = unparsedArgs.partition { it.startsWith("-X") }
|
|
||||||
arguments.unknownExtraFlags = unknownExtraArgs
|
|
||||||
arguments.freeArgs = if (ignoreInvalidArguments) unknownArgs.filterNot { it.startsWith("-") } else unknownArgs
|
|
||||||
|
|
||||||
if (!ignoreInvalidArguments) {
|
if (ignoreInvalidArguments) {
|
||||||
for (argument in unknownArgs) {
|
arguments.freeArgs.removeAll { it.startsWith("-") }
|
||||||
if (argument.startsWith("-")) {
|
}
|
||||||
throw IllegalArgumentException("Invalid argument: " + argument)
|
|
||||||
}
|
for (argument in arguments.freeArgs) {
|
||||||
|
if (argument.startsWith("-")) {
|
||||||
|
throw IllegalArgumentException("Invalid argument: " + argument)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-19
@@ -26,41 +26,56 @@ annotation class Argument(
|
|||||||
)
|
)
|
||||||
|
|
||||||
val Argument.isAdvanced: Boolean
|
val Argument.isAdvanced: Boolean
|
||||||
get() = value.startsWith("-X") && value.length > 2
|
get() = value.startsWith(ADVANCED_ARGUMENT_PREFIX) && value.length > ADVANCED_ARGUMENT_PREFIX.length
|
||||||
|
|
||||||
fun <A : CommonCompilerArguments> parseCommandLineArguments(args: Array<String>, result: A): List<String> {
|
private val ADVANCED_ARGUMENT_PREFIX = "-X"
|
||||||
data class ArgumentField(val field: Field, val argumentNames: List<String>)
|
|
||||||
|
fun <A : CommonCompilerArguments> parseCommandLineArguments(args: Array<String>, result: A) {
|
||||||
|
data class ArgumentField(val field: Field, val argument: Argument)
|
||||||
|
|
||||||
val fields = result::class.java.fields.mapNotNull { field ->
|
val fields = result::class.java.fields.mapNotNull { field ->
|
||||||
val argument = field.getAnnotation(Argument::class.java)
|
val argument = field.getAnnotation(Argument::class.java)
|
||||||
if (argument != null)
|
if (argument != null) ArgumentField(field, argument) else null
|
||||||
ArgumentField(field, listOfNotNull(argument.value, argument.shortName.takeUnless(String::isEmpty)))
|
|
||||||
else null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val freeArgs = mutableListOf<String>()
|
|
||||||
var i = 0
|
var i = 0
|
||||||
while (i < args.size) {
|
while (i < args.size) {
|
||||||
val arg = args[i++]
|
val arg = args[i++]
|
||||||
val field = fields.firstOrNull { (_, names) -> arg in names }?.field
|
val argumentField = fields.firstOrNull { (_, argument) ->
|
||||||
if (field == null) {
|
argument.value == arg ||
|
||||||
freeArgs.add(arg)
|
argument.shortName.takeUnless(String::isEmpty) == arg ||
|
||||||
|
(argument.isAdvanced && arg.startsWith(argument.value + "="))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argumentField == null) {
|
||||||
|
if (arg.startsWith(ADVANCED_ARGUMENT_PREFIX)) {
|
||||||
|
result.unknownExtraFlags.add(arg)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result.freeArgs.add(arg)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
val value: Any =
|
val (field, argument) = argumentField
|
||||||
if (field.type == Boolean::class.java) true
|
val value: Any = when {
|
||||||
else {
|
field.type == Boolean::class.java -> true
|
||||||
if (i == args.size) {
|
argument.isAdvanced && arg.startsWith(argument.value + "=") -> {
|
||||||
throw IllegalArgumentException("No value passed for argument $arg")
|
arg.substring(argument.value.length + 1)
|
||||||
}
|
}
|
||||||
args[i++]
|
else -> {
|
||||||
|
if (i == args.size) {
|
||||||
|
throw IllegalArgumentException("No value passed for argument $arg")
|
||||||
}
|
}
|
||||||
|
if (argument.isAdvanced) {
|
||||||
|
result.extraArgumentsPassedInObsoleteForm.add(arg)
|
||||||
|
}
|
||||||
|
args[i++]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
updateField(field, result, value)
|
updateField(field, result, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
return freeArgs
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <A : CommonCompilerArguments> updateField(field: Field, result: A, value: Any) {
|
private fun <A : CommonCompilerArguments> updateField(field: Field, result: A, value: Any) {
|
||||||
|
|||||||
@@ -51,8 +51,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
return exec(errStream, Services.EMPTY, MessageRenderer.PLAIN_RELATIVE_PATHS, args);
|
return exec(errStream, Services.EMPTY, MessageRenderer.PLAIN_RELATIVE_PATHS, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used via reflection in CompilerRunnerUtil#invokeExecMethod and in Eclipse plugin (see KotlinCLICompiler)
|
// Used in CompilerRunnerUtil#invokeExecMethod, in Eclipse plugin (KotlinCLICompiler) and in kotlin-gradle-plugin (GradleCompilerRunner)
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public ExitCode execAndOutputXml(@NotNull PrintStream errStream, @NotNull Services services, @NotNull String... args) {
|
public ExitCode execAndOutputXml(@NotNull PrintStream errStream, @NotNull Services services, @NotNull String... args) {
|
||||||
return exec(errStream, services, MessageRenderer.XML, args);
|
return exec(errStream, services, MessageRenderer.XML, args);
|
||||||
@@ -82,7 +81,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess") // Used in maven (see KotlinCompileMojoBase.java)
|
// Used in kotlin-maven-plugin (KotlinCompileMojoBase) and in kotlin-gradle-plugin (KotlinJvmOptionsImpl, KotlinJsOptionsImpl)
|
||||||
public void parseArguments(@NotNull String[] args, @NotNull A arguments) {
|
public void parseArguments(@NotNull String[] args, @NotNull A arguments) {
|
||||||
ArgumentUtilsKt.parseArguments(args, arguments);
|
ArgumentUtilsKt.parseArguments(args, arguments);
|
||||||
}
|
}
|
||||||
@@ -128,7 +127,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess") // Used in maven (see KotlinCompileMojoBase.java)
|
// Used in kotlin-maven-plugin (KotlinCompileMojoBase)
|
||||||
@NotNull
|
@NotNull
|
||||||
public ExitCode exec(@NotNull MessageCollector messageCollector, @NotNull Services services, @NotNull A arguments) {
|
public ExitCode exec(@NotNull MessageCollector messageCollector, @NotNull Services services, @NotNull A arguments) {
|
||||||
printVersionIfNeeded(messageCollector, arguments);
|
printVersionIfNeeded(messageCollector, arguments);
|
||||||
@@ -137,7 +136,7 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
messageCollector = new FilteringMessageCollector(messageCollector, Predicate.isEqual(WARNING));
|
messageCollector = new FilteringMessageCollector(messageCollector, Predicate.isEqual(WARNING));
|
||||||
}
|
}
|
||||||
|
|
||||||
reportUnknownExtraFlags(messageCollector, arguments);
|
reportUnknownAndObsoleteExtraFlags(messageCollector, arguments);
|
||||||
|
|
||||||
GroupingMessageCollector groupingCollector = new GroupingMessageCollector(messageCollector);
|
GroupingMessageCollector groupingCollector = new GroupingMessageCollector(messageCollector);
|
||||||
|
|
||||||
@@ -314,10 +313,14 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> {
|
|||||||
@NotNull CompilerConfiguration configuration, @NotNull A arguments, @NotNull Services services
|
@NotNull CompilerConfiguration configuration, @NotNull A arguments, @NotNull Services services
|
||||||
);
|
);
|
||||||
|
|
||||||
private void reportUnknownExtraFlags(@NotNull MessageCollector collector, @NotNull A arguments) {
|
private void reportUnknownAndObsoleteExtraFlags(@NotNull MessageCollector collector, @NotNull A arguments) {
|
||||||
for (String flag : arguments.unknownExtraFlags) {
|
for (String flag : arguments.unknownExtraFlags) {
|
||||||
collector.report(STRONG_WARNING, "Flag is not supported by this version of the compiler: " + flag, null);
|
collector.report(STRONG_WARNING, "Flag is not supported by this version of the compiler: " + flag, null);
|
||||||
}
|
}
|
||||||
|
for (String argument : arguments.extraArgumentsPassedInObsoleteForm) {
|
||||||
|
collector.report(STRONG_WARNING, "Advanced option value is passed in an obsolete form. Please use the '=' character " +
|
||||||
|
"to specify the value: " + argument + "=...", null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ class Usage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!argument.valueDescription().isEmpty()) {
|
if (!argument.valueDescription().isEmpty()) {
|
||||||
sb.append(" ");
|
sb.append(ParseCommandLineArgumentsKt.isAdvanced(argument) ? "=" : " ");
|
||||||
sb.append(argument.valueDescription());
|
sb.append(argument.valueDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -2,10 +2,10 @@ Usage: kotlinc-js <options> <source files>
|
|||||||
where advanced options include:
|
where advanced options include:
|
||||||
-Xtypedarrays Translate primitive arrays to JS typed arrays
|
-Xtypedarrays Translate primitive arrays to JS typed arrays
|
||||||
-Xno-inline Disable method inlining
|
-Xno-inline Disable method inlining
|
||||||
-Xrepeat <count> Repeat compilation (for performance analysis)
|
-Xrepeat=<count> Repeat compilation (for performance analysis)
|
||||||
-Xskip-metadata-version-check Load classes with bad metadata version anyway (incl. pre-release classes)
|
-Xskip-metadata-version-check Load classes with bad metadata version anyway (incl. pre-release classes)
|
||||||
-Xallow-kotlin-package Allow compiling code in package 'kotlin'
|
-Xallow-kotlin-package Allow compiling code in package 'kotlin'
|
||||||
-Xplugin <path> Load plugins from the given classpath
|
-Xplugin=<path> Load plugins from the given classpath
|
||||||
-Xmulti-platform Enable experimental language support for multi-platform projects
|
-Xmulti-platform Enable experimental language support for multi-platform projects
|
||||||
-Xno-check-impl Do not check presence of 'impl' modifier in multi-platform projects
|
-Xno-check-impl Do not check presence of 'impl' modifier in multi-platform projects
|
||||||
-Xcoroutines={enable|warn|error} Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
-Xcoroutines={enable|warn|error} Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
-Xplugin
|
||||||
|
non-existing-file.jar
|
||||||
|
$TESTDATA_DIR$/simple.kt
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
warning: advanced option value is passed in an obsolete form. Please use the '=' character to specify the value: -Xplugin=...
|
||||||
|
OK
|
||||||
+4
-4
@@ -6,18 +6,18 @@ where advanced options include:
|
|||||||
-Xreport-perf Report detailed performance statistics
|
-Xreport-perf Report detailed performance statistics
|
||||||
-Xmultifile-parts-inherit Compile multifile classes as a hierarchy of parts and facade
|
-Xmultifile-parts-inherit Compile multifile classes as a hierarchy of parts and facade
|
||||||
-Xskip-runtime-version-check Allow Kotlin runtime libraries of incompatible versions in the classpath
|
-Xskip-runtime-version-check Allow Kotlin runtime libraries of incompatible versions in the classpath
|
||||||
-Xdump-declarations-to <path> Path to JSON file to dump Java to Kotlin declaration mappings
|
-Xdump-declarations-to=<path> Path to JSON file to dump Java to Kotlin declaration mappings
|
||||||
-Xsingle-module Combine modules for source files and binary dependencies into a single module
|
-Xsingle-module Combine modules for source files and binary dependencies into a single module
|
||||||
-Xadd-compiler-builtins Add definitions of built-in declarations to the compilation classpath (useful with -no-stdlib)
|
-Xadd-compiler-builtins Add definitions of built-in declarations to the compilation classpath (useful with -no-stdlib)
|
||||||
-Xload-builtins-from-dependencies
|
-Xload-builtins-from-dependencies
|
||||||
Load definitions of built-in declarations from module dependencies, instead of from the compiler
|
Load definitions of built-in declarations from module dependencies, instead of from the compiler
|
||||||
-Xscript-resolver-environment <key=value[,]>
|
-Xscript-resolver-environment=<key=value[,]>
|
||||||
Script resolver environment in key-value pairs (the value could be quoted and escaped)
|
Script resolver environment in key-value pairs (the value could be quoted and escaped)
|
||||||
-Xno-inline Disable method inlining
|
-Xno-inline Disable method inlining
|
||||||
-Xrepeat <count> Repeat compilation (for performance analysis)
|
-Xrepeat=<count> Repeat compilation (for performance analysis)
|
||||||
-Xskip-metadata-version-check Load classes with bad metadata version anyway (incl. pre-release classes)
|
-Xskip-metadata-version-check Load classes with bad metadata version anyway (incl. pre-release classes)
|
||||||
-Xallow-kotlin-package Allow compiling code in package 'kotlin'
|
-Xallow-kotlin-package Allow compiling code in package 'kotlin'
|
||||||
-Xplugin <path> Load plugins from the given classpath
|
-Xplugin=<path> Load plugins from the given classpath
|
||||||
-Xmulti-platform Enable experimental language support for multi-platform projects
|
-Xmulti-platform Enable experimental language support for multi-platform projects
|
||||||
-Xno-check-impl Do not check presence of 'impl' modifier in multi-platform projects
|
-Xno-check-impl Do not check presence of 'impl' modifier in multi-platform projects
|
||||||
-Xcoroutines={enable|warn|error} Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
-Xcoroutines={enable|warn|error} Enable coroutines or report warnings or errors on declarations and use sites of 'suspend' modifier
|
||||||
|
|||||||
+2
-3
@@ -1,10 +1,9 @@
|
|||||||
-d
|
-d
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
-Xplugin
|
-Xplugin=dist/kotlinc/lib/android-extensions-compiler.jar
|
||||||
dist/kotlinc/lib/android-extensions-compiler.jar
|
|
||||||
-P
|
-P
|
||||||
plugin\:org.jetbrains.kotlin.android\:package=com.myapp
|
plugin\:org.jetbrains.kotlin.android\:package=com.myapp
|
||||||
-P
|
-P
|
||||||
plugin\:org.jetbrains.kotlin.android\:variant=main;$TESTDATA_DIR$/androidPlugin/res
|
plugin\:org.jetbrains.kotlin.android\:variant=main;$TESTDATA_DIR$/androidPlugin/res
|
||||||
$TESTDATA_DIR$/pluginSimple.kt
|
$TESTDATA_DIR$/pluginSimple.kt
|
||||||
$TESTDATA_DIR$/androidPlugin
|
$TESTDATA_DIR$/androidPlugin
|
||||||
|
|||||||
+2
-3
@@ -1,7 +1,6 @@
|
|||||||
-d
|
-d
|
||||||
$TEMP_DIR$
|
$TEMP_DIR$
|
||||||
-Xplugin
|
-Xplugin=dist/kotlinc/lib/android-extensions-compiler.jar
|
||||||
dist/kotlinc/lib/android-extensions-compiler.jar
|
|
||||||
-P
|
-P
|
||||||
plugin\:org.jetbrains.kotlin.android\:package=com.myapp
|
plugin\:org.jetbrains.kotlin.android\:package=com.myapp
|
||||||
$TESTDATA_DIR$/pluginSimple.kt
|
$TESTDATA_DIR$/pluginSimple.kt
|
||||||
@@ -11,4 +10,4 @@ $TESTDATA_DIR$/androidPlugin/androidWidget.kt
|
|||||||
$TESTDATA_DIR$/androidPlugin/fakeAppwidgetPackage.kt
|
$TESTDATA_DIR$/androidPlugin/fakeAppwidgetPackage.kt
|
||||||
$TESTDATA_DIR$/androidPlugin/fakeInputMethodServicePackage.kt
|
$TESTDATA_DIR$/androidPlugin/fakeInputMethodServicePackage.kt
|
||||||
$TESTDATA_DIR$/androidPlugin/fakeOpenglPackage.kt
|
$TESTDATA_DIR$/androidPlugin/fakeOpenglPackage.kt
|
||||||
$TESTDATA_DIR$/androidPlugin/fakeWebkitPackage.kt
|
$TESTDATA_DIR$/androidPlugin/fakeWebkitPackage.kt
|
||||||
|
|||||||
@@ -188,6 +188,12 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
doJvmTest(fileName);
|
doJvmTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("extraArgumentPassedInObsoleteForm.args")
|
||||||
|
public void testExtraArgumentPassedInObsoleteForm() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/extraArgumentPassedInObsoleteForm.args");
|
||||||
|
doJvmTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("extraHelp.args")
|
@TestMetadata("extraHelp.args")
|
||||||
public void testExtraHelp() throws Exception {
|
public void testExtraHelp() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/extraHelp.args");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/cli/jvm/extraHelp.args");
|
||||||
|
|||||||
@@ -1395,8 +1395,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
|||||||
<apiVersion>1.0</apiVersion>
|
<apiVersion>1.0</apiVersion>
|
||||||
<args>
|
<args>
|
||||||
<arg>-java-parameters</arg>
|
<arg>-java-parameters</arg>
|
||||||
<arg>-Xdump-declarations-to</arg>
|
<arg>-Xdump-declarations-to=dumpDir</arg>
|
||||||
<arg>dumpDir</arg>
|
|
||||||
</args>
|
</args>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@@ -1447,8 +1446,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
|||||||
<configuration>
|
<configuration>
|
||||||
<jvmTarget>1.8</jvmTarget>
|
<jvmTarget>1.8</jvmTarget>
|
||||||
<args>
|
<args>
|
||||||
<arg>-Xdump-declarations-to</arg>
|
<arg>-Xdump-declarations-to=dumpDir2</arg>
|
||||||
<arg>dumpDir2</arg>
|
|
||||||
</args>
|
</args>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
@@ -1574,7 +1572,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
|||||||
Assert.assertEquals("1.0", apiLevel!!.description)
|
Assert.assertEquals("1.0", apiLevel!!.description)
|
||||||
Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
listOf("-jdk-home", "temp", "-Xdump-declarations-to", "dumpDir2"),
|
listOf("-jdk-home", "temp", "-Xdump-declarations-to=dumpDir2"),
|
||||||
compilerSettings!!.additionalArgumentsAsList
|
compilerSettings!!.additionalArgumentsAsList
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1585,7 +1583,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
|||||||
Assert.assertEquals("1.0", apiLevel!!.description)
|
Assert.assertEquals("1.0", apiLevel!!.description)
|
||||||
Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
Assert.assertEquals("1.8", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
listOf("-jdk-home", "temp2", "-java-parameters", "-Xdump-declarations-to", "dumpDir"),
|
listOf("-jdk-home", "temp2", "-java-parameters", "-Xdump-declarations-to=dumpDir"),
|
||||||
compilerSettings!!.additionalArgumentsAsList
|
compilerSettings!!.additionalArgumentsAsList
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ class GradleFacetImportTest : GradleImportingTestCase() {
|
|||||||
|
|
||||||
compileKotlin {
|
compileKotlin {
|
||||||
kotlinOptions.jvmTarget = "1.7"
|
kotlinOptions.jvmTarget = "1.7"
|
||||||
kotlinOptions.freeCompilerArgs = ["-Xsingle-module", "-Xdump-declarations-to", "tmp"]
|
kotlinOptions.freeCompilerArgs = ["-Xsingle-module", "-Xdump-declarations-to=tmp"]
|
||||||
}
|
}
|
||||||
|
|
||||||
compileTestKotlin {
|
compileTestKotlin {
|
||||||
kotlinOptions.jvmTarget = "1.6"
|
kotlinOptions.jvmTarget = "1.6"
|
||||||
kotlinOptions.apiVersion = "1.0"
|
kotlinOptions.apiVersion = "1.0"
|
||||||
kotlinOptions.freeCompilerArgs = ["-Xdump-declarations-to", "tmpTest"]
|
kotlinOptions.freeCompilerArgs = ["-Xdump-declarations-to=tmpTest"]
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
importProject()
|
importProject()
|
||||||
@@ -77,7 +77,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
|
|||||||
Assert.assertEquals("1.1", apiLevel!!.versionString)
|
Assert.assertEquals("1.1", apiLevel!!.versionString)
|
||||||
Assert.assertEquals(TargetPlatformKind.Jvm[JvmTarget.JVM_1_8], targetPlatformKind)
|
Assert.assertEquals(TargetPlatformKind.Jvm[JvmTarget.JVM_1_8], targetPlatformKind)
|
||||||
Assert.assertEquals("1.7", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
Assert.assertEquals("1.7", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||||
Assert.assertEquals("-Xdump-declarations-to tmp -Xsingle-module",
|
Assert.assertEquals("-Xdump-declarations-to=tmp -Xsingle-module",
|
||||||
compilerSettings!!.additionalArguments)
|
compilerSettings!!.additionalArguments)
|
||||||
}
|
}
|
||||||
with (testFacetSettings) {
|
with (testFacetSettings) {
|
||||||
@@ -85,7 +85,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
|
|||||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||||
Assert.assertEquals(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], targetPlatformKind)
|
Assert.assertEquals(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], targetPlatformKind)
|
||||||
Assert.assertEquals("1.6", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
Assert.assertEquals("1.6", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||||
Assert.assertEquals("-Xdump-declarations-to tmpTest",
|
Assert.assertEquals("-Xdump-declarations-to=tmpTest",
|
||||||
compilerSettings!!.additionalArguments)
|
compilerSettings!!.additionalArguments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,13 +130,13 @@ class GradleFacetImportTest : GradleImportingTestCase() {
|
|||||||
|
|
||||||
compileMyMainKotlin {
|
compileMyMainKotlin {
|
||||||
kotlinOptions.jvmTarget = "1.7"
|
kotlinOptions.jvmTarget = "1.7"
|
||||||
kotlinOptions.freeCompilerArgs = ["-Xsingle-module", "-Xdump-declarations-to", "tmp"]
|
kotlinOptions.freeCompilerArgs = ["-Xsingle-module", "-Xdump-declarations-to=tmp"]
|
||||||
}
|
}
|
||||||
|
|
||||||
compileMyTestKotlin {
|
compileMyTestKotlin {
|
||||||
kotlinOptions.jvmTarget = "1.6"
|
kotlinOptions.jvmTarget = "1.6"
|
||||||
kotlinOptions.apiVersion = "1.0"
|
kotlinOptions.apiVersion = "1.0"
|
||||||
kotlinOptions.freeCompilerArgs = ["-Xdump-declarations-to", "tmpTest"]
|
kotlinOptions.freeCompilerArgs = ["-Xdump-declarations-to=tmpTest"]
|
||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
importProject()
|
importProject()
|
||||||
@@ -146,7 +146,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
|
|||||||
Assert.assertEquals("1.1", apiLevel!!.versionString)
|
Assert.assertEquals("1.1", apiLevel!!.versionString)
|
||||||
Assert.assertEquals(TargetPlatformKind.Jvm[JvmTarget.JVM_1_8], targetPlatformKind)
|
Assert.assertEquals(TargetPlatformKind.Jvm[JvmTarget.JVM_1_8], targetPlatformKind)
|
||||||
Assert.assertEquals("1.7", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
Assert.assertEquals("1.7", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||||
Assert.assertEquals("-Xdump-declarations-to tmp -Xsingle-module",
|
Assert.assertEquals("-Xdump-declarations-to=tmp -Xsingle-module",
|
||||||
compilerSettings!!.additionalArguments)
|
compilerSettings!!.additionalArguments)
|
||||||
}
|
}
|
||||||
with (facetSettings("project_myTest")) {
|
with (facetSettings("project_myTest")) {
|
||||||
@@ -154,7 +154,7 @@ class GradleFacetImportTest : GradleImportingTestCase() {
|
|||||||
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
Assert.assertEquals("1.0", apiLevel!!.versionString)
|
||||||
Assert.assertEquals(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], targetPlatformKind)
|
Assert.assertEquals(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], targetPlatformKind)
|
||||||
Assert.assertEquals("1.6", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
Assert.assertEquals("1.6", (compilerArguments as K2JVMCompilerArguments).jvmTarget)
|
||||||
Assert.assertEquals("-Xdump-declarations-to tmpTest",
|
Assert.assertEquals("-Xdump-declarations-to=tmpTest",
|
||||||
compilerSettings!!.additionalArguments)
|
compilerSettings!!.additionalArguments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ compileBuiltinsKotlin {
|
|||||||
freeCompilerArgs = [
|
freeCompilerArgs = [
|
||||||
"-version",
|
"-version",
|
||||||
"-Xallow-kotlin-package",
|
"-Xallow-kotlin-package",
|
||||||
"-Xdump-declarations-to", "${buildDir}/runtime-declarations.json",
|
"-Xdump-declarations-to=${buildDir}/runtime-declarations.json",
|
||||||
"-cp", "${rootDir}/../dist/builtins",
|
"-cp", "${rootDir}/../dist/builtins",
|
||||||
"-module-name", "kotlin-runtime"
|
"-module-name", "kotlin-runtime"
|
||||||
]
|
]
|
||||||
@@ -113,7 +113,7 @@ compileKotlin {
|
|||||||
"-version",
|
"-version",
|
||||||
"-Xallow-kotlin-package",
|
"-Xallow-kotlin-package",
|
||||||
"-Xmultifile-parts-inherit",
|
"-Xmultifile-parts-inherit",
|
||||||
"-Xdump-declarations-to", "${buildDir}/stdlib-declarations.json",
|
"-Xdump-declarations-to=${buildDir}/stdlib-declarations.json",
|
||||||
"-module-name", project.name
|
"-module-name", project.name
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ compileKotlin {
|
|||||||
kotlinOptions.freeCompilerArgs = [
|
kotlinOptions.freeCompilerArgs = [
|
||||||
"-Xallow-kotlin-package",
|
"-Xallow-kotlin-package",
|
||||||
"-Xmultifile-parts-inherit",
|
"-Xmultifile-parts-inherit",
|
||||||
"-Xdump-declarations-to", "${buildDir}/stdlib-jre7-declarations.json",
|
"-Xdump-declarations-to=${buildDir}/stdlib-jre7-declarations.json",
|
||||||
"-module-name", project.name
|
"-module-name", project.name
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ compileKotlin {
|
|||||||
kotlinOptions.freeCompilerArgs = [
|
kotlinOptions.freeCompilerArgs = [
|
||||||
"-Xallow-kotlin-package",
|
"-Xallow-kotlin-package",
|
||||||
"-Xmultifile-parts-inherit",
|
"-Xmultifile-parts-inherit",
|
||||||
"-Xdump-declarations-to", "${buildDir}/stdlib-jre8-declarations.json",
|
"-Xdump-declarations-to=${buildDir}/stdlib-jre8-declarations.json",
|
||||||
"-module-name", project.name
|
"-module-name", project.name
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ sourceSets {
|
|||||||
|
|
||||||
compileTestKotlin {
|
compileTestKotlin {
|
||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
freeCompilerArgs = ['-Xdump-declarations-to', "${buildDir}/cases-declarations.json"]
|
freeCompilerArgs = ["-Xdump-declarations-to=${buildDir}/cases-declarations.json"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ class KotlinJvmOptionsTest {
|
|||||||
"-Xreport-perf",
|
"-Xreport-perf",
|
||||||
"-Xallow-kotlin-package",
|
"-Xallow-kotlin-package",
|
||||||
"-Xmultifile-parts-inherit",
|
"-Xmultifile-parts-inherit",
|
||||||
"-Xdump-declarations-to", "declarationsPath",
|
"-Xdump-declarations-to=declarationsPath",
|
||||||
"-script-templates", "a,b,c")
|
"-script-templates", "a,b,c")
|
||||||
|
|
||||||
val arguments = K2JVMCompilerArguments()
|
val arguments = K2JVMCompilerArguments()
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ compileKotlin {
|
|||||||
freeCompilerArgs = ["-version",
|
freeCompilerArgs = ["-version",
|
||||||
"-Xallow-kotlin-package",
|
"-Xallow-kotlin-package",
|
||||||
"-module-name", "kotlin-reflection",
|
"-module-name", "kotlin-reflection",
|
||||||
"-Xdump-declarations-to", "${buildDir}/reflect-declarations.json"]
|
"-Xdump-declarations-to=${buildDir}/reflect-declarations.json"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ compileKotlin {
|
|||||||
kotlinOptions {
|
kotlinOptions {
|
||||||
freeCompilerArgs = [
|
freeCompilerArgs = [
|
||||||
"-Xallow-kotlin-package",
|
"-Xallow-kotlin-package",
|
||||||
"-Xdump-declarations-to", "${buildDir}/runtime-declarations.json",
|
"-Xdump-declarations-to=${buildDir}/runtime-declarations.json",
|
||||||
"-cp", "${rootDir}/../dist/builtins",
|
"-cp", "${rootDir}/../dist/builtins",
|
||||||
"-module-name", project.name
|
"-module-name", project.name
|
||||||
]
|
]
|
||||||
|
|||||||
+2
-4
@@ -173,9 +173,8 @@ class SourceSectionsTest : TestCaseWithTmpdir() {
|
|||||||
val sourceToOutput = getTestFiles(".out")
|
val sourceToOutput = getTestFiles(".out")
|
||||||
|
|
||||||
sourceToOutput.forEach { (source, expectedOutput) ->
|
sourceToOutput.forEach { (source, expectedOutput) ->
|
||||||
|
|
||||||
val args = arrayOf(source.canonicalPath, "-d", tmpdir.canonicalPath,
|
val args = arrayOf(source.canonicalPath, "-d", tmpdir.canonicalPath,
|
||||||
"-Xplugin", sourceSectionsPluginJar.canonicalPath,
|
"-Xplugin=${sourceSectionsPluginJar.canonicalPath}",
|
||||||
"-P", TEST_ALLOWED_SECTIONS.joinToString(",") { "plugin:${SourceSectionsCommandLineProcessor.PLUGIN_ID}:${SourceSectionsCommandLineProcessor.SECTIONS_OPTION.name}=$it" })
|
"-P", TEST_ALLOWED_SECTIONS.joinToString(",") { "plugin:${SourceSectionsCommandLineProcessor.PLUGIN_ID}:${SourceSectionsCommandLineProcessor.SECTIONS_OPTION.name}=$it" })
|
||||||
val (output, code) = captureOut {
|
val (output, code) = captureOut {
|
||||||
CLICompiler.doMainNoExit(K2JVMCompiler(), args)
|
CLICompiler.doMainNoExit(K2JVMCompiler(), args)
|
||||||
@@ -205,9 +204,8 @@ class SourceSectionsTest : TestCaseWithTmpdir() {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
sourceToOutput.forEach { (source, expectedOutput) ->
|
sourceToOutput.forEach { (source, expectedOutput) ->
|
||||||
|
|
||||||
val args = arrayOf(source.canonicalPath, "-d", tmpdir.canonicalPath,
|
val args = arrayOf(source.canonicalPath, "-d", tmpdir.canonicalPath,
|
||||||
"-Xplugin", sourceSectionsPluginJar.canonicalPath,
|
"-Xplugin=${sourceSectionsPluginJar.canonicalPath}",
|
||||||
"-P", TEST_ALLOWED_SECTIONS.joinToString(",") { "plugin:${SourceSectionsCommandLineProcessor.PLUGIN_ID}:${SourceSectionsCommandLineProcessor.SECTIONS_OPTION.name}=$it" })
|
"-P", TEST_ALLOWED_SECTIONS.joinToString(",") { "plugin:${SourceSectionsCommandLineProcessor.PLUGIN_ID}:${SourceSectionsCommandLineProcessor.SECTIONS_OPTION.name}=$it" })
|
||||||
|
|
||||||
messageCollector.clear()
|
messageCollector.clear()
|
||||||
|
|||||||
Reference in New Issue
Block a user