Do not fail on unknown -X flags

For better compatibility if we add experimental stuff in 1.0.X compilers
This commit is contained in:
Alexander Udalov
2016-04-11 14:21:41 +03:00
parent 37d612d346
commit a8629b3836
8 changed files with 61 additions and 16 deletions
@@ -74,6 +74,7 @@
<arg>-Xno-optimize</arg>
<arg>-Xno-call-assertions</arg>
<arg>-Xno-param-assertions</arg>
<arg>-Xunknown-extra-argument-abcdefghijklmnopqrstuvwxyz</arg>
</args>
</configuration>
</plugin>
@@ -16,8 +16,6 @@
package org.jetbrains.kotlin.maven;
import com.intellij.util.ArrayUtil;
import com.sampullara.cli.Args;
import kotlin.collections.CollectionsKt;
import kotlin.jvm.functions.Function1;
import org.apache.maven.artifact.Artifact;
@@ -100,13 +98,6 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
arguments.moduleName = moduleName;
getLog().info("Module name is " + moduleName);
try {
Args.parse(arguments, ArrayUtil.toStringArray(args));
}
catch (IllegalArgumentException e) {
throw new MojoExecutionException(e.getMessage());
}
if (arguments.noOptimize) {
getLog().info("Optimization is turned off");
}
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.maven;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.util.ArrayUtil;
import com.intellij.util.Processor;
import com.sampullara.cli.Args;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
@@ -115,9 +114,9 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
}
A arguments = createCompilerArguments();
configureCompilerArguments(arguments);
CLICompiler<A> compiler = createCompiler();
configureCompilerArguments(arguments, compiler);
printCompilerArgumentsIfDebugEnabled(arguments, compiler);
MessageCollector messageCollector = new MessageCollector() {
@@ -224,7 +223,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
*/
protected abstract void configureSpecificCompilerArguments(@NotNull A arguments) throws MojoExecutionException;
private void configureCompilerArguments(@NotNull A arguments) throws MojoExecutionException {
private void configureCompilerArguments(@NotNull A arguments, @NotNull CLICompiler<A> compiler) throws MojoExecutionException {
if (getLog().isDebugEnabled()) {
arguments.verbose = true;
}
@@ -245,18 +244,19 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
arguments.suppressWarnings = nowarn;
arguments.freeArgs.addAll(sources);
getLog().info("Compiling Kotlin sources from " + sources);
configureSpecificCompilerArguments(arguments);
try {
Args.parse(arguments, ArrayUtil.toStringArray(args));
compiler.parseArguments(ArrayUtil.toStringArray(args), arguments);
}
catch (IllegalArgumentException e) {
throw new MojoExecutionException(e.getMessage());
}
arguments.freeArgs.addAll(sources);
if (arguments.noInline) {
getLog().info("Method inlining is turned off");
}