https://kotlinlang.org logo
Title
g

GarouDan

02/12/2019, 2:29 PM
I’m trying to use only
.gradle.kts
instead of
.gradle
ones on my project. And I’m having a lot of doubts because of this. How can I convert this to
kts
?
kotlinFrontend {
    downloadNodeJsVersion = 'latest'

    sourceMaps = true

    npm {
        dependency "style-loader"
        dependency("react")
        dependency("react-dom")

        devDependency("karma")
    }

    webpackBundle {
        bundleName = "main"
        contentPath = file('src/main/web')
    }
}
Using something like
task("kotlinFrontend") {
don’t work since the inner parts aren’t recognized.
l

Lucas

02/12/2019, 5:38 PM
kotlinFrontend
is a block to configure the frontend plugin, so it should be defined as
kotlinFrontend { }
or
configure<KotlinFrontendExtension> { }
. The
task()
function is used to configure Gradle Tasks only. I didn't tried, but maybe this sample could help. https://github.com/gyulavoros/kotlin-todomvc/blob/master/frontend/build.gradle.kts
g

GarouDan

02/12/2019, 6:35 PM
Thanks a lot 😃
g

gildor

02/13/2019, 3:15 AM
task("kotlinFrontend") {
don’t work since the inner parts aren’t recognized.
In general, to make it work you have to specify also type of task, but also it’s incorrect syntax, because this syntax, you have to say do you want to create or get existing task
but in this case this is not a task, but extension
kotlinFrontend should work if you use plugins dsl, how in example that Danilo shared