How to configure kotlin script project with dependency on current module?

502 views Asked by At

I'd like to have:

  • directory with .kts files inside
  • classic src/main/kotlin/my/package module with classes

And have usage like:

kotlin my-script.main.kts

Where script looks like my-script.main.kts this from the example

#!/usr/bin/env kotlin

@file:Repository("https://jcenter.bintray.com")
@file:DependsOn("org.jetbrains.kotlinx:kotlinx-html-jvm:0.6.11")

import kotlinx.html.*; import kotlinx.html.stream.*; import kotlinx.html.attributes.*;
import my.package.*;

val addressee = args.firstOrNull() ?: "World"

print(createHTML().html {
    body {
        h1 { +"Hello, $addressee! from ${my.package.Greater.hello()}" }
    }
})


Restrictions:

  • no jar dependencies, at first publishing jar to maven repo then run script
  • clean design, it should be extendable and as not hello world project

How to configure kotlin script project with dependency on current module? What are the best practices so far?

0

There are 0 answers