Kotlin 1.0.6 EAP


#1

Kotlin 1.0.6 EAP

We are happy to announce the first EAP for Kotlin 1.0.6. As with 1.0.5, we are going to publish new EAP builds on a weekly basis; the final release is going to happen in the middle of December.

What’s new

  • File Structure window: visibility filters added, and members of anonymous classes are now shown;
  • Kotlin facet introduced;
  • “Join Declaration and Assignment”, “Remove empty primary constructor”, “Remove empty secondary constructor body” and “Convert function to lambda” intentions added;
  • Debugger fixes for inline functions in Android Studio and for cross-inline lambdas;
  • Numerous fixes in Android Lint;
  • “Create XML resource” Android intention added;
  • New experimental kapt plugin is available;
  • Bugfixes and performance improvements.

See the full changelog.

How to get EAP build

For IntelliJ IDEA:

You can configure Early Access Preview channel in ToolsKotlinConfigure 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-60.

Please do provide feedback and report any issues to our issue tracker (please specify your plugin version and IDE version).


#2

#3

I would appreciate more expansion on Kapt, as I’ve been stuck on 1.0.4 as all the new versions break dagger 2 and none of my tickets have been triaged - would really like some more visibility on what’s going on with this.

How are we meant to be using kapt now?


#4

Chris, maybe we should discuss by PM or elsewhere, but what is your problem with kapt and dagger2 ? I’m using both and got no problem on any version, though I’m using he experimental kapt since it is available (kapt2, are you still using kapt1 ?).

(Just tried kapt3, lots of things aren’t working, and dagger2 won’t because of Error:(5, 24) error: package javax.annotation does not exist
Error:(8, 2) error: cannot find symbol class Generated)


#5

Any plan to fix https://youtrack.jetbrains.com/issue/KT-12149 in 1.0.x as expected at some point or is it now expected for 1.1?


#6

Been using Kapt2 since it launched, 1.0.5 introduced bugs: Issues inner interfaces types not being found, @MultiBind issues.
1.0.6 just crashes with PSI stack traces (already tracked in YouTrack).

I have a huge project (12 modules), 100+ Dagger Components and Modules. I generally run into issues no one else has due to the complexity of my project.

I was asking for more visibility on this so I can work with/test the changes, know about how new things work in more detail so I can try things to raise better bugs and debug in a more useful fashion.


#7

We’re working on KT-12149 right now, and it will likely be released as part of 1.0.6.


#8

Awesome, thanks!


#9

what is Kotlin Facet?


#10

Kotlin Facet allows to have different kotlinc options (such as language version or options for compiler plugins) for different modules.
You can read more about facets in IntelliJ IDEA here.


#11

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 ToolsKotlinConfigure 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).


#12

thanks @yanex


#13

Thanks a lot @yanex.

As reported on Slack, the kotlin-spring meta annotation algorithm should be, if possible, improved to detect that @SpringBootApplication is transitively meta-annotated with @Component.

Also I successfully used noarg plugin with Spring Data MongoDB (see this commit) but it currently only works with Gradle + command line. With IDEA 2016.3 + Kotlin 1.1-M3 it does not work. Maybe that’s because such plugin is only supported in Kotlin IDEA plugin 1.0.6-eap-112 and not 1.1-M3 but we need Kotlin 1.1 in order to have build.gradle.kts autocomplete.

Is it expected? If yes, do you plan to integrate the 2 compiler plugins in 1.1-M4? Is there a workaround we can use with 1.1-M3?


#14

Fix for the transitive @Component annotations will be released as a part of 1.1-M4.

Talking about the IDEA plugin support, both allopen and noarg are supported in Kotlin IDEA plugin 1.0.6-eap-112. Unfortunately, I don’t know about the good workaround for the older IDEA plugins.


#15

Ok thanks, so I guess we need to wait 1.1-M4 to be released to have both Gradle Kotlin and noarg plugin support at the same time in IDEA.