From 13bfe236a3ef0e4047409ca27635af3391bc70de Mon Sep 17 00:00:00 2001 From: William Brawner Date: Sun, 29 Jan 2023 20:41:15 -0700 Subject: [PATCH] Convert .gradle files to gradle.kts --- app/build.gradle | 145 ------------------------------------- app/build.gradle.kts | 158 +++++++++++++++++++++++++++++++++++++++++ app/proguard-rules.pro | 2 +- build.gradle | 36 ---------- build.gradle.kts | 29 ++++++++ settings.gradle | 1 - settings.gradle.kts | 1 + 7 files changed, 189 insertions(+), 183 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 a8f9413..0000000 --- a/app/build.gradle +++ /dev/null @@ -1,145 +0,0 @@ -apply plugin: 'com.android.application' -apply plugin: 'kotlin-android-extensions' -apply plugin: 'kotlin-android' -apply plugin: 'kotlin-kapt' -apply plugin: "com.osacky.fladle" - -def keystoreProperties = new Properties() -try { - def keystorePropertiesFile = rootProject.file("keystore.properties") - keystoreProperties.load(new FileInputStream(keystorePropertiesFile)) -} catch (FileNotFoundException ignored) { - logger.warn("Unable to load keystore properties. Automatic signing won't be available") - keystoreProperties['keyAlias'] = "" - keystoreProperties['keyPassword'] = "" - keystoreProperties['storeFile'] = File.createTempFile("temp", ".tmp").absolutePath - keystoreProperties['storePassword'] = "" -} - -android { - packagingOptions { - resources { - excludes += ['META-INF/LICENSE-LGPL-2.1.txt', 'META-INF/LICENSE-LGPL-3.txt', 'META-INF/LICENSE-W3C-TEST', 'META-INF/LICENSE', 'META-INF/DEPENDENCIES'] - } - } - configurations.all { - resolutionStrategy.force 'com.google.code.findbugs:jsr305:3.0.1' - } - compileSdkVersion 33 - compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 - } - kotlinOptions { - jvmTarget = "1.8" - } - defaultConfig { - applicationId "com.wbrawner.simplemarkdown" - minSdkVersion 23 - targetSdkVersion 33 - versionCode 35 - versionName "0.8.13" - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - testInstrumentationRunnerArguments clearPackageData: 'true' - buildConfigField "boolean", "ENABLE_CUSTOM_CSS", "true" - } - signingConfigs { - playRelease { - keyAlias keystoreProperties['keyAlias'] - keyPassword keystoreProperties['keyPassword'] - storeFile file(keystoreProperties['storeFile']) - storePassword keystoreProperties['storePassword'] - } - } - buildTypes { - debug { - testCoverageEnabled true - } - release { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' - buildConfigField "boolean", "ENABLE_CUSTOM_CSS", "false" - } - } - flavorDimensions "platform" - productFlavors { - free { - applicationIdSuffix ".free" - versionNameSuffix "-free" - } - play { - signingConfig signingConfigs.playRelease - } - } - testOptions { - unitTests { - includeAndroidResources = true - } - execution 'ANDROIDX_TEST_ORCHESTRATOR' - } - namespace 'com.wbrawner.simplemarkdown' -} - -dependencies { - def navigation_version = '2.5.3' - implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version" - implementation "androidx.navigation:navigation-ui-ktx:$navigation_version" - testImplementation 'junit:junit:4.13.2' - testImplementation 'org.robolectric:robolectric:4.2.1' - implementation fileTree(include: ['*.jar'], dir: 'libs') - def espresso_version = '3.5.1' - androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version" - androidTestImplementation "androidx.test.espresso:espresso-web:$espresso_version" - androidTestImplementation "androidx.test.espresso:espresso-intents:$espresso_version" - androidTestImplementation "androidx.test:runner:1.5.2" - androidTestImplementation "androidx.test:rules:1.5.0" - androidTestUtil "androidx.test:orchestrator:1.4.2" - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0' - implementation 'com.wbrawner.plausible:plausible-android:0.1.0-SNAPSHOT' - implementation 'androidx.appcompat:appcompat:1.6.0' - implementation 'androidx.preference:preference-ktx:1.2.0' - implementation "androidx.fragment:fragment-ktx:1.5.5" - implementation 'androidx.constraintlayout:constraintlayout:2.1.4' - implementation 'com.google.android.material:material:1.8.0' - implementation 'androidx.legacy:legacy-support-v13:1.0.0' - implementation 'com.commonsware.cwac:anddown:0.3.0' - implementation 'com.jakewharton.timber:timber:5.0.1' - playImplementation 'com.android.billingclient:billing:5.1.0' - playImplementation 'com.google.android.play:core-ktx:1.8.1' - playImplementation 'com.google.firebase:firebase-crashlytics:18.3.3' - implementation "androidx.core:core-ktx:1.9.0" - implementation 'androidx.browser:browser:1.4.0' - def coroutines_version = "1.6.4" - implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutines_version" - def lifecycle_version = "2.2.0" - implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version" - kapt "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version" - implementation 'eu.crydee:syllable-counter:4.0.2' -} - -android.productFlavors.each { flavor -> - if (getGradle().getStartParameter().getTaskRequests().toString().toLowerCase().contains(flavor.name) - && flavor.name == 'play') { - apply plugin: 'com.google.gms.google-services' - apply plugin: 'com.google.firebase.crashlytics' - } -} - -fladle { - variant = 'playDebug' - useOrchestrator = true - environmentVariables = [ - "clearPackageData": "true" - ] - testTimeout = "7m" - devices = [ - [ "model": "NexusLowRes", "version": "29" ] - ] - projectId = 'simplemarkdown' -} - -task pullLogFiles(type: Exec) { - commandLine 'adb', 'pull', - '/storage/emulated/0/Android/data/com.wbrawner.simplemarkdown/files/logs' -} \ No newline at end of file diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 0000000..d8490ba --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,158 @@ +import java.io.FileInputStream +import java.io.FileNotFoundException +import java.util.* + +plugins { + id("com.android.application") + id("kotlin-android-extensions") + id("kotlin-android") + id("kotlin-kapt") + id("com.osacky.fladle") +} + +val keystoreProperties = Properties() +try { + val keystorePropertiesFile = rootProject.file("keystore.properties") + keystoreProperties.load(FileInputStream(keystorePropertiesFile)) +} catch (ignored: FileNotFoundException) { + logger.warn("Unable to load keystore properties. Automatic signing won't be available") + keystoreProperties["keyAlias"] = "" + keystoreProperties["keyPassword"] = "" + keystoreProperties["storeFile"] = File.createTempFile("temp", ".tmp").absolutePath + keystoreProperties["storePassword"] = "" +} + +android { + packagingOptions { + resources { + excludes += listOf( + "META-INF/LICENSE-LGPL-2.1.txt", + "META-INF/LICENSE-LGPL-3.txt", + "META-INF/LICENSE-W3C-TEST", + "META-INF/LICENSE", + "META-INF/DEPENDENCIES" + ) + } + } + compileSdk = 33 + compileOptions { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + kotlinOptions { + jvmTarget = "1.8" + } + defaultConfig { + applicationId = "com.wbrawner.simplemarkdown" + minSdk = 23 + targetSdk = 33 + versionCode = 35 + versionName = "0.8.13" + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + testInstrumentationRunnerArguments["clearPackageData"] = "true" + buildConfigField("boolean", "ENABLE_CUSTOM_CSS", "true") + } + signingConfigs { + create("playRelease") { + keyAlias = keystoreProperties["keyAlias"].toString() + keyPassword = keystoreProperties["keyPassword"].toString() + storeFile = file(keystoreProperties["storeFile"].toString()) + storePassword = keystoreProperties["storePassword"].toString() + } + } + buildTypes { + release { + isMinifyEnabled = true + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + buildConfigField("boolean", "ENABLE_CUSTOM_CSS", "false") + } + } + flavorDimensions.add("platform") + productFlavors { + create("free") { + applicationIdSuffix = ".free" + versionNameSuffix = "-free" + } + create("play") { + signingConfig = signingConfigs["playRelease"] + } + } + testOptions { + unitTests { + isIncludeAndroidResources = true + } + execution = "ANDROIDX_TEST_ORCHESTRATOR" + } + namespace = "com.wbrawner.simplemarkdown" +} + +dependencies { + val navigationVersion = "2.5.3" + implementation("androidx.navigation:navigation-fragment-ktx:$navigationVersion") + implementation("androidx.navigation:navigation-ui-ktx:$navigationVersion") + testImplementation("junit:junit:4.13.2") + testImplementation("org.robolectric:robolectric:4.2.1") + val espressoVersion = "3.5.1" + androidTestImplementation("androidx.test.espresso:espresso-core:$espressoVersion") + androidTestImplementation("androidx.test.espresso:espresso-web:$espressoVersion") + androidTestImplementation("androidx.test.espresso:espresso-intents:$espressoVersion") + androidTestImplementation("androidx.test:runner:1.5.2") + androidTestImplementation("androidx.test:rules:1.5.0") + androidTestUtil("androidx.test:orchestrator:1.4.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.uiautomator:uiautomator:2.2.0") + implementation("com.wbrawner.plausible:plausible-android:0.1.0-SNAPSHOT") + implementation("androidx.appcompat:appcompat:1.6.0") + implementation("androidx.preference:preference-ktx:1.2.0") + implementation("androidx.fragment:fragment-ktx:1.5.5") + implementation("androidx.constraintlayout:constraintlayout:2.1.4") + implementation("com.google.android.material:material:1.8.0") + implementation("androidx.legacy:legacy-support-v13:1.0.0") + implementation("com.commonsware.cwac:anddown:0.4.0") + implementation("com.jakewharton.timber:timber:5.0.1") + implementation("androidx.core:core-ktx:1.9.0") + implementation("androidx.browser:browser:1.4.0") + val coroutinesVersion = "1.6.4" + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion") + val lifecycleVersion = "2.2.0" + implementation("androidx.lifecycle:lifecycle-extensions:$lifecycleVersion") + kapt("androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion") + implementation("eu.crydee:syllable-counter:4.0.2") +} + +android.productFlavors.forEach { flavor -> + if (getGradle().getStartParameter().getTaskRequests().toString().toLowerCase() + .contains(flavor.name) + && flavor.name == "play" + ) { + apply(plugin = "com.google.gms.google-services") + apply(plugin = "com.google.firebase.crashlytics") + + dependencies { + implementation("com.android.billingclient:billing:5.1.0") + implementation("com.google.android.play:core-ktx:1.8.1") + implementation("com.google.firebase:firebase-crashlytics:18.3.3") + } + } +} + +fladle { + variant.set("playDebug") + useOrchestrator.set(true) + environmentVariables.put("clearPackageData", "true") + testTimeout.set("7m") + devices.add( + mapOf("model" to "NexusLowRes", "version" to "29") + ) + projectId.set("simplemarkdown") +} + +tasks.register("pullLogFiles") { + commandLine = listOf( + "adb", "pull", + "/storage/emulated/0/Android/data/com.wbrawner.simplemarkdown/files/logs" + ) +} \ No newline at end of file diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 6355009..e8da40c 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -2,7 +2,7 @@ # By default, the flags in this file are appended to flags specified # in /home/billy/Android/Sdk/tools/proguard/proguard-android.txt # You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. +# directive in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/build.gradle b/build.gradle deleted file mode 100644 index ccb6193..0000000 --- a/build.gradle +++ /dev/null @@ -1,36 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - ext.kotlin_version = '1.7.20' - repositories { - google() - mavenCentral() - maven {url 'https://plugins.gradle.org/m2/' } - } - dependencies { - classpath 'com.android.tools.build:gradle:7.4.0' - classpath 'com.google.gms:google-services:4.3.15' - classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - classpath "com.osacky.flank.gradle:fladle:0.17.4" - } -} - -allprojects { - repositories { - google() - mavenCentral() - maven { - url "https://s3.amazonaws.com/repo.commonsware.com" - } - maven { url 'https://maven.google.com' } - maven {url 'https://plugins.gradle.org/m2/' } - maven { - url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' - } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..21990ae --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,29 @@ +import java.net.URI + +buildscript { + repositories { + gradlePluginPortal() + google() + mavenCentral() + } + dependencies { + classpath("com.android.tools.build:gradle:7.4.0") + classpath("com.google.gms:google-services:4.3.15") + classpath("com.google.firebase:firebase-crashlytics-gradle:2.9.2") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20") + classpath("com.osacky.flank.gradle:fladle:0.17.4") + } +} + +allprojects { + repositories { + google() + mavenCentral() + maven { + url = URI("https://s3.amazonaws.com/repo.commonsware.com/") + } + maven { + url = URI("https://s01.oss.sonatype.org/content/repositories/snapshots/") + } + } +} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index 9d495b3..0000000 --- a/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -include ':app' \ No newline at end of file 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")