Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Tour of build system in Kotlin
Search
stormcat24
June 15, 2017
Programming
1
3.2k
Tour of build system in Kotlin
2017/06/15 CA.kt #1
stormcat24
June 15, 2017
Tweet
Share
More Decks by stormcat24
See All by stormcat24
素早く賢く失敗するDeveloper Productivityの実現を目指して
stormcat24
4
4.8k
KubernetesのマニフェストをそれなりにCIしたい
stormcat24
4
1.3k
令和時代のSaaS開発
stormcat24
1
250
History in 5 years of CircleCI and CyberAgent
stormcat24
3
830
Kubernetes Handson Osaka
stormcat24
5
560
Kubernetes Handson
stormcat24
5
4.3k
DockerとKubernetesでアプリケーション開発にコンテナをフル活用!
stormcat24
0
300
Base Image Journey 2018
stormcat24
29
140k
kotlin-fest
stormcat24
13
17k
Other Decks in Programming
See All in Programming
Multi Step Form, Decentralized Autonomous Organization
pumpkiinbell
1
860
技術を改善し続ける
gumioji
0
120
5分で理解する SOLID 原則 #phpcon_nagoya
shogogg
1
300
PHPカンファレンス名古屋2025 タスク分解の試行錯誤〜レビュー負荷を下げるために〜
soichi
1
670
Django NinjaによるAPI開発の効率化とリプレースの実践
kashewnuts
1
250
生成AIで加速するテスト実装 - ロリポップ for Gamersの事例と 生成AIエディタの活用
kinosuke01
0
110
2025.2.14_Developers Summit 2025_登壇資料
0101unite
0
180
Flutter × Firebase Genkit で加速する生成 AI アプリ開発
coborinai
0
170
コミュニティ駆動 AWS CDK ライブラリ「Open Constructs Library」 / community-cdk-library
gotok365
2
240
SwiftUI Viewの責務分離
elmetal
PRO
2
270
AIの力でお手軽Chrome拡張機能作り
taiseiue
0
190
推しメソッドsource_locationのしくみを探る - はじめてRubyのコードを読んでみた
nobu09
2
200
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
55
9.2k
The Language of Interfaces
destraynor
156
24k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Cost Of JavaScript in 2023
addyosmani
47
7.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
Building Better People: How to give real-time feedback that sticks.
wjessup
367
19k
Building Flexible Design Systems
yeseniaperezcruz
328
38k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
40
2k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
Gamification - CAS2011
davidbonilla
80
5.2k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
PRO
12
990
Transcript
Tour of build system in Kotlin 2017.06.15 CA.kt #1 @stormcat24
stormcat24 ‣ CyberAgent, Inc. ‣ FRESH! https://freshlive.tv ‣ http://blog.stormcat.io ‣
最近の興味はService Meshと仮想通貨
https://speakerdeck.com/stormcat24/spark-framework-with-kotlin
Kotlin、Android開発言語に
先見の明
FRESH! + Kotlin ‣ Androidは最初から ‣ 2016年夏から一部Microservicesで利用開始 ‣ OpenFRESH(Developer向けAPI)はKotlin +
SparkFramework ‣ Server Sideの基軸言語に一方的に認定 ‣ フルgRPC化に着手、ServerはもちろんKotlin(イマココ)
さて
皆さんGradle好きですか
僕はpom.xmlが好きです ※ウソです
GradleでKotlin 特に不自由は無いですが
他の選択肢も模索しておきたい
今日はビルドツールの話をします
Kobalt
Kobalt ‣ http://beust.com/kobalt/ ‣ DSL based on Kotlin ‣ ver1.0.87
‣ brew cask install kobalt
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`
kobalt-intellij-plugin ‣ https://github.com/cbeust/kobalt-intellij-plugin
Import to IDEA
Create Project on IDEA
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" } }
Code Completion
Kobalt所感 ‣ Build含めてKotlinで書ける ‣ 必要最小限のプラグインは揃ってる ‣ IDEAサポートちゃんとある ‣ Gradleの資産を使えるわけではない
Bazel
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
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", )
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", ], )
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や実行ファイルができる
Bazel所感 ‣ Release Engineer(ビルド職人)には良さそう ‣ Gradleからスイッチしたいとまでは現時点では思わない ‣ WindowsでAndroidビルドできない等、まだまだ途上 ‣ 1.0安定版は2018年6月予定
‣ IDEAプラグイン、イマイチ使い方わからなかった
Gradle4.0
_人人人人人人人_ > Gradle 4.0 <  ̄Y^Y^Y^Y^Y^Y ̄
Gradle 4.0 ‣ ビルドキャッシュ改善 ‣ —offlineオプション ‣ ローカルキャッシュの自動クリーンアップ ‣ ローカルキャッシュのサイズを設定、FIFOで古いものから削除
‣ 並列ダウンロード ‣ Gradle Script Kotlin 0.9.1
Upgrade to 4.0 $ ./gradlew wrapper --gradle-version=4.0
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
Gradle Kotlin Script ‣ https://github.com/gradle/gradle-script-kotlin ‣ GradleのDSLをKotlinで書くやつ ‣ build.gradleの代わりにbuild.gradle.ktsを書く
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() }
Gradle Kotlin Script所感 ‣ ちょっと勘所掴むまで手こずるかも ‣ IDEAがシンタックスエラーになるケースもある ‣ Kotlinでbuild.gradleを書けるのやっぱり(・∀・)イイ!! ‣
mv build.gradle build.gradle.ktsして、エラー箇所直してくスタイル
まとめ ‣ 他の選択肢を模索したら結局Gradleだったw ‣ 色々ツールあるが、結局はGradleと仲良くやってくのが良さそう ‣ Gradle Kotlin Scriptへの意識高めていこう