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
7
votes
2 answers

Cannot access 'com.android.build.gradle.internal.dsl.Lockable' on Android Studio Arctic Fox | 2020.3.1 Canary 12

how are you doing? Did you get this kind of error when writing a gradle plugin using kotlin DSL: Cannot access 'com.android.build.gradle.internal.dsl.Lockable' which is a supertype of 'com.android.build.gradle.BaseExtension'. Check your module…
7
votes
2 answers

How to get Firebase App Distribution to work for different flavors with Kotlin DSL?

I have an issue with Firebase Distribution configuration. Here's a part of my build.gradle in Kotlin DSL flavorDimensions("dim") productFlavors { create("fl1") { applicationIdSuffix = ".fl1" setDimension("dim") …
7
votes
2 answers

publishing aar using maven plugin and kotlin dsl

I am having problems when trying to use maven-publish plugin from AS. I tried that example with a project and it works without problem. But as soon as I move to kotlin dsl, I have this issue: SoftwareComponentInternal with name 'release' not…
Leandro Ocampo
  • 1,894
  • 18
  • 38
7
votes
2 answers

Why cannot be `const val` used in build.gradle.kts

I'd like to define a version constant in guild.gradle.kts file so that it can be used even in the plugins block. The plugins block requires restricted syntax: «plugin version» must be constant, literal, strings Following the restriction I tried to…
czerny
  • 15,090
  • 14
  • 68
  • 96
7
votes
1 answer

How to enable helpful NullPointerExceptions in gradle test

This problem has been fixed in Gradle 6.6 Original post I want to put the flag -XX:+ShowCodeDetailsInExceptionMessages to enable helpful NPEs (https://openjdk.java.net/jeps/358) on the tests I tried tasks.withType { …
apflieger
  • 912
  • 10
  • 18
7
votes
2 answers

How to add jvmArgs using kotlin dsl?

I need to open some javafx modules and I'm told to put it in the build.gradle.kts. I have no idea how to add jvmArgs to the run task with the kotlin DSL? Can someone show me how please.
AlwaysNeedingHelp
  • 1,851
  • 3
  • 21
  • 29
7
votes
0 answers

how to convert build.gradle.kts to old build.gradle

I want to convert this file in old build.gradle file, I am doing but there are alot of errors. have searched too many google links but nothing happened. I want to convert this file in old build.gradle file, I am doing but there are alot of…
Asad
  • 71
  • 3
7
votes
2 answers

How to set unit test jvmargs using gradle kotlin dsl

I'm trying to set jvmargs for unit tests using kotlin-dsl and I can't get it to work. This is so that I can add the "-noverify" argument and allow intellji test runner to collect code coverage info. Groovy, works: testOptions { unitTests.all…
7
votes
2 answers

how to configure build.gradle.kts to fix error "Duplicate JVM class name generated from: package-fragment"

I'm trying to follow this tutorial https://dev.to/tagmg/step-by-step-guide-to-building-web-api-with-kotlin-and-dropwizard and am instead writing my gradle.build file in Kotlin's DSL and am finding there is no direct mapping from Groovy to Kotlin and…
Quilty Kim
  • 455
  • 1
  • 4
  • 18
7
votes
1 answer

Gradle kotlin how to call function defined in parent?

When working with gradle multimodule project, is it possible to define functions in parent project but use them in submodules build.gradle.kts? Note i do not need untyped tasks registered and called with strings... I want actual typesafe code to be…
vach
  • 10,571
  • 12
  • 68
  • 106
7
votes
2 answers

Flyway and gradle kotlin dsl

I'm migrating from Gradle to Gradle Kotlin DSL, and I have a question. Have flyway { url = System.getenv ('DB_URL') user = System.getenv ('DB_USER') password = System.getenv ('DB_PASSWORD') baselineOnMigrate = true locations =…
Rodrigo Batista
  • 383
  • 1
  • 6
  • 16
7
votes
3 answers

Configure Jacoco with gradle and kotlin DSL

I'm trying to configure Jacoco to exclude some classes from analysis but can't find any working example :( I found some samples with afterEvaluate but no success
yodamad
  • 1,452
  • 14
  • 24
7
votes
2 answers

How do I create an additional Kotlin SourceSet using Gradle with Kotlin DSL

I want to create a test lib source set, src/tlib/kotlin that "sits between" main and test. I have this, but I'm not sure why I would use java source dir for kotlin, and I need to get it depending on my main sources sourceSets { …
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
7
votes
4 answers

Why I cannot access project properties in "plugins" section of build.gradle.kts with Gradle Kotlin DSL (5.0)?

Gradle 5.0, Kotlin DSL Create gradle.properties file: kotlinVersion=1.3.10 Create build.gradle.kts file: val kotlinVersion: String by project println(kotlinVersion) // works plugins { kotlin("jvm").version(kotlinVersion) // …
Viktor
  • 1,298
  • 15
  • 28
7
votes
1 answer

execute JavaExec task using gradle kotlin dsl

I've created simple build.gradle.kts file group = "com.lapots.breed" version = "1.0-SNAPSHOT" plugins { java } java { sourceCompatibility = JavaVersion.VERSION_1_8 } repositories { mavenCentral() } dependencies {} task("execute") { …
lapots
  • 12,553
  • 32
  • 121
  • 242