Kotlin-dsl-samples: Missing documentation

Created on 25 May 2018  路  3Comments  路  Source: gradle/kotlin-dsl-samples

I was trying to convert the following simple block from groovy dsl to kotlin dsl

compileKotlin {
  kotlinOptions {
    freeCompilerArgs = ["-Xjsr305=strict"]
    jvmTarget = "1.8"
  }
}

First, I went to kotlin-dsl/samples, but was unable to find any relevant example. Next I turned to https://github.com/jnizet/gradle-kotlin-dsl-migration-guide/blob/master/README.adoc. From there I conclude that I would need to write val compileKotlin: XXX by tasks to get a corresponding task cast to a correct type. Then I will be able, hopefully, to use autocompletion to guide me further. But how can I find out what is the class of the task named compileKotlin? Or in general: given a task name, how can I find the class implementing that task?

I don't remember how, but I did found the class, KotlinCompile. But then my Idea was unable to find that actual class. Unknown package org.jetbrains. Gradle 4.7, Kotlin plugin 1.2.41

question superseded

Most helpful comment

You can use the Gradle help task, it will give you the type of the task:

./gradlew help --task compileKotlin

> Task :help
Detailed task information for :compileKotlin

Path
     :compileKotlin

Type
     KotlinCompile (org.jetbrains.kotlin.gradle.tasks.KotlinCompile)

Description
     Compiles the source set 'main'.kotlin.

This trick is being added to the in-progress migration guide at https://github.com/gradle-guides/migrating-build-logic-from-groovy-to-kotlin

879 would provide discoverability right from the IDE

All 3 comments

You can use the Gradle help task, it will give you the type of the task:

./gradlew help --task compileKotlin

> Task :help
Detailed task information for :compileKotlin

Path
     :compileKotlin

Type
     KotlinCompile (org.jetbrains.kotlin.gradle.tasks.KotlinCompile)

Description
     Compiles the source set 'main'.kotlin.

This trick is being added to the in-progress migration guide at https://github.com/gradle-guides/migrating-build-logic-from-groovy-to-kotlin

879 would provide discoverability right from the IDE

Eagerly waiting for migration guide! :) Using gradle for 5 years I didn't know that --help prints task's implementation class :)

Superseded by #811, closing

Was this page helpful?
0 / 5 - 0 ratings