You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.
importorg.gradle.api.Pluginimportorg.gradle.api.Projectimportorg.gradle.kotlin.dsl.getValueimportorg.gradle.kotlin.dsl.creatingopenclassExampleKotlinDslPlugin : Plugin<Project> {
overridefunapply(project:Project) {
project.run {
val myTask by tasks.creating
}
}
}
Your Environment
Gradle 4.3-rc-2
IntelliJ IDEA 2017.2.5
Build #IU-172.4343.14, built on September 26, 2017
Licensed to Mike Kobit
You have a perpetual fallback license for this version
Subscription is active until September 5, 2018
JRE: 1.8.0_152-release-915-b12 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.10.0-37-generic
The text was updated successfully, but these errors were encountered:
Thanks for the well written report @mkobit!
This looks like an IntelliJ issue to me, related to how delegated properties are handled.
We need to find/fill an upstream issue. Ideally reproducing the faulty behavior with a simple Kotlin project not involving the Gradle Kotlin DSL.
One workaround would be to import org.gradle.kotlin.dsl.*
Good call with the star import (although I try not to use them) - definitely makes sense to report upstream as this is most likely an IntelliJ issue - I reported it here first due to it being the first and primary place I ran into it.
I'll hopefully report it tonight, but if not in the next few days and follow up on this issue.
eskatos
changed the title
IntellIj suggests unused import for org.gradle.kotlin.dsl.getValue when using kotlin-dsl and doesn't suggest import for creating
KT-22101 IntellIj suggests unused import for org.gradle.kotlin.dsl.getValue when using kotlin-dsl and doesn't suggest import for creatingJan 4, 2018
If we're going to ask people to use Kotlin in buildSrc, I think this is important.
The issue understates what happens in practice. The import is marked as unused, IntelliJ optimizes the imports and removes it, the build then fails. If you add the import back and save, IntelliJ removes it again. The only way to get it to not do this is to fiddle with Intellij defaults.
@big-guy, I don't recall this happening to me. Do you have Optimize imports on the fly enabled? I believe it's not the default.
This also happens when using by registering in a plugin which requires import org.gradle.kotlin.dsl.provideDelegate or import import org.gradle.kotlin.dsl.* as previously suggested.
When trying to use the domain object extension methods
getting
andcreating
in a plugin when usingkotlin-dsl
it leads to less than ideal behavior.Moving pictures speak a thousand words:
val taskName by tasks.getting
val taskName by tasks.creating
Expected Behavior
import
is not marked as unusedby creating
Current Behavior
import
is grayed out and removed by the Optimize Imports actionby creating
Context
Using
kotlin-dsl
in a plugin I am writingSteps to Reproduce (for bugs)
In
src/main/kotlin/ExampleKotlinDslPlugin.kt
Your Environment
Gradle 4.3-rc-2
IntelliJ IDEA 2017.2.5
Build #IU-172.4343.14, built on September 26, 2017
Licensed to Mike Kobit
You have a perpetual fallback license for this version
Subscription is active until September 5, 2018
JRE: 1.8.0_152-release-915-b12 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Linux 4.10.0-37-generic
The text was updated successfully, but these errors were encountered: