Kotlin Gradle Script and Dependency Management

I am trying to connect a Spring application Cloud Stream app script to Kotlin. So far, so good, with the exception of the dependency management block. It's hard to find anything on the net. Samples also do not cover this topic.

How to convert the next block to build.gradle.kts? Thank.

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:Camden.SR2"
    }
}
+4
source share
1 answer

Not fully tested, but I believe it should be something like this:

import io.spring.gradle.dependencymanagement.DependencyManagementExtension
import io.spring.gradle.dependencymanagement.ImportsHandler

configure<DependencyManagementExtension> {
    imports(delegateClosureOf<ImportsHandler> {
        mavenBom("org.springframework.cloud:spring-cloud-dependencies:Camden.SR2")
    })
}

, gradle script kotlin groovy interop. groovy, , , . gradle script kotlin .

19 2016

gradle script kotlin friendly :

configure<DependencyManagementExtension> {
    imports {
        it.mavenBom("io.spring.platform:platform-bom:Camden.SR2")
    }
}

Kotlin, it ( ), !

3 2017

it, :

configure<DependencyManagementExtension> {
    imports {
        mavenBom("io.spring.platform:platform-bom:Camden.SR2")
    }
}
+8
source

Source: https://habr.com/ru/post/1662019/


All Articles