CLI: Support "-X" advanced options, simplify some boolean options
This commit is contained in:
@@ -33,7 +33,7 @@ class KDocCompiler() : K2JVMCompiler() {
|
||||
return KDocArguments()
|
||||
}
|
||||
|
||||
protected override fun usage(target : PrintStream) {
|
||||
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]");
|
||||
}
|
||||
}
|
||||
|
||||
+4
-11
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.doc.KDocConfig
|
||||
import java.util.concurrent.Callable
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil
|
||||
|
||||
public open class KotlinCompile(): AbstractCompile() {
|
||||
|
||||
@@ -116,16 +115,10 @@ public open class KotlinCompile(): AbstractCompile() {
|
||||
|
||||
args.noStdlib = true
|
||||
args.noJdkAnnotations = true
|
||||
args.inline = kotlinOptions.inline
|
||||
args.optimize = kotlinOptions.optimize
|
||||
|
||||
if (!CompilerArgumentsUtil.checkOption(args.inline)) {
|
||||
throw GradleException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("inline", args.inline))
|
||||
}
|
||||
|
||||
if (!CompilerArgumentsUtil.checkOption(args.optimize)) {
|
||||
throw GradleException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("optimize", args.optimize))
|
||||
}
|
||||
args.noInline = kotlinOptions.noInline
|
||||
args.noOptimize = kotlinOptions.noOptimize
|
||||
args.noCallAssertions = kotlinOptions.noCallAssertions
|
||||
args.noParamAssertions = kotlinOptions.noParamAssertions
|
||||
|
||||
val messageCollector = GradleMessageCollector(getLogger())
|
||||
getLogger().debug("Calling compiler")
|
||||
|
||||
+2
-18
@@ -1,16 +1,6 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import com.google.common.io.Files
|
||||
import com.intellij.openapi.util.SystemInfo
|
||||
import java.io.File
|
||||
import java.util.Arrays
|
||||
import java.util.Scanner
|
||||
import org.junit.Before
|
||||
import org.junit.After
|
||||
import org.junit.Test
|
||||
import kotlin.test.assertTrue
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.fail
|
||||
import org.junit.Ignore
|
||||
import org.jetbrains.kotlin.gradle.BaseGradleIT.Project
|
||||
|
||||
@@ -37,14 +27,8 @@ class BasicKotlinGradleIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
Test fun testInlineDisabled() {
|
||||
Project("inlineDisabled", "1.6").build("build", "-Pkotlin.gradle.plugin.version=0.1-SNAPSHOT") {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
Test fun testOptimizationDisabled() {
|
||||
Project("optimizationDisabled", "1.6").build("build", "-Pkotlin.gradle.plugin.version=0.1-SNAPSHOT") {
|
||||
Test fun testAdvancedOptions() {
|
||||
Project("advancedOptions", "1.6").build("build", "-Pkotlin.gradle.plugin.version=0.1-SNAPSHOT") {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
+4
-2
@@ -40,8 +40,10 @@ test {
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.annotations = "externalAnnotations"
|
||||
kotlinOptions.inline = false
|
||||
kotlinOptions.noInline = true
|
||||
kotlinOptions.noOptimize = true
|
||||
kotlinOptions.noCallAssertions = true
|
||||
kotlinOptions.noParamAssertions = true
|
||||
}
|
||||
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<root>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner on(java.lang.String)'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner.MapJoiner withKeyValueSeparator(java.lang.String)'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner skipNulls()'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
</root>
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url 'file://' + pathToKotlinPlugin
|
||||
}
|
||||
}
|
||||
dependencies {
|
||||
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin-core:0.1-SNAPSHOT'
|
||||
}
|
||||
}
|
||||
|
||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPlugin
|
||||
|
||||
apply plugin: KotlinPlugin
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
kotlin {
|
||||
srcDir 'src'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url 'file://' + pathToKotlinPlugin
|
||||
}
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile 'com.google.guava:guava:12.0'
|
||||
testCompile 'org.testng:testng:6.8'
|
||||
testRuntime 'org.jetbrains.kotlin:kotlin-stdlib:0.1-SNAPSHOT'
|
||||
}
|
||||
|
||||
test {
|
||||
useTestNG()
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.annotations = "externalAnnotations"
|
||||
kotlinOptions.optimize = false
|
||||
}
|
||||
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion="1.4"
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
<root>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner on(java.lang.String)'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner.MapJoiner withKeyValueSeparator(java.lang.String)'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
<item name='com.google.common.base.Joiner com.google.common.base.Joiner skipNulls()'>
|
||||
<annotation name="org.jetbrains.annotations.NotNull" />
|
||||
</item>
|
||||
</root>
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
package demo
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
class KotlinGreetingJoiner() {
|
||||
|
||||
val names = ArrayList<String?>()
|
||||
|
||||
fun addName(name : String?): Unit{
|
||||
names.add(name)
|
||||
}
|
||||
}
|
||||
|
||||
+14
-21
@@ -28,25 +28,19 @@ import org.jetbrains.jet.cli.common.CLICompiler;
|
||||
import org.jetbrains.jet.cli.common.ExitCode;
|
||||
import org.jetbrains.jet.cli.common.KotlinVersion;
|
||||
import org.jetbrains.jet.cli.common.arguments.CommonCompilerArguments;
|
||||
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
|
||||
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
|
||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.cli.jvm.K2JVMCompiler;
|
||||
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
|
||||
import org.jetbrains.jet.codegen.inline.InlineCodegenUtil;
|
||||
import org.jetbrains.jet.codegen.optimization.OptimizationUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@@ -321,24 +315,23 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
|
||||
arguments.noJdkAnnotations = true;
|
||||
arguments.annotations = getFullAnnotationsPath(log, annotationPaths);
|
||||
log.info("Using kotlin annotations from " + arguments.annotations);
|
||||
arguments.inline = inline;
|
||||
arguments.optimize = optimize;
|
||||
arguments.noInline = !CompilerArgumentsUtil.optionToBooleanFlag(inline, true);
|
||||
arguments.noOptimize = !CompilerArgumentsUtil.optionToBooleanFlag(optimize, true);
|
||||
|
||||
if (!CompilerArgumentsUtil.checkOption(arguments.inline)) {
|
||||
throw new MojoExecutionException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("inline", arguments.inline));
|
||||
if (!CompilerArgumentsUtil.checkOption(inline)) {
|
||||
throw new MojoExecutionException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("inline", inline));
|
||||
}
|
||||
|
||||
if (!CompilerArgumentsUtil.checkOption(arguments.optimize)) {
|
||||
throw new MojoExecutionException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("optimize", arguments.optimize));
|
||||
if (!CompilerArgumentsUtil.checkOption(optimize)) {
|
||||
throw new MojoExecutionException(CompilerArgumentsUtil.getWrongCheckOptionErrorMessage("optimize", optimize));
|
||||
}
|
||||
|
||||
log.info("Method inlining is " + CompilerArgumentsUtil.optionToBooleanFlag(arguments.inline, InlineCodegenUtil.DEFAULT_INLINE_FLAG));
|
||||
log.info(
|
||||
"Optimization mode is " + CompilerArgumentsUtil.optionToBooleanFlag(
|
||||
arguments.optimize,
|
||||
OptimizationUtils.DEFAULT_OPTIMIZATION_FLAG
|
||||
)
|
||||
);
|
||||
if (arguments.noInline) {
|
||||
log.info("Method inlining is turned off");
|
||||
}
|
||||
if (arguments.noOptimize) {
|
||||
log.info("Optimization is turned off");
|
||||
}
|
||||
}
|
||||
|
||||
protected String getFullAnnotationsPath(Log log, List<String> annotations) {
|
||||
|
||||
Reference in New Issue
Block a user