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
805
votes
54 answers

All com.android.support libraries must use the exact same version specification

After updating to android studio 2.3 I got this error message. I know it's just a hint as the app run normally but it's really strange. All com.android.support libraries must use the exact same version specification (mixing versions can lead to…
humazed
  • 74,687
  • 32
  • 99
  • 138
347
votes
24 answers

Still getting warning : Configuration 'compile' is obsolete and has been replaced with 'implementation'

I have replaced every occurrence of compile by implementation in my project's build.gradle, but I'm still getting this warning : I tried to look for "compile " in the whole project but no match was found. So what could be the cause?
Rob
  • 4,123
  • 3
  • 33
  • 53
253
votes
39 answers

Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details

Error:Execution failed for task ':app:compileDebugKotlin'. > Compilation error. See log for more details build:gradle(Module:app) buildscript { repositories { maven { url 'https://jitpack.io' url…
Ankur_009
  • 3,823
  • 4
  • 31
  • 47
193
votes
4 answers

In Gradle, is there a better way to get Environment Variables?

In several Tasks, I reference jars in my home folder. Is there a better way to get Environment Variables than ENV = System.getenv() HOME = ENV['HOME'] task copyToServer(dependsOn: 'jar', type: Copy) { from 'build/libs/' into HOME +…
190
votes
19 answers

How to set compileJava' task ( 11) and 'compileKotlin' task (1.8) jvm target compatibility to the same Java version in build.gradle.kts?

Build.gradle.kts buildscript { repositories { google() mavenCentral() gradlePluginPortal() } dependencies { classpath ("com.android.tools.build:gradle:7.0.2") classpath…
155
votes
8 answers

How do I exclude all instances of a transitive dependency when using Gradle?

My gradle project uses the application plugin to build a jar file. As part of the runtime transitive dependencies, I end up pulling in org.slf4j:slf4j-log4j12. (It's referenced as a sub-transitive dependency in at least 5 or 6 other transitive…
Jens D
  • 4,229
  • 3
  • 16
  • 19
142
votes
16 answers

Your project requires a newer version of the Kotlin Gradle plugin. (Android Studio)

I've just updated my flutter project packages to be null-safety compliant and now Android Studio wants me to update my project to use the latest version of Kotling Gradle Plugin. Can't see where to change this though. I have tried to change…
jeffmayn
  • 1,785
  • 2
  • 9
  • 22
105
votes
4 answers

How to add a maven repository by url using kotlinscript DSL (build.gradle.kts)

Whats the equivalent of the following code snippet from a build.gradle in a build.gradle.kts version? repositories { mavenCentral() maven { url '' } }
Florian Reisinger
  • 2,638
  • 4
  • 23
  • 34
101
votes
11 answers

org.gradle.api.InvalidUserCodeException: Querying the mapped value of provider (java.util.Set) before task ... has completed is not supported

I upgraded my project to Android Studio Arctic Fox, so I have to upgrade gradle to 7.0.2 and gradle build tool to 7.0.0-beta04. After synchronizing, I got this warning message in Sync tab: org.gradle.api.InvalidUserCodeException: Querying the mapped…
user1373996
87
votes
11 answers

ext in buildscript can not be recognised by Gradle Kotlin DSL

In these days, I am trying to write some codes to experience the Spring reactive features and kotlin extension in Spring 5, and I also prepared a gradle Kotlin DSL build.gradle.kt to configure the gradle build. The build.gradle.kt is converted from…
Hantsy
  • 8,006
  • 7
  • 64
  • 109
80
votes
5 answers

Gradle Single vs Double Quotes

I'm new to gradle and am currently just trying to follow the tutorials and quite a few times I've seen single and double quotes intermixed. I just wanted to know if there was a difference of when one set should be used over the other. One example of…
Dan W
  • 5,718
  • 4
  • 33
  • 44
72
votes
10 answers

Add classpath in manifest using Gradle

I would like my Gradle build script to add the complete Classpath to the manifest file contained in JAR file created after the build. Example: Manifest-Version: 1.0 Class-Path: MyProject.jar SomeLibrary.jar AnotherLib.jar My build script already…
Paolo Fulgoni
  • 5,208
  • 3
  • 39
  • 55
70
votes
4 answers

How to create a fat JAR with Gradle Kotlin script?

As titled, I'd like to know how to modify the gradle.build.kts in order to have a task to create a unique jar with all the dependencies (kotlin lib included) inside. I found this sample in Groovy: //create a single Jar with all dependencies task…
elect
  • 6,765
  • 10
  • 53
  • 119
59
votes
14 answers

Plugin [id: 'dagger.hilt.android.plugin'] was not found in any of the following sources

I get the following warning when I want to use @AndroidEntryPoint which is a property of hilt in my project. Expected @AndroidEntryPoint to have a value. Did you forget to apply the Gradle Plugin? (dagger.hilt.android.plugin) When I try to add id…
Hasan Kucuk
  • 2,433
  • 6
  • 19
  • 41
58
votes
7 answers

Gradle Kotlin DSL: Define Kotlin version in unique place

For describing Gradle build scripts, we can use Kotlin via build.gradle.kts files. It's a common problem to globally define the Kotlin version to be used, both in the dependencies and also in the build plugin section (It's rather uncommon to have…
s1m0nw1
  • 76,759
  • 17
  • 167
  • 196
1
2 3
76 77