Support inline true/false options

This commit is contained in:
Mikhael Bogdanov
2014-03-20 15:32:20 +04:00
parent 0b1470b5e5
commit ca4609dd2a
34 changed files with 357 additions and 46 deletions
@@ -21,8 +21,8 @@ import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.types.Reference;
import org.jetbrains.jet.buildtools.core.BytecodeCompiler;
import org.jetbrains.jet.buildtools.core.Util;
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException;
import org.jetbrains.jet.lang.types.lang.InlineUtil;
import java.io.File;
import java.util.Arrays;
@@ -141,7 +141,12 @@ public class BytecodeCompilerTask extends Task {
String stdlibPath = (this.stdlib != null ? getPath(this.stdlib) : null);
String[] classpath = (this.compileClasspath != null ? this.compileClasspath.list() : null);
String[] externalAnnotationsPath = (this.externalAnnotations != null) ? this.externalAnnotations.list() : null;
boolean enableInline = InlineUtil.optionToInlineFlag(inline);
if (!CompilerArgumentsUtil.checkInlineOption(inline)) {
throw new CompileEnvironmentException(CompilerArgumentsUtil.getWrongOptionErrorMessage(inline));
}
boolean enableInline = CompilerArgumentsUtil.optionToInlineFlag(inline);
if (this.src != null) {
@@ -0,0 +1,45 @@
/*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.cli.common.arguments;
import org.jetbrains.annotations.Nullable;
public class CompilerArgumentsUtil {
public static final boolean DEFAULT_INLINE_FLAG = true;
public static final boolean DEFAULT_INLINE_FLAG_FOR_TEST = true;
public static boolean optionToInlineFlag(@Nullable String option) {
boolean enableInline = "on".equalsIgnoreCase(option) || "true".equalsIgnoreCase(option);
return (enableInline || "off".equalsIgnoreCase(option) || "false".equalsIgnoreCase(option)) ? enableInline : DEFAULT_INLINE_FLAG;
}
public static boolean checkInlineOption(@Nullable String option) {
if (option == null ||
"on".equalsIgnoreCase(option) ||
"off".equalsIgnoreCase(option) ||
"true".equalsIgnoreCase(option) ||
"false".equalsIgnoreCase(option)) {
return true;
}
return false;
}
public static String getWrongOptionErrorMessage(@Nullable String inline) {
return "Wrong value for inline option: '" + inline + "'. Should be 'on'/'off' or 'true'/'false'";
}
}
@@ -66,6 +66,6 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
@Argument(value = "kotlinHome", description = "Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery")
public String kotlinHome;
@Argument(value = "inline", description = "Inlining mode: on/off (default is on)")
public String enableInline;
@Argument(value = "inline", description = "Inlining mode: on/off or true/false (default is on)")
public String inline;
}
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.cli.common.CLICompiler;
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
import org.jetbrains.jet.cli.common.ExitCode;
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments;
import org.jetbrains.jet.cli.common.messages.*;
import org.jetbrains.jet.cli.jvm.compiler.*;
@@ -32,7 +33,6 @@ import org.jetbrains.jet.codegen.CompilationException;
import org.jetbrains.jet.config.CommonConfigurationKeys;
import org.jetbrains.jet.config.CompilerConfiguration;
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
import org.jetbrains.jet.lang.types.lang.InlineUtil;
import org.jetbrains.jet.utils.KotlinPaths;
import org.jetbrains.jet.utils.KotlinPathsFromHomeDir;
import org.jetbrains.jet.utils.PathUtil;
@@ -108,7 +108,7 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, arguments.notNullAssertions);
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, arguments.notNullParamAssertions);
configuration.put(JVMConfigurationKeys.ENABLE_INLINE, InlineUtil.optionToInlineFlag(arguments.enableInline));
configuration.put(JVMConfigurationKeys.ENABLE_INLINE, CompilerArgumentsUtil.optionToInlineFlag(arguments.inline));
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector);
@@ -197,11 +197,9 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
protected void checkArguments(@NotNull K2JVMCompilerArguments argument) {
super.checkArguments(argument);
String inline = argument.enableInline;
if (inline != null) {
if (!"on".equalsIgnoreCase(inline) && !"off".equalsIgnoreCase(inline)) {
throw new IllegalArgumentException("Wrong value for inline option: '" + inline + "'. Should be 'on' or 'off'");
}
if (!CompilerArgumentsUtil.checkInlineOption(argument.inline)) {
throw new IllegalArgumentException(CompilerArgumentsUtil.getWrongOptionErrorMessage(argument.inline));
}
}
}
@@ -18,7 +18,6 @@ package org.jetbrains.jet.cli.jvm.compiler;
import com.google.common.base.Predicates;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.psi.PsiFile;
import kotlin.Function0;
@@ -30,6 +29,7 @@ import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
import org.jetbrains.jet.cli.common.CompilerPlugin;
import org.jetbrains.jet.cli.common.CompilerPluginContext;
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
import org.jetbrains.jet.cli.common.messages.MessageCollector;
import org.jetbrains.jet.cli.common.output.OutputDirector;
@@ -48,7 +48,6 @@ import org.jetbrains.jet.lang.resolve.ScriptNameUtil;
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.types.lang.InlineUtil;
import org.jetbrains.jet.plugin.MainFunctionDetector;
import org.jetbrains.jet.utils.KotlinPaths;
@@ -308,7 +307,7 @@ public class KotlinToJVMBytecodeCompiler {
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, false),
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, false),
GenerationState.GenerateClassFilter.GENERATE_ALL,
configuration.get(JVMConfigurationKeys.ENABLE_INLINE, InlineUtil.DEFAULT_INLINE_FLAG)
configuration.get(JVMConfigurationKeys.ENABLE_INLINE, CompilerArgumentsUtil.DEFAULT_INLINE_FLAG)
);
KotlinCodegenFacade.compileCorrectFiles(generationState, CompilationErrorHandler.THROW_EXCEPTION);
return generationState;
@@ -32,6 +32,7 @@ import org.jetbrains.annotations.Nullable;
import org.jetbrains.asm4.Type;
import org.jetbrains.jet.OutputFile;
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
import org.jetbrains.jet.cli.common.messages.MessageCollector;
import org.jetbrains.jet.cli.common.messages.MessageCollectorToString;
@@ -56,7 +57,6 @@ import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.resolve.scopes.WritableScopeImpl;
import org.jetbrains.jet.lang.types.lang.InlineUtil;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.plugin.JetLanguage;
import org.jetbrains.jet.storage.ExceptionTracker;
@@ -248,7 +248,7 @@ public class ReplInterpreter {
BindingContext bindingContext = AnalyzeExhaust.success(trace.getBindingContext(), module).getBindingContext();
GenerationState generationState = new GenerationState(psiFile.getProject(), ClassBuilderFactories.BINARIES,
bindingContext, Collections.singletonList(psiFile), InlineUtil.DEFAULT_INLINE_FLAG);
bindingContext, Collections.singletonList(psiFile), CompilerArgumentsUtil.DEFAULT_INLINE_FLAG);
compileScript(psiFile.getScript(), scriptClassType, earlierScripts, generationState,
CompilationErrorHandler.THROW_EXCEPTION);
@@ -85,6 +85,16 @@ public class AntTaskTest extends KotlinIntegrationTestBase {
doJvmAntTest();
}
@Test
public void inlineDisabled() throws Exception {
doJvmAntTest();
}
@Test
public void inlineWrongArg() throws Exception {
doAntTest(FAILED);
}
@Test
public void jvmClasspath() throws Exception {
doJvmAntTest();
@@ -0,0 +1,10 @@
OUT:
Buildfile: [TestData]/build.xml
build:
[kotlinc] Compiling [[[TestData]/hello.kt]] => [[Temp]/hello.jar]
BUILD SUCCESSFUL
Total time: [time]
Return code: 0
@@ -0,0 +1,7 @@
<project name="Ant Task Test" default="build">
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
<target name="build">
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar" inline="false"/>
</target>
</project>
@@ -0,0 +1,7 @@
package hello
fun main(args : Array<String>) {
for (s in arrayList("a"))
println("Hello, $s!")
}
@@ -0,0 +1,4 @@
OUT:
Hello, a!
Return code: 0
@@ -0,0 +1,31 @@
OUT:
Buildfile: [TestData]/build.xml
build:
ERR:
BUILD FAILED
[TestData]/build.xml:5: org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentException: Wrong value for inline option: 'wrong'. Should be 'on'/'off' or 'true'/'false'
at org.jetbrains.jet.buildtools.ant.BytecodeCompilerTask.execute(BytecodeCompilerTask.java:146)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
at org.apache.tools.ant.Project.executeTarget(Project.java:1329)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
at org.apache.tools.ant.Main.runBuild(Main.java:801)
at org.apache.tools.ant.Main.startAnt(Main.java:218)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
Total time: [time]
Return code: 1
@@ -0,0 +1,7 @@
<project name="Ant Task Test" default="build">
<taskdef resource="org/jetbrains/jet/buildtools/ant/antlib.xml" classpath="${kotlin.lib}/kotlin-ant.jar"/>
<target name="build">
<kotlinc src="${test.data}/hello.kt" output="${temp}/hello.jar" inline="wrong"/>
</target>
</project>
@@ -0,0 +1,7 @@
package hello
fun main(args : Array<String>) {
for (s in arrayList("a"))
println("Hello, $s!")
}
+1 -1
View File
@@ -13,7 +13,7 @@ Usage: org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
-module [String] module to compile
-script [flag] evaluate script
-kotlinHome [String] Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
-inline [String] Inlining mode: on/off (default is on)
-inline [String] Inlining mode: on/off or true/false (default is on)
-tags [flag] Demarcate each compilation message (error, warning, etc) with an open and close tag
-verbose [flag] Enable verbose logging output
-version [flag] Display compiler version
+1 -1
View File
@@ -13,7 +13,7 @@ Usage: org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
-module [String] module to compile
-script [flag] evaluate script
-kotlinHome [String] Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
-inline [String] Inlining mode: on/off (default is on)
-inline [String] Inlining mode: on/off or true/false (default is on)
-tags [flag] Demarcate each compilation message (error, warning, etc) with an open and close tag
-verbose [flag] Enable verbose logging output
-version [flag] Display compiler version
+1 -1
View File
@@ -13,7 +13,7 @@ Usage: org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
-module [String] module to compile
-script [flag] evaluate script
-kotlinHome [String] Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
-inline [String] Inlining mode: on/off (default is on)
-inline [String] Inlining mode: on/off or true/false (default is on)
-tags [flag] Demarcate each compilation message (error, warning, etc) with an open and close tag
-verbose [flag] Enable verbose logging output
-version [flag] Display compiler version
+2 -2
View File
@@ -1,4 +1,4 @@
Wrong value for inline option: 'wrong'. Should be 'on' or 'off'
Wrong value for inline option: 'wrong'. Should be 'on'/'off' or 'true'/'false'
Usage: org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
-jar [String] jar file name
-src [String] source file or directory (allows many paths separated by the system path separator)
@@ -14,7 +14,7 @@ Usage: org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
-module [String] module to compile
-script [flag] evaluate script
-kotlinHome [String] Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
-inline [String] Inlining mode: on/off (default is on)
-inline [String] Inlining mode: on/off or true/false (default is on)
-tags [flag] Demarcate each compilation message (error, warning, etc) with an open and close tag
-verbose [flag] Enable verbose logging output
-version [flag] Display compiler version
+1 -1
View File
@@ -14,7 +14,7 @@ Usage: org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments
-module [String] module to compile
-script [flag] evaluate script
-kotlinHome [String] Path to Kotlin compiler home directory, used for annotations and runtime libraries discovery
-inline [String] Inlining mode: on/off (default is on)
-inline [String] Inlining mode: on/off or true/false (default is on)
-tags [flag] Demarcate each compilation message (error, warning, etc) with an open and close tag
-verbose [flag] Enable verbose logging output
-version [flag] Display compiler version
@@ -23,6 +23,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment;
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
@@ -31,7 +32,6 @@ import org.jetbrains.jet.codegen.state.Progress;
import org.jetbrains.jet.config.CompilerConfiguration;
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
import org.jetbrains.jet.lang.types.lang.InlineUtil;
import org.jetbrains.jet.utils.UtilsPackage;
import java.io.File;
@@ -62,7 +62,7 @@ public class CodegenTestUtil {
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, true),
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, true),
GenerationState.GenerateClassFilter.GENERATE_ALL,
configuration.get(JVMConfigurationKeys.ENABLE_INLINE, InlineUtil.DEFAULT_INLINE_FLAG_FOR_TEST)
configuration.get(JVMConfigurationKeys.ENABLE_INLINE, CompilerArgumentsUtil.DEFAULT_INLINE_FLAG_FOR_TEST)
);
KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
return state.getFactory();
@@ -21,11 +21,11 @@ import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
import org.jetbrains.jet.lang.types.lang.InlineUtil;
import java.util.Collections;
import java.util.List;
@@ -59,7 +59,7 @@ public class GenerationUtils {
public static GenerationState compileFilesGetGenerationState(@NotNull Project project, @NotNull AnalyzeExhaust analyzeExhaust, @NotNull List<JetFile> files) {
analyzeExhaust.throwIfError();
GenerationState state = new GenerationState(project, ClassBuilderFactories.TEST, analyzeExhaust.getBindingContext(), files,
InlineUtil.DEFAULT_INLINE_FLAG_FOR_TEST);
CompilerArgumentsUtil.DEFAULT_INLINE_FLAG_FOR_TEST);
KotlinCodegenFacade.compileCorrectFiles(state, CompilationErrorHandler.THROW_EXCEPTION);
return state;
}
@@ -28,16 +28,6 @@ import org.jetbrains.jet.lang.resolve.constants.EnumValue;
public class InlineUtil {
public static final boolean DEFAULT_INLINE_FLAG = true;
public static final boolean DEFAULT_INLINE_FLAG_FOR_TEST = true;
public static final boolean DEFAULT_INLINE_FLAG_FOR_STUB = false; /*always false*/
public static boolean optionToInlineFlag(@Nullable String option) {
return ("on".equalsIgnoreCase(option) || "off".equalsIgnoreCase(option)) ? "on".equalsIgnoreCase(option) : DEFAULT_INLINE_FLAG;
}
public static boolean hasNoinlineAnnotation(@NotNull CallableDescriptor valueParameterDescriptor) {
KotlinBuiltIns builtIns = KotlinBuiltIns.getInstance();
return KotlinBuiltIns.containsAnnotation(valueParameterDescriptor, builtIns.getNoinlineClassAnnotation());
@@ -28,6 +28,7 @@ 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() {
@@ -114,7 +115,11 @@ public open class KotlinCompile(): AbstractCompile() {
args.noStdlib = true
args.noJdkAnnotations = true
args.enableInline = kotlinOptions.enableInline
args.inline = kotlinOptions.inline
if (!CompilerArgumentsUtil.checkInlineOption(args.inline)) {
throw GradleException(CompilerArgumentsUtil.getWrongOptionErrorMessage(args.inline))
}
val messageCollector = GradleMessageCollector(logger)
val exitCode = compiler.exec(messageCollector, args)
@@ -37,6 +37,12 @@ class BasicKotlinGradleIT : BaseGradleIT() {
}
}
Test fun testInlineDisabled() {
Project("inlineDisabled").build("build", "-Pkotlin.gradle.plugin.version=0.1-SNAPSHOT") {
assertSuccessful()
}
}
Test fun testSimpleKDoc() {
Project("delta").build("kdoc", "-Pkotlin.gradle.plugin.version=0.1-SNAPSHOT") {
assertSuccessful()
@@ -45,7 +45,6 @@ task show << {
compileKotlin {
kotlinOptions.annotations = "externalAnnotations"
kotlinOptions.enableInline = "off";
}
@@ -0,0 +1,50 @@
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.inline = false
}
task wrapper(type: Wrapper) {
gradleVersion="1.4"
}
@@ -0,0 +1,11 @@
<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>
@@ -0,0 +1,13 @@
package demo
import java.util.ArrayList
class KotlinGreetingJoiner() {
val names = ArrayList<String?>()
fun addName(name : String?): Unit{
names.add(name)
}
}
@@ -70,11 +70,6 @@
</goals>
</execution>
</executions>
<configuration>
<inline>
off
</inline>
</configuration>
</plugin>
</plugins>
</build>
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jetbrains.kotlin.it</groupId>
<artifactId>test-inlineDisabled</artifactId>
<version>1.0</version>
<name>Test Hello World project</name>
<description>
Test the kotlin-maven-plugin:compile goal on HelloWorld project.
</description>
<properties>
<kotlin.version>0.1-SNAPSHOT</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
</plugin>
</plugins>
</pluginManagement>
<!--suppress MavenModelInspection -->
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<!--suppress MavenModelInspection -->
<!--testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory-->
<plugins>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<inline>false</inline>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,9 @@
package org.jetbrains
fun main(args : Array<String>) {
System.out?.println(getGreeting())
}
fun getGreeting() : String {
return "Hello, World!"
}
@@ -0,0 +1,13 @@
package org.jetbrains;
import org.junit.Test;
import static junit.framework.Assert.assertEquals;
public class HelloWorldJavaTest {
@Test
public void greeting() {
assertEquals("Hello, World!", org.jetbrains.JetbrainsPackage.getGreeting());
}
}
@@ -0,0 +1,7 @@
import java.io.*;
File file = new File( basedir, "target/test-inlineDisabled-1.0.jar" );
if (!file.exists() || !file.isFile())
{
throw new FileNotFoundException( "Could not find generated JAR: " + file );
}
@@ -33,7 +33,7 @@ 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.lang.types.lang.InlineUtil;
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
import java.io.File;
import java.io.IOException;
@@ -312,8 +312,11 @@ public abstract class KotlinCompileMojoBase extends AbstractMojo {
arguments.noJdkAnnotations = true;
arguments.annotations = getFullAnnotationsPath(log, annotationPaths);
log.info("Using kotlin annotations from " + arguments.annotations);
arguments.enableInline = inline;
log.info("Method inlining is " + InlineUtil.optionToInlineFlag(arguments.enableInline));
arguments.inline = inline;
if (!CompilerArgumentsUtil.checkInlineOption(arguments.inline)) {
throw new MojoExecutionException(CompilerArgumentsUtil.getWrongOptionErrorMessage(arguments.inline));
}
log.info("Method inlining is " + CompilerArgumentsUtil.optionToInlineFlag(arguments.inline));
}
protected String getFullAnnotationsPath(Log log, List<String> annotations) {