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
Building Android Projects with kts
Search
Iñaki Villar
October 18, 2020
Technology
2
240
Building Android Projects with kts
Presentation Build Android Projects with kts.
Devfest Latam 2020
Devfest Pacific Region DevFest 2020
Iñaki Villar
October 18, 2020
Tweet
Share
More Decks by Iñaki Villar
See All by Iñaki Villar
Scaling Android Builds in Pandemic Times
cdsap
1
95
The Build Shrugged
cdsap
1
63
State of Testing in Kotlin
cdsap
0
130
Dexs, R8 and 3.3
cdsap
0
260
Deep Dive Work Manager
cdsap
0
150
Advanced Topics Android
cdsap
0
93
Kotlin: Server-Client
cdsap
0
72
Droidcon Dubai : Kotlin - Server - Client
cdsap
0
43
Kotlin: Server-Client
cdsap
3
480
Other Decks in Technology
See All in Technology
なんでもかんでもコンテナ化すればいいってもんでもないけど なんでもかんでもコンテナ化したらスッキリしました
saramune
1
160
Autonomous Database - Dedicated 技術詳細 / adb-d_technical_detail_jp
oracle4engineer
PRO
2
4.9k
ChatGPTのLT会-メモソフトにChatGPT入れると結構便利
okada_fuutass
0
150
Uniting Rust Servers and Clients through OpenAPI
ahl
0
430
Server-Side Kotlin + Spring Boot + Exposedでやったこと
ikefukurou777
0
110
二刀流でWinActorを活用してみた話
tamai_63
0
120
layerx-0-to-1-product-development-in-compound-startups
shnjtk
1
520
GitHub Actions Runner Controller
takesection
0
110
Tohoku.Tech #1 「EC-CUBE/AWSの構築をChatGPTに相談してみました」by テンダ
jun2882
0
130
Feature Flag Deep Dive
biwashi
20
5k
SSMエージェントはIAMロールの夢を見るか/ Do SSM Agents Dream Of IAM Roles?
yukihirochiba
0
1.4k
パフォーマンスを改善するには仕様変更が1番はやい
yamamotohiroya
12
4.6k
Featured
See All Featured
Documentation Writing (for coders)
carmenintech
59
3.7k
Rails Girls Zürich Keynote
gr2m
91
13k
What's in a price? How to price your products and services
michaelherold
236
11k
The Invisible Side of Design
smashingmag
293
49k
Design by the Numbers
sachag
274
18k
Thoughts on Productivity
jonyablonski
57
3.7k
A better future with KSS
kneath
230
16k
The Language of Interfaces
destraynor
150
22k
Building Flexible Design Systems
yeseniaperezcruz
317
37k
A Philosophy of Restraint
colly
195
15k
GraphQLとの向き合い方2022年版
quramy
28
12k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
4
1.4k
Transcript
None
None
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion 30
defaultConfig { applicationId “com.example.app" versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false } } }
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion 30
defaultConfig { applicationId “com.example.app" versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false } } } apply(plugin = "com.android.application") apply(plugin = "kotlin-android") android { compileSdkVersion(30) defaultConfig { applicationId = "com.example.app" versionCode = 1 versionName = "1.0" } buildTypes { getByName("release") { isMinifyEnabled = false } } }
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion 30
defaultConfig { applicationId “com.example.app" versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false } } } apply(plugin = "com.android.application") apply(plugin = "kotlin-android") android { compileSdkVersion(30) defaultConfig { applicationId = "com.example.app" versionCode = 1 versionName = "1.0" } buildTypes { getByName("release") { isMinifyEnabled = false } } }
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion 30
defaultConfig { applicationId “com.example.app" versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false } } } apply(plugin = "com.android.application") apply(plugin = "kotlin-android") android { compileSdkVersion(30) defaultConfig { applicationId = "com.example.app" versionCode = 1 versionName = "1.0" } buildTypes { getByName("release") { isMinifyEnabled = false } } }
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion 30
defaultConfig { applicationId “com.example.app" versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false } } } apply(plugin = "com.android.application") apply(plugin = "kotlin-android") android { compileSdkVersion(30) defaultConfig { applicationId = "com.example.app" versionCode = 1 versionName = "1.0" } buildTypes { getByName("release") { isMinifyEnabled = false } } }
apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion 30
defaultConfig { applicationId “com.example.app" versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false } } } apply(plugin = "com.android.application") apply(plugin = "kotlin-android") android { compileSdkVersion(30) defaultConfig { applicationId = "com.example.app" versionCode = 1 versionName = "1.0" } buildTypes { getByName("release") { isMinifyEnabled = false } } }
None
None
None
None
None
None
KTS
GRADLE JAVA API KTS
GRADLE JAVA API KTS Kotlin DSL API org.gradle.kotlin.dsl org.gradle.kotlin.dsl.plugins.dsl
GRADLE JAVA API KTS Kotlin DSL API org.gradle.kotlin.dsl org.gradle.kotlin.dsl.plugins.dsl implementation("com.github.oshi:oshi-core:3.13.3")
GRADLE JAVA API KTS Kotlin DSL API org.gradle.kotlin.dsl org.gradle.kotlin.dsl.plugins.dsl implementation("com.github.oshi:oshi-core:3.13.3")
fun DependencyHandler.`implementation`(dependencyNotation: Any): Dependency? = add("implementation", dependencyNotation)
Gradle
kotlin-compiler-embeddable Gradle
kotlin-compiler-embeddable kotlin-stdlib kotlin-reflect Gradle
6.8 kotlin-compiler-embeddable kotlin-stdlib kotlin-reflect Gradle 1.4 6.6 1.3 Gradle Kotlin
Module-a/build.gradle.kts
dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.60") implementation("org.influxdb:influxdb-java:2.19") } Module-a/build.gradle.kts
dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.60") implementation("org.influxdb:influxdb-java:2.19") } Module-a/build.gradle.kts object Dependencies { const
val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:1.3.60" const val influxDb = "org.influxdb:influxdb-java:2.19" }
dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.60") implementation("org.influxdb:influxdb-java:2.19") } Module-a/build.gradle.kts object Dependencies { const
val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:1.3.60" const val influxDb = "org.influxdb:influxdb-java:2.19" } dependencies { implementation(Dependencies.kotlin) implementation(Dependencies.influxDb) }
dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.60") implementation("org.influxdb:influxdb-java:2.19") } Module-a/build.gradle.kts object Dependencies { const
val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:1.3.60" const val influxDb = "org.influxdb:influxdb-java:2.19" } dependencies { implementation(Dependencies.kotlin) implementation(Dependencies.influxDb) }
Module-b/build.gradle.kts
Module-b/build.gradle.kts dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.60") implementation("org.influxdb:influxdb-java:2.19") }
Module-b/build.gradle.kts dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.60") implementation("org.influxdb:influxdb-java:2.19") }
Module-b/build.gradle.kts dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.60") implementation("org.influxdb:influxdb-java:2.19") } Module a Module b
build.gradle.kts build.gradle.kts
Plugins build scripts blocks buildSrc build.gradle.kts build.gradle Gradle API
Plugins build scripts blocks buildSrc build.gradle.kts build.gradle Gradle API
Plugins build scripts blocks buildSrc build.gradle.kts build.gradle Gradle API
Plugins build scripts blocks buildSrc build.gradle.kts build.gradle Gradle API dependencies
{ implementation("") implementation("") testImplementation("") } object Dependencies{ ... }
Plugins build scripts blocks buildSrc build.gradle.kts build.gradle Gradle API plugins
{ `kotlin-dsl` }
Plugins build scripts blocks buildSrc build.gradle.kts build.gradle Gradle API plugins
{ `kotlin-dsl` } import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.repositories class ExamplePlugin : Plugin<Project> { override fun apply(target: Project) { target.repositories { } target.dependencies { } } }
Plugins build scripts blocks buildSrc build.gradle.kts build.gradle Gradle API
Plugins build scripts blocks buildSrc build.gradle.kts build.gradle Gradle API buildscript
{ repositories { google() jcenter() } dependencies { classpath("com.android.tools.build:gradle:4.1.0") classpath(kotlin("gradle-plugin", version = "1.3.70")) } } plugins { id("com.android.application") kotlin("android") kotlin("android.extensions") }
buildSrc buildScript Plugins Gradle Module a build.gradle.kts Module b build.gradle.kts
buildSrc buildScript Plugins Gradle Module a build.gradle.kts Module b build.gradle.kts
buildSrc buildScript Plugins Gradle Module a build.gradle.kts Module b build.gradle.kts
buildSrc buildScript Plugins Gradle Module a build.gradle.kts Module b build.gradle.kts
buildSrc buildScript Plugins Gradle Module a build.gradle.kts Module b build.gradle.kts
Cache invalidation!!
Java Platform Plugin
Java Platform Plugin dependencies { constraints { api("commons-httpclient:commons-httpclient:3.1") api("org.apache.commons:commons-lang3:3.8.1") }
}
Java Platform Plugin dependencies { constraints { api("commons-httpclient:commons-httpclient:3.1") api("org.apache.commons:commons-lang3:3.8.1") }
} dependencies { api(platform(project(":platform"))) api("commons-httpclient:commons-httpclient") }
Java Platform Plugin dependencies { constraints { api("commons-httpclient:commons-httpclient:3.1") api("org.apache.commons:commons-lang3:3.8.1") }
} dependencies { api(platform(project(":platform"))) api("commons-httpclient:commons-httpclient") } https://docs.gradle.org/current/userguide/java_platform_plugin.html
refreshVersions https://github.com/jmfayard/refreshVersions
AGP 4.1
AGP 4.1 Full Support Kotlin DSL
AGP 4.1 Full Support Kotlin DSL API & DSL Kotlin
https://developer.android.com/reference/tools/gradle-api/4.1/com/android/build/api/dsl/ApplicationBaseFlavor
AGP 4.1 Full Support Kotlin DSL API & DSL Kotlin
AGP 4.1 Full Support Kotlin DSL API & DSL Kotlin
KTS = Kotlin in GRADLE SUPPORT AGP 4.1 BUILD SYSTEM
INTERNALS BUILD LOGIC > KTS
https://github.com/gradle/kotlin-dsl-samples https://medium.com/androiddevelopers/new-apis-in-the-android-gradle-plugin-f5325742e614 https://guides.gradle.org/migrating-build-logic-from-groovy-to-kotlin/ https://github.com/androidx/androidx AGP 4.1 MIGRATION SAMPLES ANDROIDX IDIOMATIC
https://github.com/jjohannes/idiomatic-gradle Resources
BUILD SUCCESSFUL in 30m 50s Thanks @inyaki_mwc