Questions tagged [kotlin-dsl]
68 questions
1
vote
0 answers
How to access a variable defined in root build.gradle file from subproject build.gradle using kotlin dsl?
A variable defined in root build.gradle fille
def a = 1
and i want access the variable a in subproject's build.gradle.ktl file.
Notice subproject's gradle file uses kotlin dsl.

initLiu
- 19
- 1
1
vote
0 answers
Kotlin DSL to store configurations instead of JSON
After reading about Kotlin, and particularly about Kotlin DSL, it seems to be a good way to replace JSON configuration files.
I have a service that takes a configuration file argument (resource), something like --config='path/to/configX.json'.
There…

Thomas
- 1,053
- 2
- 11
- 20
1
vote
1 answer
Match request method with Kotlin DSL for Spring Security
Spring Security provided Kotlin DSL for easier configuration. Here's an example from Spring Blog:
override fun configure(http: HttpSecurity?) {
http {
httpBasic {}
authorizeRequests {
authorize("/greetings/**",…

rmalviya
- 1,847
- 12
- 39
1
vote
0 answers
How to dynamically change application Id in Kotlin DSL
Here my code snippet
val applicationId = when {
this.name.contains("test") -> this.mergedFlavor.applicationId + ".test"
this.name.contains("paidDebug") -> this.mergedFlavor.applicationId + ".dbg"
this.name.contains("freeDebud") ->…

j Ganesh
- 11
- 1
1
vote
2 answers
gradle kotlin DSL extendsfrom
How can I reformulate:
testCompile.extendsFrom compileOnly
of the Gradle Groovy DSL to its Kotlin-based equivalent?
configurations {
testCompile{
extendsFrom(compileOnly)
}
}
My approach above fails.

Georg Heiler
- 16,916
- 36
- 162
- 292
1
vote
1 answer
Kotlin DSL with optional fields
I'm currently in the process of learning about Kotlin DSLs.
I've been playing around with it for a while now but I'm unable to solve my use case. I have a simple DSL, and I don't care too much of the types it has as long as I can achieve a syntax…

Stefan
- 214
- 1
- 12
1
vote
3 answers
How to write the following Kotlin contract?
The question is very simple: (using Kotlin 1.3.71)
I have the following data alike this one:
data class Location(val lat: Double, val lng: Double)
I want to achieve a type-safety with a call like so:
val loc = location {
lat = 2.0
lng =…

Some random IT boy
- 7,569
- 2
- 21
- 47
1
vote
1 answer
Kotlin testing the restriction in DSL
We are writing a DSL in Kotlin, and we have added a few restrictions in that DSL.
For eg,
table {
tr {
td {
}
}
}
Here, we restrict td should not be called inside another td.
How do we test this? Is there any dsl-testkit or matcher…

Dollyg
- 317
- 2
- 7
1
vote
2 answers
Kotlin Gradle DSL JSONObject not mocked
Since I converted my Groovy to Kotlin DSL gradle, my unittests are not working anymore. I get the error:
java.lang.RuntimeException: Method get in org.json.JSONObject not mocked. See http://g.co/androidstudio/not-mocked for details.
So i followed…

Geert Berkers
- 653
- 7
- 19
1
vote
1 answer
How can I write this Gradle build script snippet in Groovy?
I recently cloned a Gradle projcet (from GitHub) that its scripts is in Kotlin DSL (that I'm not comfortable with it). I could convert all of its scripts to Groovy except below snippet:
publishing {
publications {
register("mavenJava",…

ali.etemadi77
- 79
- 1
- 4
1
vote
1 answer
How to migrate from Kotlin 1.2 to 1.3 with the kotlin-dsl Gradle plugin?
I am currently using the kotlin-dsl Gradle plugin 0.18.2, Kotlin 1.2.51 and Gradle 4.10.2 in my Android project (take a look at the temporary project-setup branch).
I like to migrate to Kotlin 1.3. However, I have difficulties in finding out which…

JJD
- 50,076
- 60
- 203
- 339
1
vote
1 answer
How to ignore explicitly importing classes like gradle kotlin script when writing custom kotlin-dsl
In the gradle's kotlin build script, we don't need explicitly import classes or functions like plugins, repositories or dependencies in build script build.gradle.kts.
plugins {
val kotlinVersion = "1.3.10"
val springBootVersion =…

Kane
- 8,035
- 7
- 46
- 75
0
votes
0 answers
Kotlin DSL allows using Property of other class
I'm new to Kotlin DSL and unfortunately I can't find a corresponding reference in the documentation. I probably missed that somewhere and also can't find the right keywords for a successful search on Google.
I have the following code
data class…

Lars Michaelis
- 559
- 2
- 6
- 11
0
votes
0 answers
Spring Boot Kotlin DSL
lately I have asked a question about dsl config in this question Spring Boot and Kotlin DSL Configuration
After some more tests, I figured out that below class's userSignInService is not autowired. The proxy does not have the actual instance to…

Olgun Kaya
- 2,519
- 4
- 32
- 46
0
votes
0 answers
How can I get values from listOf param in kotlin DSL?
I have a BuildType with this param:
select(
name = "services_to_deploy",
value = "",
label = "Services to deploy",
display = ParameterDisplay.PROMPT,
allowMultiple =…

Win32Sector
- 65
- 2
- 10