kotlin-maven-plugin: Add apiVersion parameter linked with kotlin.compiler.apiVersion property.
Test apiVersion parameter is applied as explicitly and as implicitly inferred from languageVersion. #KT-14298
This commit is contained in:
@@ -0,0 +1 @@
|
||||
invoker.buildResult = failure
|
||||
@@ -0,0 +1,67 @@
|
||||
<?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</groupId>
|
||||
<artifactId>test-apiVersion</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.9</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<kotlin.compiler.apiVersion>1.0</kotlin.compiler.apiVersion>
|
||||
</properties>
|
||||
|
||||
<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>
|
||||
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<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>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
fun useApiFrom11() {
|
||||
mapOf<Any, Any>().toMutableMap()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
source(new File(basedir, "../../../verify-common.bsh").getAbsolutePath());
|
||||
|
||||
assertBuildLogHasLine("[INFO] BUILD FAILURE");
|
||||
assertBuildLogHasLineThatContains("Unresolved reference: toMutableMap");
|
||||
@@ -16,7 +16,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-runtime</artifactId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
+4
@@ -1,3 +1,7 @@
|
||||
sealed class Base
|
||||
|
||||
class Derived : Base()
|
||||
|
||||
fun useApiFrom11() {
|
||||
mapOf<Any, Any>().toMutableMap()
|
||||
}
|
||||
@@ -2,3 +2,4 @@ source(new File(basedir, "../../../verify-common.bsh").getAbsolutePath());
|
||||
|
||||
assertBuildLogHasLine("[INFO] BUILD FAILURE");
|
||||
assertBuildLogHasLineThatContains("This type is sealed");
|
||||
assertBuildLogHasLineThatContains("Unresolved reference: toMutableMap");
|
||||
|
||||
+5
@@ -114,6 +114,10 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
@Parameter(property = "kotlin.compiler.languageVersion", required = false, readonly = false)
|
||||
protected String languageVersion;
|
||||
|
||||
|
||||
@Parameter(property = "kotlin.compiler.apiVersion", required = false, readonly = false)
|
||||
protected String apiVersion;
|
||||
|
||||
/**
|
||||
* Additional command line arguments for Kotlin compiler.
|
||||
*/
|
||||
@@ -222,6 +226,7 @@ public abstract class KotlinCompileMojoBase<A extends CommonCompilerArguments> e
|
||||
|
||||
arguments.suppressWarnings = nowarn;
|
||||
arguments.languageVersion = languageVersion;
|
||||
arguments.apiVersion = apiVersion;
|
||||
|
||||
getLog().info("Compiling Kotlin sources from " + sources);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user