Kotlin 1.0.6 RC
Kotlin 1.0.6 RC is out!
What’s new
- IDE and Gradle plugins are now compatible with Android Studio 2.3;
- Fix incorrect inner class modifier for
sealed
inner classes;
- All-open compiler plugin to make classes and its members open (useful for mocking).
- No-arg compiler plugin that generates the default (zero-argument) class constructor (useful for JPA).
- “Convert function type parameter to receiver” (and back), “Add names to call arguments” intentions;
- Numerous fixes in the IDE plugin in inspections, intentions and Android Lint;
- Performance issue fixes in the debugger;
- Fixes in the experimental kapt.
The full changelog is avilable here.
All-open compiler plugin
All-open plugin makes classes and its members open without the explicit open
keyword, so it becomes easier to use frameworks/libraries such as Spring AOP or Mockito. You can read the detailed information about all-open in the corresponding KEEP proposal.
We provide all-open
plugin support for Gradle and Maven.
How to use all-open with Gradle
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
}
apply plugin: "kotlin-allopen"
allOpen {
annotation("com.your.Annotation")
}
If the class (or any of its superclasses) is annotated with com.your.Annotation
, the class itself and all its properties and functions will become all-open.
It even works with meta-annotations:
@com.your.Annotation
annotation class MyFrameworkAnnotation
@MyFrameworkAnnotation
class MyClass // will be all-open
We also provide the plugin for Spring:
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
}
apply plugin: "kotlin-spring"
Of course, you can use both kotlin-allopen
and kotlin-spring
in the same project.
How to use all-open with Maven
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<!-- Or "spring" for the Spring support -->
<plugin>all-open</plugin>
</compilerPlugins>
<pluginOptions>
<option>all-open:annotation=com.your.Annotation</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
No-arg compiler plugin
No-arg plugin generates an additional zero-argument constructor for annotated classes. The relevant proposal is available here. Note that the generated constructor is synthetic so it can’t be directly called both from Java and Kotlin; the only way to call it is by using reflection.
How to use no-arg in Gradle
The usage is similar with all-open.
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version"
}
}
// Or "kotlin-jpa" for Java Persistence API support
apply plugin: "kotlin-noarg"
noArg {
annotation("com.your.Annotation")
}
How to use no-arg in Maven
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<!-- Or "jpa" for the Java Persistence API support -->
<plugin>no-arg</plugin>
</compilerPlugins>
<pluginOptions>
<option>no-arg:annotation=com.your.Annotation</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
How to get EAP build
For IntelliJ IDEA:
You can configure Early Access Preview channel in Tools → Kotlin → Configure Kotlin Plugin Updates. Change the update channel and press Check for updates now.
For Gradle or Maven:
Add https://dl.bintray.com/kotlin/kotlin-eap to your repositories.
Change the version of Kotlin dependencies (compiler and stdlib) to 1.0.6-eap-112
.
Please do provide feedback and report any issues to our issue tracker (please specify your plugin version and IDE version).