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
14
votes
1 answer

Cannot access 'kotlin.collections.Collection' which is a supertype of 'org.gradle.api.artifacts.dsl.RepositoryHandler'

I got the above error after i add Plugins{ `kotlin`} to my build.gradle.kts file. I have Google this problem and rebuild after delete all .gradle、.idea dir, but this problem still occurs. Additionally, i tried invalidate caches, but not work. Any…
Cyrus
  • 8,995
  • 9
  • 31
  • 58
14
votes
2 answers

The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android dependency was found

im getting this gradle sync error - The Hilt Android Gradle plugin is applied but no com.google.dagger:hilt-android dependency was found. can someone help please ? :) im using kotlin dsl, i have libs.kt in buildSrc buildSrc -…
Kochchy
  • 591
  • 1
  • 6
  • 17
14
votes
0 answers

SourceSet with name 'jvmMain' not found

I'm trying to run kotlin multiplatform project with jvm and js source sets but am getting the following error: FAILURE: Build failed with an exception. * Where: Initialization script '/private/var/folders/yc/sdfads/T/Home_main__.gradle' line: 20 *…
Marcel Bro
  • 4,907
  • 4
  • 43
  • 70
14
votes
2 answers

How to configure Firebase Performance Monitoring plugin extension in Gradle Kotlin DSL

I have an Android app using Gradle with Kotlin DSL. I'm adding Firebase Performance Monitoring, but I would like for it to be enabled only for a specific build type. I've been following the instructions provided at Firebase - Disable Firebase…
14
votes
4 answers

gradle kotlin dsl - How to configure dependencies for subprojects

I'm creating gradle multi project for kotlin programming. When I create dependencies under subprojects in main project build.gradle.kts I'm getting error Configuration with name 'implementation' not found. Below is my configuration - plugins…
user51
  • 8,843
  • 21
  • 79
  • 158
14
votes
1 answer

Why is 'publishing' function not being found in my custom gradle.kts file within buildSrc directory?

I have a custom gradle.kts script I am building that will do our maven publishing for all of our various modules to our sonatype repository, but encountering a strange error. Here are the contents of my maven-deploy.gradle.kts file: plugins { …
Shan
  • 541
  • 3
  • 11
14
votes
7 answers

@Parcelize not resolved with androidExtensions experimental mode set to true

After switching to Gradle Kotlin DSL Gradle is not able to resolve @Parcelize annotation or package import kotlinx.android.parcel.Parcelize ("Unresolved reference" error). That happens with stable Kotlin plugin and latest Canary one. Build fails in…
marcinm
  • 281
  • 1
  • 2
  • 11
14
votes
2 answers

How to use JUnit 5 with build.gradle.kts and kotlin?

Java version java 10.0.1 2018-04-17 Kotlin version 1.2.41 Gradle version 4.7 it will be even better if we could use jigsaw module system
xiang
  • 1,384
  • 1
  • 12
  • 28
13
votes
2 answers

Reading Gradle properties in settings.gradle.kts

So I'm using Gradle Kotlin DSL, I want to know if it's possible to read gradle properties inside settings.gradle.kts? I have gradle.properties file like this: nexus_username=something nexus_password=somepassword I've done it like this, but still…
Jimly Asshiddiqy
  • 335
  • 4
  • 15
13
votes
1 answer

Gradle 7.0 Version Catalog for maven bom

I have published maven bom and imported it in top level build.gradle.kts as: allProjects { dependencies { implementation(platform("com.example:some-dependencies:1.2.3")) } } And then in libs.versions.toml: [libraries] some-bom = {…
Hiosdra
  • 332
  • 3
  • 11
13
votes
1 answer

Gradle 6.6.1 and Kotlin 1.4 - runtime version conflict

I use the latest Gradle (v. 6.6.1) and the latest Kotlin (v. 1.4). buildSrc project defines all Kotlin versions. And unfortunately it receives the error below. The `kotlin-dsl` plugin applied to project ':buildSrc' enables experimental Kotlin…
Manushin Igor
  • 3,398
  • 1
  • 26
  • 40
13
votes
6 answers

Android studio 4.0 update is giving lint infrastructure error, when used with gradle 6.1.1

I am trying to update my android studio to 4.0(gradle build tools 4.0) and also updating gradle to 6.1.1 from 5.6.4. But when I do that I am getting a build error specifically for lint task. So when I run ./gradlew build or ./gradlew lint I am…
13
votes
4 answers

Gradle Kotlin DSL can't find java.io package

I'm trying to convert the build.gradle file of an Android app to a Kotlin DSL. This file has a function like this: def getLastCommitHash() { def stdout = new ByteArrayOutputStream() exec { commandLine 'git', 'rev-parse', '--short',…
Henrique Rocha
  • 149
  • 1
  • 9
13
votes
3 answers

How to set global variables in gradle.kts?

My app uses several gradle.kts scripts. I want to set one variable which would be global for everyone. object Versions{ val kotlin_version = "1.3.60-eap-25" } but it is not resolved: classpath…
Nurseyit Tursunkulov
  • 8,012
  • 12
  • 44
  • 78
13
votes
2 answers

How to efficiently populate extra properties in the Gradle Kotlin DSL?

I'm migrating Gradle build scripts from Groovy to Kotlin DSL and one of the things which is not really documented is how to populate extra properties. In Groovy, I can write: ext { comp = 'node_exporter' compVersion = '0.16.0' …
Vít Kotačka
  • 1,472
  • 1
  • 15
  • 40