Is there a simple way to scaffold a new (library) ...
# getting-started
d
Is there a simple way to scaffold a new (library) project for kotlin? Just getting started with kotlin and tried the options in intellij but it creates a project without a test runner which makes it somewhat difficult to run/interact with the code (scratch pads and worksheets seem to be broken and don’t output anything). Any recommendations?
c
Create a runner with
Copy code
fun main(args: Array) {
}
That should work without jvmstatic, or just run it from a unit test.
d
Yeah this seems to be simplest. But is this really how most people develop java/kotlin code 😄?
c
Most of the time people build a “showcase” or sample app if they build a library. If it doesn’t have a UI, you can just make it with unit tests I guess
t
If I’m understanding you correctly - you would start with a gradle or maven build file and import that into intellij
d
I’m pretty new to Kotlin/Java development in general (on the backend) so I wouldn’t know. I have a background in Ruby/Elixir which both have a REPL so trying to figure out how things are done in Kotlin 🙂 Thanks for the responses!
k
I start with a gradle project and import that into idea as well, so you've got your build tools set up from the start. Here's a guide on how to get started: https://kotlinlang.org/docs/reference/using-gradle.html.
e
I ususally just let gradle do that:
gradle init --type=kotlin-library
😍 1
😮 1
d
@eekboom Is there by any chance also a parameter that adds a test setup as well?
e
An example test is automatically generated.
m
@Dennis Tel Kotlin has a REPL as well if you want to experiment, just execute
kotlinc
from the shell without arguments, or in IntelliJ under the menu
Tools > Kotlin > Kotlin REPL