Support inline true/false options
This commit is contained in:
+6
-1
@@ -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)
|
||||
|
||||
+6
@@ -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()
|
||||
|
||||
-1
@@ -45,7 +45,6 @@ task show << {
|
||||
|
||||
compileKotlin {
|
||||
kotlinOptions.annotations = "externalAnnotations"
|
||||
kotlinOptions.enableInline = "off";
|
||||
}
|
||||
|
||||
|
||||
|
||||
+50
@@ -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"
|
||||
}
|
||||
+11
@@ -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>
|
||||
+13
@@ -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>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package org.jetbrains
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
System.out?.println(getGreeting())
|
||||
}
|
||||
|
||||
fun getGreeting() : String {
|
||||
return "Hello, World!"
|
||||
}
|
||||
+13
@@ -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 );
|
||||
}
|
||||
+6
-3
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user