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

Use Kotlin for build.gradle.

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
  1. )PX

  2. 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'
  3. 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͔Βඞཁ
  4. 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' } }
  5. 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' } }
  6. 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मਖ਼
  7. 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मਖ਼
  8. 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मਖ਼
  9. 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; }
  10. 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मਖ਼
  11. 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मਖ਼
  12. 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मਖ਼
  13. 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)
  14. 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मਖ਼

More Decks by Amane Nikaido

Other Decks in Programming