Skip to content

Instantly share code, notes, and snippets.

@nickytoh
Created October 20, 2019 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickytoh/9602ec0d228b6b01e0c3f30b8f645bfd to your computer and use it in GitHub Desktop.
Save nickytoh/9602ec0d228b6b01e0c3f30b8f645bfd to your computer and use it in GitHub Desktop.
Simple Kotlin Application with Gradle
plugins {
kotlin("jvm") version "1.3.50"
application
}
repositories {
jcenter()
}
dependencies {
implementation(kotlin("stdlib", "1.3.50"))
testImplementation("junit:junit:4.12")
}
application {
mainClassName = "app.smth.kotlin.MyLibrary"
}
package app.smth.kotlin
data class Language(val name: String, val hotness: Int)
class MyLibrary {
fun kotlinLanguage() = Language("Kotlin", 10)
companion object {
@JvmStatic
fun main(args: Array<String>) {
val languageName = MyLibrary().kotlinLanguage().name
println("My favorite language is $languageName")
}
}
}
package app.smth.kotlin
import org.junit.Assert.assertEquals
import org.junit.Test
class MyLibraryTest {
@Test fun testMyLanguage() {
assertEquals("Kotlin", MyLibrary().kotlinLanguage().name)
assertEquals(10, MyLibrary().kotlinLanguage().hotness)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment