From 0dbf4b3b64b77ca8b7b7950ce4941ddb56475f90 Mon Sep 17 00:00:00 2001 From: Mygod Date: Wed, 22 Apr 2020 09:53:17 +0800 Subject: [PATCH] Migrate to Kotlin DSL --- .circleci/config.yml | 4 +- build.gradle | 31 ------------ build.gradle.kts | 34 ++++++++++++++ mobile/build.gradle | 101 ---------------------------------------- mobile/build.gradle.kts | 100 +++++++++++++++++++++++++++++++++++++++ settings.gradle | 1 - settings.gradle.kts | 1 + 7 files changed, 137 insertions(+), 135 deletions(-) delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 mobile/build.gradle create mode 100644 mobile/build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/.circleci/config.yml b/.circleci/config.yml index 4487ea69..baa77f27 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -11,7 +11,7 @@ jobs: - run: git submodule sync - run: git submodule update --init --recursive - restore_cache: - key: jars-{{ checksum "build.gradle" }} + key: jars-{{ checksum "build.gradle.kts" }} - run: name: Run Build and Tests command: ./gradlew assembleDebug check @@ -19,7 +19,7 @@ jobs: paths: - ~/.gradle - ~/.android/build-cache - key: jars-{{ checksum "build.gradle" }} + key: jars-{{ checksum "build.gradle.kts" }} - store_artifacts: path: mobile/build/outputs/apk destination: apk diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 446ae84a..00000000 --- a/build.gradle +++ /dev/null @@ -1,31 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -apply plugin: 'com.github.ben-manes.versions' - -buildscript { - ext.kotlinVersion = '1.3.72' - repositories { - google() - jcenter() - } - dependencies { - classpath 'com.android.tools.build:gradle:4.0.0-beta04' - classpath 'com.github.ben-manes:gradle-versions-plugin:0.28.0' - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta04' - classpath 'com.google.android.gms:oss-licenses-plugin:0.10.2' - classpath 'com.google.gms:google-services:4.3.3' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" - } -} - -allprojects { - repositories { - google() - jcenter() - maven { url 'https://jitpack.io' } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..0079aee3 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,34 @@ +plugins { + id("com.github.ben-manes.versions") version "0.28.0" +} + +buildscript { + val kotlinVersion = "1.3.72" + extra.set("kotlinVersion", kotlinVersion) + + repositories { + google() + jcenter() + } + + dependencies { + classpath("com.android.tools.build:gradle:4.0.0-beta04") + classpath("com.github.ben-manes:gradle-versions-plugin:0.28.0") + classpath("com.google.firebase:firebase-crashlytics-gradle:2.0.0-beta04") + classpath("com.google.android.gms:oss-licenses-plugin:0.10.2") + classpath("com.google.gms:google-services:4.3.3") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") + } +} + +allprojects { + repositories { + google() + jcenter() + maven("https://jitpack.io") + } +} + +tasks.register("clean", Delete::class) { + delete(rootProject.buildDir) +} diff --git a/mobile/build.gradle b/mobile/build.gradle deleted file mode 100644 index ce034262..00000000 --- a/mobile/build.gradle +++ /dev/null @@ -1,101 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'com.google.android.gms.oss-licenses-plugin' -apply plugin: 'com.google.firebase.crashlytics' -apply plugin: 'com.google.gms.google-services' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'kotlin-kapt' - -def javaVersion = JavaVersion.VERSION_1_8 - -android { - compileSdkVersion 29 - compileOptions { - coreLibraryDesugaringEnabled true - sourceCompatibility javaVersion - targetCompatibility javaVersion - } - kotlinOptions.jvmTarget = javaVersion - defaultConfig { - applicationId "be.mygod.vpnhotspot" - minSdkVersion 21 - targetSdkVersion 29 - resConfigs 'it', 'ru', 'zh-rCN', 'zh-rTW' - versionCode 222 - versionName '2.8.1' - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - javaCompileOptions.annotationProcessorOptions.arguments = [ - "room.incremental": "true", - "room.schemaLocation": "$projectDir/schemas".toString(), - ] - buildConfigField "boolean", "DONATIONS", "true" - } - buildFeatures { - dataBinding = true - viewBinding = true - } - buildTypes { - debug { - pseudoLocalesEnabled true - } - release { - shrinkResources true - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - } - } - flavorDimensions("freedom") - packagingOptions.exclude '**/*.kotlin_*' - productFlavors { - freedom { - dimension "freedom" - } - google { - dimension "freedom" - buildConfigField "boolean", "DONATIONS", "false" - } - } - sourceSets { - androidTest.assets.srcDirs += files("$projectDir/schemas".toString()) - } -} - -androidExtensions { - experimental = true -} - -def lifecycleVersion = '2.2.0' -def roomVersion = '2.2.5' -dependencies { - coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.0.5' - kapt "androidx.room:room-compiler:$roomVersion" - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.browser:browser:1.2.0' - implementation 'androidx.core:core-ktx:1.3.0-rc01' - implementation 'androidx.emoji:emoji:1.1.0-beta01' - implementation 'androidx.fragment:fragment-ktx:1.2.4' - implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion" - implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion" - implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion" - implementation 'androidx.preference:preference:1.1.1' - implementation "androidx.room:room-ktx:$roomVersion" - implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-rc01' - implementation 'com.android.billingclient:billing-ktx:2.2.0' - implementation 'com.github.topjohnwu.libsu:core:2.5.1' - implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' - implementation 'com.google.android.material:material:1.1.0' - implementation 'com.google.firebase:firebase-analytics-ktx:17.3.0' - implementation 'com.google.firebase:firebase-crashlytics:17.0.0-beta04' - implementation 'com.google.zxing:core:3.4.0' - implementation 'com.jakewharton.timber:timber:4.7.1' - implementation 'com.linkedin.dexmaker:dexmaker:2.25.1' - implementation 'com.takisoft.preferencex:preferencex-simplemenu:1.1.0' - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion" - implementation 'org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.2' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5' - testImplementation 'junit:junit:4.13' - androidTestImplementation "androidx.room:room-testing:$roomVersion" - androidTestImplementation 'androidx.test:runner:1.2.0' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' - androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.1' -} diff --git a/mobile/build.gradle.kts b/mobile/build.gradle.kts new file mode 100644 index 00000000..3a77d69d --- /dev/null +++ b/mobile/build.gradle.kts @@ -0,0 +1,100 @@ +plugins { + id("com.android.application") + id("com.google.android.gms.oss-licenses-plugin") + id("com.google.gms.google-services") + id("com.google.firebase.crashlytics") + kotlin("android") + kotlin("android.extensions") + kotlin("kapt") +} + +android { + val javaVersion = JavaVersion.VERSION_1_8 + compileOptions { + coreLibraryDesugaringEnabled = true + sourceCompatibility = javaVersion + targetCompatibility = javaVersion + } + compileSdkVersion(29) + kotlinOptions.jvmTarget = javaVersion.toString() + defaultConfig { + applicationId = "be.mygod.vpnhotspot" + minSdkVersion(21) + targetSdkVersion(29) + resConfigs(listOf("it", "ru", "zh-rCN", "zh-rTW")) + versionCode = 222 + versionName = "2.8.1" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + javaCompileOptions.annotationProcessorOptions.arguments = mapOf( + "room.incremental" to "true", + "room.schemaLocation" to "$projectDir/schemas" + ) + buildConfigField("boolean", "DONATIONS", "true") + } + buildFeatures { + dataBinding = true + viewBinding = true + } + buildTypes { + getByName("debug") { + isPseudoLocalesEnabled = true + } + getByName("release") { + isShrinkResources = true + isMinifyEnabled = true + proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro") + } + } + packagingOptions.exclude("**/*.kotlin_*") + flavorDimensions("freedom") + productFlavors { + create("freedom") { + setDimension("freedom") + } + create("google") { + setDimension("freedom") + buildConfigField("boolean", "DONATIONS", "false") + } + } + sourceSets.getByName("androidTest") { + assets.setSrcDirs(assets.srcDirs + files("$projectDir/schemas")) + } +} + +androidExtensions.isExperimental = true + +dependencies { + val lifecycleVersion = "2.2.0" + val roomVersion = "2.2.5" + + coreLibraryDesugaring("com.android.tools:desugar_jdk_libs:1.0.5") + kapt("androidx.room:room-compiler:$roomVersion") + implementation("androidx.browser:browser:1.2.0") + implementation("androidx.core:core-ktx:1.3.0-rc01") + implementation("androidx.emoji:emoji:1.1.0-beta01") + implementation("androidx.fragment:fragment-ktx:1.2.4") + implementation("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion") + implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion") + implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion") + implementation("androidx.preference:preference:1.1.1") + implementation("androidx.room:room-ktx:$roomVersion") + implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.1.0-rc01") + implementation("com.android.billingclient:billing-ktx:2.2.0") + implementation("com.github.topjohnwu.libsu:core:2.5.1") + implementation("com.google.android.gms:play-services-oss-licenses:17.0.0") + implementation("com.google.android.material:material:1.1.0") + implementation("com.google.firebase:firebase-analytics-ktx:17.3.0") + implementation("com.google.firebase:firebase-crashlytics:17.0.0-beta04") + implementation("com.google.zxing:core:3.4.0") + implementation("com.jakewharton.timber:timber:4.7.1") + implementation("com.linkedin.dexmaker:dexmaker:2.25.1") + implementation("com.takisoft.preferencex:preferencex-simplemenu:1.1.0") + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:${rootProject.extra.get("kotlinVersion")}") + implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.3.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.5") + testImplementation("junit:junit:4.13") + androidTestImplementation("androidx.room:room-testing:$roomVersion") + androidTestImplementation("androidx.test:runner:1.2.0") + androidTestImplementation("androidx.test.espresso:espresso-core:3.2.0") + androidTestImplementation("androidx.test.ext:junit-ktx:1.1.1") +} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 6070d9b3..00000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':mobile' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..ed243483 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +include(":mobile")