From 68e5f7e1d1d7cc8f030600ca15ff0662b3d12b18 Mon Sep 17 00:00:00 2001 From: Antoine POPINEAU Date: Mon, 21 Oct 2019 23:26:06 +0200 Subject: [PATCH] Migrated to Kotlin for Gradle scripts. --- app/build.gradle | 92 --------------------------------- app/build.gradle.kts | 113 +++++++++++++++++++++++++++++++++++++++++ app/proguard-rules.pro | 21 -------- build.gradle | 39 -------------- build.gradle.kts | 24 +++++++++ gradle.properties | 18 +------ settings.gradle | 1 - settings.gradle.kts | 1 + 8 files changed, 139 insertions(+), 170 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts delete mode 100644 settings.gradle create mode 100644 settings.gradle.kts diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 6b52092..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,92 +0,0 @@ -plugins { - id 'com.github.triplet.play' version '2.4.2' -} - -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-android-extensions' - -def props = new Properties() - -props.load(new FileInputStream(rootProject.file('local.properties'))) - -android { - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8 - } - - compileSdkVersion 29 - - defaultConfig { - applicationId "com.github.apognu.otter" - - minSdkVersion 23 - targetSdkVersion 29 - - versionCode androidGitVersion.code() - versionName androidGitVersion.name() - } - - signingConfigs { - release { - storeFile file(props.get('signing.store')) - storePassword props.get('signing.store_passphrase') - keyAlias props.get('signing.alias') - keyPassword props.get('signing.key_passphrase') - } - } - - buildTypes { - release { - signingConfig signingConfigs.release - - minifyEnabled false - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - } - } - - androidGitVersion { - codeFormat = 'MNNPP' - } -} - -play { - serviceAccountCredentials = file(props.get('play.credentials')) - - defaultToAppBundles = true - track = "beta" -} - -dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.2' - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.2' - - implementation 'androidx.appcompat:appcompat:1.1.0' - implementation 'androidx.core:core-ktx:1.2.0-beta01' - implementation 'androidx.coordinatorlayout:coordinatorlayout:1.0.0' - implementation 'androidx.preference:preference:1.1.0' - implementation 'androidx.recyclerview:recyclerview:1.0.0' - implementation 'androidx.swiperefreshlayout:swiperefreshlayout:1.0.0' - implementation 'com.google.android.material:material:1.1.0-beta01' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' - - implementation 'com.google.android.exoplayer:exoplayer:2.10.3' - implementation 'com.google.android.exoplayer:extension-mediasession:2.10.6' - implementation 'com.google.android.exoplayer:extension-cast:2.10.6' - implementation 'com.aliassadi:power-preference-lib:1.4.1' - implementation 'com.github.kittinunf.fuel:fuel:2.1.0' - implementation 'com.github.kittinunf.fuel:fuel-coroutines:2.1.0' - implementation 'com.github.kittinunf.fuel:fuel-android:2.1.0' - implementation 'com.github.kittinunf.fuel:fuel-gson:2.1.0' - implementation 'com.google.code.gson:gson:2.8.5' - implementation 'com.squareup.picasso:picasso:2.71828' - implementation 'jp.wasabeef:picasso-transformations:2.2.1' -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..9e263c2 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,113 @@ +import org.gradle.kotlin.dsl.* +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions +import java.io.FileInputStream +import java.util.* + +plugins { + id("com.android.application") + id("kotlin-android") + id("kotlin-android-extensions") + + id("org.jlleitschuh.gradle.ktlint") version "8.1.0" + id("com.gladed.androidgitversion") version "0.4.10" + id("com.github.triplet.play") version "2.4.2" +} + +val props = Properties().apply { + load(FileInputStream(rootProject.file("local.properties"))) +} + +android { + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + + kotlinOptions { + (this as KotlinJvmOptions).apply { + jvmTarget = JavaVersion.VERSION_1_8.toString() + } + } + + compileSdkVersion(29) + + defaultConfig { + applicationId = "com.github.apognu.otter" + + minSdkVersion(23) + targetSdkVersion(29) + + versionCode = androidGitVersion.code() + versionName = androidGitVersion.name() + } + + signingConfigs { + create("release") { + if (props.contains("signing.store")) { + storeFile = file(props.getProperty("signing.store")) + storePassword = props.getProperty("signing.store_passphrase") + keyAlias = props.getProperty("signing.alias").toString() + keyPassword = props.getProperty("signing.key_passphrase") + } + } + } + + buildTypes { + getByName("release") { + signingConfig = signingConfigs.getByName("release") + + isMinifyEnabled = false + + proguardFile(getDefaultProguardFile("proguard-android-optimize.txt")) + proguardFile("proguard-rules.pro") + } + } +} + +androidGitVersion { + codeFormat = "MNNPP" +} + +ktlint { + debug.set(false) + verbose.set(false) +} + +play { + isEnabled = props.contains("play.credentials") + + if (isEnabled) { + serviceAccountCredentials = file(props.getProperty("play.credentials")) + defaultToAppBundles = true + track = "beta" + } +} + +dependencies { + implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar")))) + + implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.2") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.2") + + implementation("androidx.appcompat:appcompat:1.1.0") + implementation("androidx.core:core-ktx:1.2.0-beta01") + implementation("androidx.coordinatorlayout:coordinatorlayout:1.0.0") + implementation("androidx.preference:preference:1.1.0") + implementation("androidx.recyclerview:recyclerview:1.0.0") + implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0") + implementation("com.google.android.material:material:1.1.0-beta01") + implementation("com.android.support.constraint:constraint-layout:1.1.3") + + implementation("com.google.android.exoplayer:exoplayer:2.10.3") + implementation("com.google.android.exoplayer:extension-mediasession:2.10.6") + implementation("com.google.android.exoplayer:extension-cast:2.10.6") + implementation("com.aliassadi:power-preference-lib:1.4.1") + implementation("com.github.kittinunf.fuel:fuel:2.1.0") + implementation("com.github.kittinunf.fuel:fuel-coroutines:2.1.0") + implementation("com.github.kittinunf.fuel:fuel-android:2.1.0") + implementation("com.github.kittinunf.fuel:fuel-gson:2.1.0") + implementation("com.google.code.gson:gson:2.8.5") + implementation("com.squareup.picasso:picasso:2.71828") + implementation("jp.wasabeef:picasso-transformations:2.2.1") +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index f1b4245..e69de29 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,21 +0,0 @@ -# Add project specific ProGuard rules here. -# You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} - -# Uncomment this to preserve the line number information for -# debugging stack traces. -#-keepattributes SourceFile,LineNumberTable - -# If you keep the line number information, uncomment this to -# hide the original source file name. -#-renamesourcefileattribute SourceFile diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 4e7227e..0000000 --- a/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -buildscript { - ext.kotlin_version = '1.3.50' - - repositories { - google() - jcenter() - - } - - dependencies { - classpath 'com.android.tools.build:gradle:3.5.1' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - } -} - -plugins { - id 'org.jlleitschuh.gradle.ktlint' version '8.1.0' - id 'com.gladed.androidgitversion' version '0.4.10' -} - -allprojects { - repositories { - google() - jcenter() - } -} - -subprojects { - apply plugin: 'org.jlleitschuh.gradle.ktlint' - - ktlint { - debug = false - verbose = false - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..39ad497 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,24 @@ +buildscript { + repositories { + google() + jcenter() + } + + dependencies { + classpath("com.android.tools.build:gradle:3.5.1") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.50") + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +tasks { + val clean by registering(Delete::class) { + delete(buildDir) + } +} diff --git a/gradle.properties b/gradle.properties index 23339e0..4d0bf06 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,21 +1,5 @@ -# Project-wide Gradle settings. -# IDE (e.g. Android Studio) users: -# Gradle settings configured through the IDE *will override* -# any settings specified in this file. -# For more details on how to configure your build environment visit -# http://www.gradle.org/docs/current/userguide/build_environment.html -# Specifies the JVM arguments used for the daemon process. -# The setting is particularly useful for tweaking memory settings. org.gradle.jvmargs=-Xmx1536m -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# AndroidX package structure to make it clearer which packages are bundled with the -# Android operating system, and which are packaged with your app's APK -# https://developer.android.com/topic/libraries/support-library/androidx-rn + android.useAndroidX=true -# Automatically convert third-party libraries to use AndroidX android.enableJetifier=true -# Kotlin code style for this project: "official" or "obsolete": kotlin.code.style=official diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index e7b4def..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..15a801b --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +include(":app")