Questions tagged [gradle-kotlin-dsl]

Kotlin language support for Gradle build scripts.

Gradle build scripts have historically been written in Groovy. The Gradle Kotlin DSL project was created to create statically typed, clear, concise,and descriptive build scripts with awesome IDE support.

Build scripts are written in the Kotlin programming language, but using a Kotlin DSL (domain specific language) designed specifically to support building software.

Questions that belong here:

  • What causes a specific build script error?
  • How to convert a specific construct of a Groovy build script to its Kotlin equivalent?
  • How to achieve a specific processing task in your Kotlin build script?

Do not use this tag for general gradle questions.

Note: Before version 0.10.1 the "Gradle Kotlin DSL" project was called "Gradle Script Kotlin".

1145 questions
11
votes
1 answer

Android subprojects with Kotlin DSL

I'm working on migrating by Gradle build files to the Kotlin DSL and I encounter an issue. On my parent build.gradle, I have the following piece of code buildscript { repositories { google() mavenCentral() } dependencies { …
Robert Estivill
  • 12,369
  • 8
  • 43
  • 64
11
votes
1 answer

how do I add JavaFX to a gradle build file using Kotlin DSL?

how do I add the javafx dependencies through gradle? thufir@dur:~/NetBeansProjects/helloWorldJavaFX$ thufir@dur:~/NetBeansProjects/helloWorldJavaFX$ gradle clean > Configure project : e:…
Thufir
  • 8,216
  • 28
  • 125
  • 273
11
votes
5 answers

Gradle kotlin-dsl configuration not working, android extension function not recognized

I´m trying to configure my gradle setup with kotlin-dsl. My project gradle looks like this: buildscript { repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:3.3.2") …
Lemao1981
  • 2,225
  • 5
  • 18
  • 30
11
votes
8 answers

ShadowJar: No value has been specified for property 'mainClassName'

In tweaking my buildfile, I seem to have encountered a bug with mainClassName: thufir@dur:~/NetBeansProjects/HelloSeleniumWorld$ thufir@dur:~/NetBeansProjects/HelloSeleniumWorld$ ./gradlew clean ShadowJar --stacktrace > Task :shadowJar…
Thufir
  • 8,216
  • 28
  • 125
  • 273
11
votes
0 answers

Unsupported method: IdeaModuleDependency.getDependencyModule() error when migrating project to Gradle Kotlin DSL

I am getting a very uninformative error when I try to build my project after migrating from Gradle Groovy DSL to Kotlin DSL in IntelliJ IDEA. Unsupported method: IdeaModuleDependency.getDependencyModule(). The version of Gradle you connect to does…
zjuhasz
  • 1,489
  • 12
  • 30
11
votes
2 answers

Adding integration tests to Kotlin project using the Kotlin Gradle DSL

I would like to add an additional "source set" to a Kotlin project that will contain integration tests. I have seen a few posts that talk about doing it for either a vanilla Java project or for Kotlin but using Groovy rather than the Kotlin Gradle…
cdc
  • 2,511
  • 2
  • 17
  • 15
11
votes
0 answers

Debugging build.gradle.kts for Gradle Wrapper 4.7 build from IntelliJ 2018.1.4

I'm trying to debug a build.gradle.kts for a Gradle Wrapper 4.7 Kotlin DSL build in IntelliJ 2018.1.4 to. I ran: ./gradlew clean` ./gradlew build -Dorg.gradle.debug=true --no-daemon Gradle waited for a debugger to attach. I added breakpoints…
XDR
  • 4,070
  • 3
  • 30
  • 54
10
votes
1 answer

How can I call a function from a separate .gradle file from a gradle script using the Gradle Kotlin DSL?

Basically I want to do exactly this: Use Gradle function from other gradle file which is to say, call one function in one gradle script from another. The wrinkle is that my build.gradle is in Kotlin (build.gradle.kts) and the script my function is…
M Dapp
  • 1,453
  • 16
  • 31
10
votes
1 answer

Gradle publish depending on custom task using Kotlin dsl

I'm switching from groovy to Kotlin dsl (build.gradle.kts) for Gradle builds. My publish artifact depends on my custom task. And I do not understand how to make this dependency in Kotlin dsl. Original groovy code that I like to migrate to Kotlin…
Pavel
  • 653
  • 2
  • 11
  • 31
10
votes
3 answers

How to define the Kotlin version for both buildSrc and an application module?

I am using a buildSrc module in a multi-module Kotlin project to manage dependency definitions and versions. The module makes use of kotlin-dsl as shown in the build.gradle.kts: plugins { `kotlin-dsl` } Alternative declaration: plugins { …
JJD
  • 50,076
  • 60
  • 203
  • 339
10
votes
2 answers

Different ways to apply plugins ? (Gradle Kotlin DSL)

Trying to migrate this one project's build to GSK. We have this in Groovy: allprojects { apply plugin: 'java' ... sourceSets { ... } sourceCompatibility = ... } So while figuring out how to access the plugin convention in…
bruto
  • 467
  • 1
  • 4
  • 13
10
votes
3 answers

Kotlin and Gradle - Reading from stdio

I am trying to execute my Kotlin class using the command: ./gradlew -q run < src/main/kotlin/samples/input.txt Here is my HelloWorld.kt class: package samples fun main(args: Array) { println("Hello, world!") val lineRead =…
9
votes
2 answers

Configure Kotlin extension for Gradle subprojects

I'm setting up a multi-module Gradle project based on Kotlin for the JVM. Since the root project does not contain any code, the Kotlin plugin should only be applied to subprojects. build.gradle.kts (root project) plugins { kotlin("jvm") version…
9
votes
1 answer

Understanding all the ways to apply a plugin in Gradle

I'm trying to understand all the ways you can apply a plugin in Gradle, Kotlin DSL. This question answers part of my question, but not all of it (I'm guessing methods have been added in the six years that have passed since them). I've seen this…
J-bob
  • 8,380
  • 11
  • 52
  • 85
9
votes
0 answers

Android Studio 4.2 - The APK Set archive does not contain the following modules: [feature_login]

After updating android studio from 4.1.3 to 4.2 and especially com.android.tools.build:gradle:4.2.0 dependency, I receive the above error for my project that contains dynamic feature modules. Does someone else face the same problem? The problem is…