From eeaa1e0edfa0db787f4e8398883c1d073304bf7e Mon Sep 17 00:00:00 2001 From: "maarten.vercruysse" Date: Fri, 23 Jun 2023 22:51:32 +0200 Subject: [PATCH 1/3] Convert gradle to gradle.kts --- app/build.gradle | 149 ----------------------- app/build.gradle.kts | 156 +++++++++++++++++++++++++ app/proguard-rules.pro | 2 +- benchmarks/build.gradle | 67 ----------- benchmarks/build.gradle.kts | 66 +++++++++++ build.gradle | 50 -------- build.gradle.kts | 50 ++++++++ settings.gradle => settings.gradle.kts | 7 +- 8 files changed, 277 insertions(+), 270 deletions(-) delete mode 100644 app/build.gradle create mode 100644 app/build.gradle.kts delete mode 100644 benchmarks/build.gradle create mode 100644 benchmarks/build.gradle.kts delete mode 100644 build.gradle create mode 100644 build.gradle.kts rename settings.gradle => settings.gradle.kts (77%) diff --git a/app/build.gradle b/app/build.gradle deleted file mode 100644 index 0723294b4..000000000 --- a/app/build.gradle +++ /dev/null @@ -1,149 +0,0 @@ -plugins { - id 'com.android.application' - id 'org.jetbrains.kotlin.android' - id 'com.google.devtools.ksp' - id 'androidx.baselineprofile' -} - -android { - compileSdk 33 - - defaultConfig { - applicationId "com.jerboa" - namespace "com.jerboa" - minSdk 26 - targetSdk 33 - versionCode 34 - versionName "0.0.34" - - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary true - } - ksp { arg('room.schemaLocation', "$projectDir/schemas") } - } - - if(project.hasProperty("RELEASE_STORE_FILE")) { - signingConfigs { - release { - storeFile file(RELEASE_STORE_FILE) - storePassword RELEASE_STORE_PASSWORD - keyAlias RELEASE_KEY_ALIAS - keyPassword RELEASE_KEY_PASSWORD - - // Optional, specify signing versions used - v1SigningEnabled true - v2SigningEnabled true - } - } - } - - buildTypes { - release { - minifyEnabled true - shrinkResources true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - if(project.hasProperty("RELEASE_STORE_FILE")) { - signingConfig signingConfigs.release - } - } - debug { - applicationIdSuffix '.debug' - versionNameSuffix ' (DEBUG)' - } - - generateProfiles { // use this variant to generate the profiles - minifyEnabled false // The startup profiles needs minification off - shrinkResources false - debuggable false - signingConfig signingConfigs.debug - proguardFiles 'benchmark-rules.pro' // The baseline profile generator needs obfuscation off - applicationIdSuffix = ".benchmark" - } - } - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = '17' - freeCompilerArgs = ['-Xjvm-default=all-compatibility', '-opt-in=kotlin.RequiresOptIn'] - } - buildFeatures { - compose true - } - composeOptions { - kotlinCompilerExtensionVersion '1.4.7' - } -} - -dependencies { - implementation 'com.github.alorma:compose-settings-ui-m3:0.27.0' - - implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.11' - - // Markdown support - implementation 'io.noties.markwon:core:4.6.2' - implementation 'io.noties.markwon:ext-strikethrough:4.6.2' - implementation 'io.noties.markwon:ext-tables:4.6.2' - implementation 'io.noties.markwon:html:4.6.2' - implementation 'io.noties.markwon:image-coil:4.6.2' - implementation 'io.noties.markwon:linkify:4.6.2' - - // Accompanist - implementation 'com.google.accompanist:accompanist-pager:0.30.1' - implementation 'com.google.accompanist:accompanist-pager-indicators:0.30.1' - implementation 'com.google.accompanist:accompanist-flowlayout:0.30.1' - implementation "com.google.accompanist:accompanist-permissions:0.30.1" - - // LiveData - implementation 'androidx.compose.runtime:runtime-livedata:1.4.3' - implementation "androidx.lifecycle:lifecycle-runtime-compose:2.6.1" - - // gif support - implementation "io.coil-kt:coil-gif:2.4.0" - - // To use Kotlin annotation processing tool - ksp "androidx.room:room-compiler:2.5.1" - - implementation "androidx.room:room-runtime:2.5.1" - annotationProcessor "androidx.room:room-compiler:2.5.1" - - // optional - Kotlin Extensions and Coroutines support for Room - implementation "androidx.room:room-ktx:2.5.1" - - // optional - Test helpers - testImplementation "androidx.room:room-testing:2.5.1" - testImplementation "pl.pragmatists:JUnitParams:1.1.1" - - // optional - Paging 3 Integration - implementation "androidx.room:room-paging:2.5.1" - - implementation 'io.arrow-kt:arrow-core:1.1.5' - // Unfortunately, ui tooling, and the markdown thing, still brings in the other material2 dependencies - implementation 'androidx.compose.material3:material3:1.1.0' - implementation 'androidx.compose.material3:material3-window-size-class:1.1.0' - implementation 'androidx.compose.material:material-icons-extended:1.4.3' - implementation 'org.ocpsoft.prettytime:prettytime:5.0.6.Final' - implementation 'io.coil-kt:coil-compose:2.4.0' - implementation "androidx.navigation:navigation-compose:2.5.3" - testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1' - testImplementation "androidx.arch.core:core-testing:2.2.0" - implementation "com.squareup.retrofit2:retrofit:2.9.0" - implementation "com.squareup.retrofit2:converter-gson:2.9.0" -// implementation 'androidx.core:core-ktx:1.9.0' - implementation 'androidx.compose.ui:ui:1.4.3' - implementation 'androidx.compose.ui:ui-tooling-preview:1.4.3' - implementation 'androidx.activity:activity-compose:1.7.2' - testImplementation 'junit:junit:4.13.2' - androidTestImplementation 'androidx.test.ext:junit:1.1.5' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' - androidTestImplementation 'androidx.compose.ui:ui-test-junit4:1.4.3' - debugImplementation 'androidx.compose.ui:ui-tooling:1.4.3' - debugImplementation 'androidx.compose.ui:ui-test-manifest:1.4.3' - implementation "net.engawapg.lib:zoomable:1.4.3" - implementation 'androidx.browser:browser:1.5.0' - - implementation 'androidx.profileinstaller:profileinstaller:1.3.1' - baselineProfile project(path: ':benchmarks') -} diff --git a/app/build.gradle.kts b/app/build.gradle.kts new file mode 100644 index 000000000..0ceef8912 --- /dev/null +++ b/app/build.gradle.kts @@ -0,0 +1,156 @@ +@file:Suppress("UnstableApiUsage") + +plugins { + id("com.android.application") + id("org.jetbrains.kotlin.android") + id("com.google.devtools.ksp") + id("androidx.baselineprofile") +} + +android { + compileSdk = 33 + + defaultConfig { + applicationId = "com.jerboa" + namespace = "com.jerboa" + minSdk = 26 + targetSdk = 33 + versionCode = 34 + versionName = "0.0.34" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + vectorDrawables { + useSupportLibrary = true + } + ksp { arg("room.schemaLocation", "$projectDir/schemas") } + } + + if(project.hasProperty("RELEASE_STORE_FILE")) { + signingConfigs { + register("release") { + storeFile = file(project.property("RELEASE_STORE_FILE")!!) + storePassword = project.property("RELEASE_STORE_PASSWORD") as String? + keyAlias = project.property("RELEASE_KEY_ALIAS") as String? + keyPassword = project.property("RELEASE_KEY_PASSWORD") as String? + + // Optional, specify signing versions used + enableV1Signing = true + enableV2Signing = true + } + } + } + + buildTypes { + release { + if(project.hasProperty("RELEASE_STORE_FILE")) { + signingConfig = signingConfigs.getByName("release") + } + + postprocessing { + isRemoveUnusedCode = true + isObfuscate = false + isOptimizeCode = true + isRemoveUnusedResources = true + proguardFiles("proguard-rules.pro") + } + } + debug { + applicationIdSuffix = ".debug" + versionNameSuffix = " (DEBUG)" + } + + register("generateProfiles") { // use this variant to generate the profiles + isMinifyEnabled = false // The startup profiles needs minification off + isShrinkResources = false + isDebuggable = false + signingConfig = signingConfigs.getByName("debug") + proguardFiles("benchmark-rules.pro") // The baseline profile generator needs obfuscation off + applicationIdSuffix = ".benchmark" + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + freeCompilerArgs = listOf("-Xjvm-default=all-compatibility", "-opt-in=kotlin.RequiresOptIn") + } + buildFeatures { + compose = true + } + composeOptions { + kotlinCompilerExtensionVersion = "1.4.7" + } +} + +dependencies { + implementation("com.github.alorma:compose-settings-ui-m3:0.27.0") + + implementation("com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.11") + + // Markdown support + implementation("io.noties.markwon:core:4.6.2") + implementation("io.noties.markwon:ext-strikethrough:4.6.2") + implementation("io.noties.markwon:ext-tables:4.6.2") + implementation("io.noties.markwon:html:4.6.2") + implementation("io.noties.markwon:image-coil:4.6.2") + implementation("io.noties.markwon:linkify:4.6.2") + + // Accompanist + implementation("com.google.accompanist:accompanist-pager:0.30.1") + implementation("com.google.accompanist:accompanist-pager-indicators:0.30.1") + implementation("com.google.accompanist:accompanist-flowlayout:0.30.1") + implementation("com.google.accompanist:accompanist-permissions:0.30.1") + + // LiveData + implementation("androidx.compose.runtime:runtime-livedata:1.4.3") + implementation("androidx.lifecycle:lifecycle-runtime-compose:2.6.1") + + // gif support + implementation("io.coil-kt:coil-gif:2.4.0") + + // To use Kotlin annotation processing tool + ksp("androidx.room:room-compiler:2.5.1") + + implementation("androidx.room:room-runtime:2.5.1") + annotationProcessor("androidx.room:room-compiler:2.5.1") + + // optional - Kotlin Extensions and Coroutines support for Room + implementation("androidx.room:room-ktx:2.5.1") + + // optional - Test helpers + testImplementation("androidx.room:room-testing:2.5.1") + testImplementation("pl.pragmatists:JUnitParams:1.1.1") + + // optional - Paging 3 Integration + implementation("androidx.room:room-paging:2.5.1") + + implementation("io.arrow-kt:arrow-core:1.1.5") + // Unfortunately, ui tooling, and the markdown thing, still brings in the other material2 dependencies + implementation("androidx.compose.material3:material3:1.1.0") + implementation("androidx.compose.material3:material3-window-size-class:1.1.0") + implementation("androidx.compose.material:material-icons-extended:1.4.3") + implementation("org.ocpsoft.prettytime:prettytime:5.0.6.Final") + implementation("io.coil-kt:coil-compose:2.4.0") + implementation("androidx.navigation:navigation-compose:2.5.3") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.1") + testImplementation("androidx.arch.core:core-testing:2.2.0") + implementation("com.squareup.retrofit2:retrofit:2.9.0") + implementation("com.squareup.retrofit2:converter-gson:2.9.0") + + implementation("androidx.compose.ui:ui:1.4.3") + implementation("androidx.compose.ui:ui-tooling-preview:1.4.3") + implementation("androidx.activity:activity-compose:1.7.2") + testImplementation("junit:junit:4.13.2") + androidTestImplementation("androidx.test.ext:junit:1.1.5") + androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") + androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.4.3") + debugImplementation("androidx.compose.ui:ui-tooling:1.4.3") + debugImplementation("androidx.compose.ui:ui-test-manifest:1.4.3") + implementation("net.engawapg.lib:zoomable:1.4.3") + implementation("androidx.browser:browser:1.5.0") + + implementation("androidx.profileinstaller:profileinstaller:1.3.1") + baselineProfile(project(":benchmarks")) +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index 133647df8..6840dc14a 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -1,6 +1,6 @@ # Add project specific ProGuard rules here. # You can control the set of applied configuration files using the -# proguardFiles setting in build.gradle. +# proguardFiles setting in build.gradle.kts. # # For more details, see # http://developer.android.com/guide/developing/tools/proguard.html diff --git a/benchmarks/build.gradle b/benchmarks/build.gradle deleted file mode 100644 index b288d09dd..000000000 --- a/benchmarks/build.gradle +++ /dev/null @@ -1,67 +0,0 @@ -import com.android.build.api.dsl.ManagedVirtualDevice - -plugins { - id 'com.android.test' - id 'org.jetbrains.kotlin.android' - id 'androidx.baselineprofile' -} - -android { - namespace 'com.jerboa.benchmarks' - compileSdk 33 - - compileOptions { - sourceCompatibility JavaVersion.VERSION_17 - targetCompatibility JavaVersion.VERSION_17 - } - kotlinOptions { - jvmTarget = '17' - freeCompilerArgs = ['-Xjvm-default=all-compatibility', '-opt-in=kotlin.RequiresOptIn'] - } - - defaultConfig { - minSdk 26 - targetSdk 33 - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - // Only use the emulator to test benchmarks - testInstrumentationRunnerArgument 'androidx.benchmark.suppressErrors', "EMULATOR" - consumerProguardFiles("consumer-rules.pro") - } - - targetProjectPath = ":app" - // Enable the benchmark to run separately from the app process - experimentalProperties["android.experimental.self-instrumenting"] = true - - // Baselines profiles needs to generated on a rooted phone - // Use this plugin to setup and tear down a rooted phone - testOptions.managedDevices.devices { - pixel6Api31(ManagedVirtualDevice) { - device = "Pixel 6" - apiLevel = 31 - systemImageSource = "aosp" - } - } - - buildTypes { - benchmark { - debuggable false - signingConfig signingConfigs.debug - matchingFallbacks = ["release"] - } - } -} - -// This is the configuration block for the Baseline Profile plugin. -// You can specify to run the generators on a managed devices or connected devices. -baselineProfile { - managedDevices += "pixel6Api31" - useConnectedDevices = false -} - -dependencies { - implementation 'androidx.test.ext:junit:1.1.5' - implementation 'androidx.test.espresso:espresso-core:3.5.1' - implementation 'androidx.test.uiautomator:uiautomator:2.2.0' - implementation 'androidx.benchmark:benchmark-macro-junit4:1.2.0-alpha15' -} \ No newline at end of file diff --git a/benchmarks/build.gradle.kts b/benchmarks/build.gradle.kts new file mode 100644 index 000000000..386ae59b5 --- /dev/null +++ b/benchmarks/build.gradle.kts @@ -0,0 +1,66 @@ +import com.android.build.api.dsl.ManagedVirtualDevice + +plugins { + id("com.android.test") + id("org.jetbrains.kotlin.android") + id("androidx.baselineprofile") +} + +android { + namespace = "com.jerboa.benchmarks" + compileSdk = 33 + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + freeCompilerArgs = listOf("-Xjvm-default=all-compatibility", "-opt-in=kotlin.RequiresOptIn") + } + + defaultConfig { + minSdk = 26 + targetSdk = 33 + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + // Only use the emulator to test benchmarks + testInstrumentationRunnerArguments += mapOf("androidx.benchmark.suppressErrors" to "EMULATOR") + } + + targetProjectPath = ":app" + // Enable the benchmark to run separately from the app process + experimentalProperties["android.experimental.self-instrumenting"] = true + + // Baselines profiles needs to generated on a rooted phone + // Use this plugin to setup and tear down a rooted phone + testOptions.managedDevices.devices { + maybeCreate("pixel6Api31").apply { + device = "Pixel 6" + apiLevel = 31 + systemImageSource = "aosp" + } + } + + buildTypes { + register("benchmark") { + isDebuggable = false + signingConfig = signingConfigs.getByName("debug") + matchingFallbacks += listOf("release") + } + } +} + +// This is the configuration block for the Baseline Profile plugin. +// You can specify to run the generators on a managed devices or connected devices. +baselineProfile { + managedDevices += "pixel6Api31" + useConnectedDevices = false +} + +dependencies { + implementation("androidx.test.ext:junit:1.1.5") + implementation("androidx.test.espresso:espresso-core:3.5.1") + implementation("androidx.test.uiautomator:uiautomator:2.2.0") + implementation("androidx.benchmark:benchmark-macro-junit4:1.2.0-alpha15") +} diff --git a/build.gradle b/build.gradle deleted file mode 100644 index f776a0be6..000000000 --- a/build.gradle +++ /dev/null @@ -1,50 +0,0 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -buildscript { - repositories { - google() - mavenCentral() - } -}// Top-level build file where you can add configuration options common to all sub-projects/modules. - -plugins { - id 'com.android.application' version '8.0.2' apply false - id 'com.android.library' version '8.0.2' apply false - id 'org.jetbrains.kotlin.android' version '1.8.20' apply false - id "com.github.ben-manes.versions" version "0.42.0" - id 'org.jmailen.kotlinter' version "3.15.0" apply false - id 'com.google.devtools.ksp' version "1.8.21-1.0.11" apply false - id 'com.android.test' version '8.0.2' apply false - id 'androidx.baselineprofile' version '1.2.0-alpha13' apply false -} - -subprojects { - apply plugin: "org.jmailen.kotlinter" // Version should be inherited from parent -} - -// Enables compose compiler metrics -// Generate them with `./gradlew assembleRelease --rerun-tasks -P com.jerboa.enableComposeCompilerReports=true` -// see https://github.com/androidx/androidx/blob/androidx-main/compose/compiler/design/compiler-metrics.md -subprojects { - tasks.withType(KotlinCompile).configureEach { - compilerOptions { - if (project.findProperty("com.jerboa.enableComposeCompilerReports") == "true") { - - freeCompilerArgs.addAll([ - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + - project.buildDir.absolutePath + "/compose_metrics" - ]) - freeCompilerArgs.addAll([ - "-P", - "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + - project.buildDir.absolutePath + "/compose_metrics" - ]) - } - } - } -} - -tasks.register('clean', Delete) { - delete rootProject.buildDir -} diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 000000000..afd7d42e3 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,50 @@ +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +buildscript { + repositories { + google() + mavenCentral() + } +}// Top-level build file where you can add configuration options common to all sub-projects/modules. + +plugins { + id("com.android.application") version "8.0.2" apply false + id("com.android.library") version "8.0.2" apply false + id("org.jetbrains.kotlin.android") version "1.8.20" apply false + id("com.github.ben-manes.versions") version "0.42.0" + id("org.jmailen.kotlinter") version "3.15.0" apply false + id("com.google.devtools.ksp") version "1.8.21-1.0.11" apply false + id( "com.android.test") version "8.0.2" apply false + id( "androidx.baselineprofile") version "1.2.0-alpha13" apply false +} + +subprojects { + apply(plugin = "org.jmailen.kotlinter") // Version should be inherited from parent +} + +// Enables compose compiler metrics +// Generate them with `./gradlew assembleRelease --rerun-tasks -P com.jerboa.enableComposeCompilerReports=true` +// see https://github.com/androidx/androidx/blob/androidx-main/compose/compiler/design/compiler-metrics.md +subprojects { + tasks.withType().configureEach { + compilerOptions { + if (project.findProperty("com.jerboa.enableComposeCompilerReports") == "true") { + + freeCompilerArgs.addAll( + "-P", "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + + project.buildDir.absolutePath + "/compose_metrics" + ) + + freeCompilerArgs.addAll( + "-P", + "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + + project.buildDir.absolutePath + "/compose_metrics" + ) + } + } + } +} + +tasks.register("clean", Delete::class) { + delete(rootProject.buildDir) +} diff --git a/settings.gradle b/settings.gradle.kts similarity index 77% rename from settings.gradle rename to settings.gradle.kts index ca76129f7..504ad96e8 100644 --- a/settings.gradle +++ b/settings.gradle.kts @@ -10,9 +10,10 @@ dependencyResolutionManagement { repositories { google() mavenCentral() - maven { url 'https://jitpack.io' } + maven { url = uri("https://jitpack.io") } } } rootProject.name = "jerboa" -include ':app' -include ':benchmarks' +include(":app") +include(":benchmarks") + From d38a86c74a3544729643f1f1712e5e6a10b565b6 Mon Sep 17 00:00:00 2001 From: "maarten.vercruysse" Date: Fri, 23 Jun 2023 22:58:40 +0200 Subject: [PATCH 2/3] Update version --- app/build.gradle.kts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 0ceef8912..fd5b82b43 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -15,8 +15,8 @@ android { namespace = "com.jerboa" minSdk = 26 targetSdk = 33 - versionCode = 34 - versionName = "0.0.34" + versionCode = 35 + versionName = "0.0.35" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { @@ -25,7 +25,7 @@ android { ksp { arg("room.schemaLocation", "$projectDir/schemas") } } - if(project.hasProperty("RELEASE_STORE_FILE")) { + if (project.hasProperty("RELEASE_STORE_FILE")) { signingConfigs { register("release") { storeFile = file(project.property("RELEASE_STORE_FILE")!!) @@ -42,8 +42,10 @@ android { buildTypes { release { - if(project.hasProperty("RELEASE_STORE_FILE")) { - signingConfig = signingConfigs.getByName("release") + signingConfig = if (project.hasProperty("RELEASE_STORE_FILE")) { + signingConfigs.getByName("release") + } else { + signingConfigs.getByName("debug") } postprocessing { From 3ae63a50df24ed9b94a659faac671ee9fee04ce5 Mon Sep 17 00:00:00 2001 From: "maarten.vercruysse" Date: Fri, 23 Jun 2023 23:10:27 +0200 Subject: [PATCH 3/3] Retrigger pipeline --- build.gradle.kts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index afd7d42e3..32b673cfd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,7 +31,8 @@ subprojects { if (project.findProperty("com.jerboa.enableComposeCompilerReports") == "true") { freeCompilerArgs.addAll( - "-P", "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + + "-P", + "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + project.buildDir.absolutePath + "/compose_metrics" )