https://kotlinlang.org logo
Title
h

henrik

09/27/2019, 7:05 AM
Hi. I'm a little disappointed in how little help I get from IntelliJ after switching to kotlin-dsl. For example this snippet:
tasks {
    val moduleTest by existing(Test::class) {
        setForkEvery(1)
    }
}
I'm not able to navigate to the
Test
class or to
setForkEvery
, and I don't get a list of other methods are available besides
setForkEvery
. Is there anything I can do to improve the situation?
g

GarouDan

09/27/2019, 7:40 AM
I don’t know if this help you, but when you configure gradle tasks inside intellij (using run configurations) you should be able to put breakpoints and inspect your code. But, if the navigation is not working this might not help too much. Did you enabled the auto reload support? In my case I have classes inside my buildSrc module and I can use autocompletion and navigation.
Also we have a gradle slack and usually the folks there are really kind giving suggestions. I’ve seen now that you posted there.
h

henrik

09/27/2019, 7:48 AM
I don't use auto-reload, but click on reload whenever I need to. I'm able to navigate to Libs and Versions (and everything else) in buildSrc, but not to anything in the Gradle API.
t

tapchicoma

09/27/2019, 8:23 AM
what gradle distribution are you using -
bin
or
all
?
g

GarouDan

09/27/2019, 8:33 AM
Hum, I think you need to add this thing here in your build.gradle.kts inside build.src
compile("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
Also this in the repositories (I also have in my settings.gradle.kts, but I don’t know if its going to be needed for you or not)
gradlePluginPortal()
h

henrik

09/27/2019, 9:06 AM
@tapchicoma: I'm using
all
@GarouDan Adding
kotlin-gradle-plugin
to buildSrc dependencies didn't help. And I've already got
gradlePluginPortal()
in
buildscript
g

GarouDan

09/27/2019, 10:08 AM
Is this class here?
.../.gradle/caches/transforms-2/files-2.1/.../unzipped-distribution/gradle-5.6.2/subprojects/testing-jvm/src/main/java/org/gradle/api/tasks/testing/Test.java
If yes I can navigate to it
h

henrik

09/27/2019, 3:35 PM
There's no
unzipped-distribution
anywhere in
~/.gradle/caches/
Also
~/.gradle/caches/transforms-2/files-2.1/
is empty
g

GarouDan

09/27/2019, 4:27 PM
I don’t know how to solve your problem, but probably is because of that you don’t have autocompletion. You will probably need to add the needed classpath dependencies in your project to have something in your
~/gradle/
and then use the proper autocompletion. This is my guess
h

henrik

09/27/2019, 6:46 PM
I have:
plugins {
   `kotlin-dsl`
}
... in
buildSrc/build.gradle.kts
, and ..
buildscript { 
  dependencies {
      classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50") 
      ...
   }
}
apply(plugin = "kotlin")

dependencies {
   compile("org.jetbrains.kotlin:kotlin-stdlib:1.3.50")
   compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50")
   ...
}
... in my regular
build.gradle.kts
Shouldn't that be sufficient? I guess I should create a demo project, this is a pretty large multiproject build with loads of gradle config (also mixed groovy/kotlin config at the time being)
Deleting all ipr/iml/iws config files and reimporting the project helped! Thanks a lot for your patience 🙂