Created
October 20, 2019 17:21
-
-
Save nickytoh/9602ec0d228b6b01e0c3f30b8f645bfd to your computer and use it in GitHub Desktop.
Simple Kotlin Application with Gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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