Share
Embed
Use Kotlin for build.gradle.
Gradle Kotlin DSL helps us to write build.gradle with Kotlin.
I try to use it, and explain how to do it.
Amane Nikaido
October 27, 2017
Transcript
22 slides
-
TFUUJOHTHSBEMF pluginManagement { repositories { gradlePluginPortal() maven { url "https://jcenter.bintray.com/"
} maven { url "https://dl.google.com/dl/android/maven2/" } } resolutionStrategy { eachPlugin { if(requested.id.id == "com.android.application") { useModule("com.android.tools.build:gradle:$ {requested.version}") } } } } include ‘:app' rootProject.buildFileName = 'build.gradle.kts' -
TFUUJOHTHSBEMF pluginManagement { repositories { gradlePluginPortal() maven { url "https://jcenter.bintray.com/"
} maven { url "https://dl.google.com/dl/android/maven2/" } } resolutionStrategy { eachPlugin { if(requested.id.id == "com.android.application") { useModule("com.android.tools.build:gradle:$ {requested.version}") } } } } include ':app' rootProject.buildFileName = 'build.gradle.kts' "OESPJEQMVHJO͔Βඞཁ -
CVJMEHSBEMFLUTमਖ਼ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion
26 buildToolsVersion "26.0.2" defaultConfig { applicationId “jp.a2kaido.view" minSdkVersion 21 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro' } } -
CVJMEHSBEMFLUTमਖ਼ apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion
26 buildToolsVersion "26.0.2" defaultConfig { applicationId “jp.a2kaido.view" minSdkVersion 21 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro' } } -
plugins { id("com.android.application") version "3.0.0" kotlin("android") version "1.1.51" } android
{ compileSdkVersion 26 buildToolsVersion "26.0.2" defaultConfig { applicationId “jp.a2kaido.view" minSdkVersion 21 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro' CVJMEHSBEMFLUTमਖ਼ -
plugins { id("com.android.application") version "3.0.0" kotlin("android") version "1.1.51" } android
{ compileSdkVersion 26 buildToolsVersion "26.0.2" defaultConfig { applicationId "jp.a2kaido.view" minSdkVersion 21 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard- rules.pro' } } } dependencies { CVJMEHSBEMFLUTमਖ਼ -
plugins { id("com.android.application") version "3.0.0" kotlin("android") version "1.1.51" } android
{ compileSdkVersion(26) buildToolsVersion("26.0.2") defaultConfig { applicationId = "jp.a2kaido.view" minSdkVersion(21) targetSdkVersion(26) versionCode = 1 versionName = "1.0" testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" } buildTypes { getByName("release") { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard- rules.pro") } } } dependencies { CVJMEHSBEMFLUTमਖ਼ -
plugins { id("com.android.application") version "3.0.0" kotlin("android") version "1.1.51" } android
{ compileSdkVersion(26) buildToolsVersion("26.0.2") defaultConfig { applicationId = "jp.a2kaido.view" minSdkVersion(21) targetSdkVersion(26) versionCode = 1 versionName = "1.0" testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" } buildTypes { getByName("release") { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard- rules.pro") } } } dependencies { CVJMEHSBEMFLUTमਖ਼ /** Sets the targetSdkVersion to the given value. */ @NonNull public ProductFlavor setTargetSdkVersion(@Nullable ApiVersion targetSdkVersion) { mTargetSdkVersion = targetSdkVersion; return this; } -
plugins { id("com.android.application") version "3.0.0" kotlin("android") version "1.1.51" } android
{ compileSdkVersion(26) buildToolsVersion("26.0.2") defaultConfig { applicationId = "jp.a2kaido.view" minSdkVersion(21) targetSdkVersion(26) versionCode = 1 versionName = "1.0" testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner" } buildTypes { getByName("release") { isMinifyEnabled = false proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard- rules.pro") } } } dependencies { CVJMEHSBEMFLUTमਖ਼ -
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard- rules.pro") } } } dependencies { implementation fileTree(dir:
'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" implementation 'com.android.support:appcompat-v7:26.1.0' implementation 'com.android.support.constraint:constraint-layout:1.0.2' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.1' androidTestImplementation 'com.android.support.test.espresso:espresso-core: 3.0.1' } CVJMEHSBEMFLUTमਖ਼ -
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard- rules.pro") } } } dependencies { implementation(fileTree(mapOf("dir" to
"libs", "include" to arrayOf("*.jar")))) implementation("org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.51") implementation("com.android.support:appcompat-v7:26.1.0") "implementation"("com.android.support.constraint:constraint-layout:1.0.2") testImplementation("junit:junit:4.12") androidTestImplementation("com.android.support.test:runner:1.0.1") val test = "androidTestImplementation" test("com.android.support.test.espresso:espresso-core:3.0.1") } repositories { google() jcenter() } CVJMEHSBEMFLUTमਖ਼ -
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard- rules.pro") } } } dependencies { implementation(fileTree(mapOf("dir" to
"libs", "include" to arrayOf("*.jar")))) implementation("org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.51") implementation("com.android.support:appcompat-v7:26.1.0") "implementation"("com.android.support.constraint:constraint-layout:1.0.2") testImplementation("junit:junit:4.12") androidTestImplementation("com.android.support.test:runner:1.0.1") val test = "androidTestImplementation" test("com.android.support.test.espresso:espresso-core:3.0.1") } repositories { google() jcenter() } CVJMEHSBEMFLUTमਖ਼ operator fun String.invoke(dependencyNotation: Any): Dependency = dependencies.add(this, dependencyNotation) -
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard- rules.pro") } } } dependencies { implementation(fileTree(mapOf("dir" to
"libs", "include" to arrayOf("*.jar")))) implementation("org.jetbrains.kotlin:kotlin-stdlib-jre7:1.1.51") implementation("com.android.support:appcompat-v7:26.1.0") "implementation"("com.android.support.constraint:constraint-layout:1.0.2") testImplementation("junit:junit:4.12") androidTestImplementation("com.android.support.test:runner:1.0.1") val test = "androidTestImplementation" test("com.android.support.test.espresso:espresso-core:3.0.1") } repositories { google() jcenter() } CVJMEHSBEMFLUTमਖ਼