title | date | author | tags | keywords | categories | reward | reward_title | reward_wechat | reward_alipay | source_url | translator | translator_url |
---|---|---|---|---|---|---|---|---|---|---|---|---|
Kotlin 1.0.6 is here! |
2016-12-27 12:11:00 -0800 |
yanex |
官方动态 |
false |
Have a nice Kotlin! |
We are happy to announce the release of Kotlin 1.0.6, the new bugfix and tooling update for Kotlin 1.0. This version brings a significant number of improvements related to the IDE plugin and Android support. We’d like to thank our external contributors whose pull requests are included in this release: Kirill Rakhman and Yoshinori Isogai . We also want to thank everyone of our EAP users for their feedback. It is really valuable for us, as always. You can find the full list of changes in the changelog . Some of the changes worth highlighting are described below.
We continue to add intentions for converting code to idiomatic Kotlin. The IDE now automatically suggests to replace try-finally
block with the use() call when all the finally
block does is closing a resource.
Named arguments help to increase code readability. With the new “Add names to call arguments” intention you can easily add the name to an argument, or just substitute names for all call arguments at once.
{% raw %}
{% endraw %}- Inspection/intention for removing empty secondary constructor body, as well as empty primary constructor declaration;
- “Join declaration and assignment” intention;
- Fixes for inline functions and performance improvements in debugger;
- Numerous fixes in intentions, KDoc and Quick Doc.
- Android Studio 2.3 beta 1 is now supported, as well as the Android Gradle plugin version 2.3.0-alpha3 and newer.
- “Create XML resource” intention is added;
- Android Extensions support is now active in the IDE only if the corresponding plugin is enabled in the build.gradle;
- Significant number of fixes in Android Lint. Also the “Suppress Lint” intention is added.
We continue to work on the experimental version of Kotlin annotation processing tool (kapt). While there are still some things to do in order to fully support incremental compilation, performance of the annotation processing is significantly increased since Kotlin 1.0.4.
To enable experimental kapt, just add the following line to your build.gradle
:
apply plugin: 'kotlin-kapt'
The all-open compiler plugin makes classes annotated with a specific annotation and their members open without the explicit open
keyword, so it becomes much easier to use frameworks/libraries such as Spring AOP or Mockito. You can read the detailed information about all-open in the corresponding KEEP .
We provide all-open plugin support both for Gradle and Maven, as well as the IDE integration.
{% raw %}
{% endraw %}buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
}
apply plugin: "kotlin-allopen"
allOpen {
annotation("com.your.Annotation")
}
{% raw %}
{% endraw %}If the class (or any of its superclasses) is annotated with com.your.Annotation
, the class itself and all its members will become open. It even works with meta-annotations:
{% raw %}
{% endraw %}@com.your.Annotation
annotation class MyFrameworkAnnotation
@MyFrameworkAnnotation
class MyClass // will be all-open
{% raw %}
{% endraw %}We also provide the “kotlin-spring” plugin that already has all required annotations for the Spring framework:
{% raw %}
{% endraw %}buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
}
apply plugin: "kotlin-spring"
{% raw %}
{% endraw %}Of course, you can use both kotlin-allopen
and kotlin-spring
in the same project.
{% raw %}
{% endraw %}<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>
<!-- Each annotation is placed on its own line -->
<option>all-open:annotation=com.your.Annotation</option>
<option>all-open:annotation=com.their.AnotherAnnotation</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
{% raw %}
{% endraw %}The no-arg compiler plugin generates an additional zero-argument constructor for classes with a specific annotation. The generated constructor is synthetic so it can’t be directly called from Java or Kotlin, but it can be called using reflection. You can see motivating discussion here .
The usage is pretty similar to all-open.
{% raw %}
{% endraw %}buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version"
}
}
// Or "kotlin-jpa" for the Java Persistence API support
apply plugin: "kotlin-noarg"
noArg {
annotation("com.your.Annotation")
}
{% raw %}
{% endraw %}{% raw %}
{% endraw %}<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<!-- Or "jpa" for the Java Persistence annotation 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>
{% raw %}
{% endraw %}To update the IDEA plugin, use Tools | Kotlin | Configure Kotlin Plugin Updates and press the “Check for updates now” button. Also, don’t forget to update the compiler and standard library version in your Maven and Gradle build scripts. The command-line compiler can be downloaded from the Github release page . As usual, if you run into any problems with the new release, you’re welcome to ask for help on the forums , on Slack (get an invite here ), or to report issues in the issue tracker . Let’s Kotlin!