Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Tour of build system in Kotlin

Tour of build system in Kotlin

2017/06/15 CA.kt #1

stormcat24

June 15, 2017
Tweet

More Decks by stormcat24

Other Decks in Programming

Transcript

  1. FRESH! + Kotlin ‣ Androidは最初から ‣ 2016年夏から一部Microservicesで利用開始 ‣ OpenFRESH(Developer向けAPI)はKotlin +

    SparkFramework ‣ Server Sideの基軸言語に一方的に認定 ‣ フルgRPC化に着手、ServerはもちろんKotlin(イマココ)
  2. Create Kobalt Project $ mkdir kobalt-example && kobalt-example (~/kobalt-example) $

    kobaltw --init kotlin _ __ _ _ _ | |/ / ___ | |__ __ _ | | | |_ | ' / / _ \ | '_ \ / _` | | | | __| | . \ | (_) | | |_) | | (_| | | | | |_ |_|\_\ \___/ |_.__/ \__,_| |_| \__| 1.0.87 Regular compilation time: 1553 ms Template "kotlin" installed Now you can run either `./kobaltw test` or `./kobaltw run`
  3. Build.kt val p = project { name = "kobalt-example" group

    = "io.stormcat" artifactId = name version = "0.1" dependencies { compile("org.jetbrains.kotlin:kotlin-stdlib:1.1.2-5") compile("com.squareup.okhttp3:okhttp:3.8.0") } assemble { jar {} } application { mainClass = "io.stormcat.example.MainKt" } }
  4. Bazel ‣ Google謹製, 現在0.5.1 ‣ 多言語/環境対応を統一されたDSLで ‣ C/C++, Java, Android,

    Objective-C, Go, Rust ‣ Shell, Docker, .deb(Debian Package) ‣ KotlinはKotlin Rules for Bazelを使う ‣ https://github.com/pubref/rules_kotlin
  5. Bazel WORKSPACE file git_repository( name = "org_pubref_rules_kotlin", remote = "https://github.com/pubref/rules_kotlin.git",

    tag = "v0.3.1", # update as needed ) load("@org_pubref_rules_kotlin//kotlin:rules.bzl", "kotlin_repositories") kotlin_repositories() maven_jar( name = "com_squareup_okhttp3_okhttp", artifact = "com.squareup.okhttp3:okhttp:3.8.0", )
  6. Bazel BUILD file package(default_visibility = ["//visibility:public"]) load("@org_pubref_rules_kotlin//kotlin:rules.bzl", "kotlin_binary", "kotlin_library") kotlin_binary(

    name = "main_kt", main_class = "io.stormcat.example.MainKt", srcs = glob(["src/main/kotlin/io/stormcat/example/**/*.kt"]), java_deps = [ "@com_squareup_okhttp3_okhttp//jar", ], )
  7. Build artifact (~/bazel-kotlin) $ bazel build //:main_kt ........................................................... ..... INFO:

    Found 1 target... Target //:main_kt up-to-date: bazel-bin/main_kt.jar bazel-bin/main_kt INFO: Elapsed time: 13.961s, Critical Path: 0.18s Jarや実行ファイルができる
  8. Pallarel Download $ ./gradlew build ... Download https://jcenter.bintray.com/io/springfox/springfox-swagger2/2.6.1/ springfox-swagger2-2.6.1.jar Download

    https://jcenter.bintray.com/io/springfox/springfox-swagger-ui/2.6.1/ springfox-swagger-ui-2.6.1.jar <-------------> 0% EXECUTING [1m 53s] > :compileKotlin > Resolve files of :compileClasspath > moshi-1.3.1.jar > aws-java-sdk-s3-1.11.61.jar > commons-lang3-3.5.jar > aws-java-sdk-core-1.11.61.jar > klaxon-0.27.jar > aws-java-sdk-sqs-1.11.61.jar > httpclient-4.5.2.jar > aws-java-sdk-kms-1.11.61.jar
  9. build.gradle.kts val springbootVersion = "1.4.0.RELEASE" plugins { application kotlin("jvm") idea

    } application { mainClassName = "samples.HelloWorldKt" } fun springBoot(artifact: String) = "org.springframework.boot:$artifact:$springbootVersion" dependencies { compile(kotlin("stdlib")) compile(springBoot("spring-boot-starter-web")) compile(springBoot("spring-boot-actuator")) } repositories { gradleScriptKotlin() }