Questions tagged [kotlin-dsl]

68 questions
0
votes
1 answer

Kotlin DSL variable imitation

Using Kotlin type-safe builders one might end up writing this code code { dict["a"] = "foo"; // dict is a Map hidden inside that can associate some name to some value println(dict["a"]); // usage of this value } This code is ok, but there is a…
0
votes
1 answer

Teamcity Kotlin Build Base Class Property Extension

I've extracted my Teamcity builds as Kotlin outputs. I want to create a base class that defines a number of common steps/settings, but allow individual builds to extend these properties. e.g. open class BuildBase(init: BuildBase.() -> Unit) :…
Obsidian Phoenix
  • 4,083
  • 1
  • 22
  • 60
0
votes
2 answers

Kotlin: higher-order function taking vararg lamba-with-receiver, where the receiver takes arguments

I am trying to wrap a hierarchy of Java builders in a Kotlin type-safe builder. The hierarchy consists of the following builders (and their targets): FigureBuilder (Figure) LayoutBuilder (Layout) TraceBuilder (Trace) In Java, FigureBuilder has one…
L. Blanc
  • 2,150
  • 2
  • 21
  • 31
0
votes
1 answer

Why configurations.all { conf: Configuration -> ... } compile error with: Type mismatch: inferred type is Unit but Boolean was expected

I use build.gradle.kts to build my android project. The following code does NOT compile: configurations.all { conf: Configuration -> println(conf) } error is: println(conf) ^ Type mismatch: inferred type is Unit but Boolean was…
walfud
  • 21
  • 4
0
votes
1 answer

Kotlin property not initialized, but why?

We're writing an internal DSL in Kotlin. Then we use it from our Java code. We see that the objects defined in the DSL are not yet available. Hence the question: Why is the package property not initialized? Simplified the situation is thus: val…
Michiel Leegwater
  • 1,172
  • 4
  • 11
  • 27
0
votes
1 answer

Kotlin dsl for Mutablelist add

here is an extensible function I want to use in adding more element to a mutableList. fun MutableList.withFields(block: () -> Field): MutableList { this.add(block()) return this } here is how I get to use the function fun…
Belvi Nosakhare
  • 3,107
  • 5
  • 32
  • 65
0
votes
2 answers

Spring boot failing to resolve spring-boot-dependencies using gradle kotlin dsl

The build.gradle.kts file looks like this: buildscript { val springBootVersion by extra("2.1.3.RELEASE") repositories { mavenCentral() } dependencies { …
0
votes
2 answers

Required and one-of-more idioms

Kotlin DSL support is great, but I ran into two scenarios I can only add workaround. Both workaround has its major drawback as they enforce constraints only at execution time. First constraint: required parameter I would like to write something like…
Balage1551
  • 1,037
  • 1
  • 10
  • 28
1 2 3 4
5