Learning Kotlin by building

It took longer than I want to admit to have a simple Koltin application build this morning. The build.gradle.kts needed a bit of tweaking to get a simple 3 class application with a single test to properly build.

Here is the content of the build.gradle.kts:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
kotlin("jvm") version "1.4.10"
}
dependencies {
implementation(kotlin("stdlib"))
implementation("org.jetbrains.kotlin:kotlin-test:1.4.10")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
testImplementation("org.assertj:assertj-core:3.17.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
}
repositories {
mavenCentral()
}
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
jvmTarget = "11"
}
val compileTestKotlin: KotlinCompile by tasks
compileTestKotlin.kotlinOptions {
jvmTarget = "11"
}

Learning Kotlin 1/10000

It is a nice language to learn but I am not dedicating enough time right now to make the progress I would like.

Little thing I learned last night was the repo for use the Anko “library” in my code.

maven { url "http://dl.bintray.com/kotlin/kotlin-dev" }

Sometimes the simplest thing takes you an hour to figure out. All the examples for Anko that I looked at were partial so they showed the dependency line to add:

compile("org.jetbrains.anko:anko-commons:${anko_version}")

I guess that I have to be happy that I figured something out.

Back to coding a micro-service with Spring Boot and Kotlin…