mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-14 17:37:05 +05:30
build-logic: rewrite everything to use full Gradle plugins
This commit is contained in:
parent
49863d4138
commit
29d63a879e
29 changed files with 415 additions and 301 deletions
|
@ -89,17 +89,23 @@ fun LobstersApp(
|
||||||
label = "Hottest",
|
label = "Hottest",
|
||||||
route = Destinations.Hottest.getRoute(),
|
route = Destinations.Hottest.getRoute(),
|
||||||
icon = ClawIcons.Flame,
|
icon = ClawIcons.Flame,
|
||||||
) { coroutineScope.launch { hottestListState.animateScrollToItem(index = 0) } },
|
) {
|
||||||
|
coroutineScope.launch { hottestListState.animateScrollToItem(index = 0) }
|
||||||
|
},
|
||||||
NavigationItem(
|
NavigationItem(
|
||||||
label = "Newest",
|
label = "Newest",
|
||||||
route = Destinations.Newest.getRoute(),
|
route = Destinations.Newest.getRoute(),
|
||||||
icon = ClawIcons.New,
|
icon = ClawIcons.New,
|
||||||
) { coroutineScope.launch { newestListState.animateScrollToItem(index = 0) } },
|
) {
|
||||||
|
coroutineScope.launch { newestListState.animateScrollToItem(index = 0) }
|
||||||
|
},
|
||||||
NavigationItem(
|
NavigationItem(
|
||||||
label = "Saved",
|
label = "Saved",
|
||||||
route = Destinations.Saved.getRoute(),
|
route = Destinations.Saved.getRoute(),
|
||||||
icon = ClawIcons.HeartBorder,
|
icon = ClawIcons.HeartBorder,
|
||||||
) { coroutineScope.launch { savedListState.animateScrollToItem(index = 0) } },
|
) {
|
||||||
|
coroutineScope.launch { savedListState.animateScrollToItem(index = 0) }
|
||||||
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
SideEffect { systemUiController.setStatusBarColor(color = systemBarsColor) }
|
SideEffect { systemUiController.setStatusBarColor(color = systemBarsColor) }
|
||||||
|
|
|
@ -17,7 +17,27 @@ afterEvaluate {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
tasks.withType<KotlinCompile>().configureEach {
|
||||||
kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() }
|
kotlinOptions {
|
||||||
|
jvmTarget = JavaVersion.VERSION_11.toString()
|
||||||
|
freeCompilerArgs = freeCompilerArgs + "-Xsam-conversions=class"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gradlePlugin {
|
||||||
|
plugins {
|
||||||
|
register("android-application") {
|
||||||
|
id = "dev.msfjarvis.claw.android-application"
|
||||||
|
implementationClass = "dev.msfjarvis.aps.gradle.ApplicationPlugin"
|
||||||
|
}
|
||||||
|
register("android-library") {
|
||||||
|
id = "dev.msfjarvis.claw.android-library"
|
||||||
|
implementationClass = "dev.msfjarvis.aps.gradle.LibraryPlugin"
|
||||||
|
}
|
||||||
|
register("rename-artifacts") {
|
||||||
|
id = "dev.msfjarvis.claw.rename-artifacts"
|
||||||
|
implementationClass = "dev.msfjarvis.aps.gradle.RenameArtifactsPlugin"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
*/
|
|
||||||
@file:Suppress("UnstableApiUsage")
|
|
||||||
|
|
||||||
import signing.configureBuildSigning
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("com.android.application")
|
|
||||||
id("dev.msfjarvis.claw.android-common")
|
|
||||||
}
|
|
||||||
|
|
||||||
android {
|
|
||||||
adbOptions.installOptions("--user 0")
|
|
||||||
|
|
||||||
dependenciesInfo {
|
|
||||||
includeInBundle = false
|
|
||||||
includeInApk = false
|
|
||||||
}
|
|
||||||
|
|
||||||
buildFeatures { buildConfig = true }
|
|
||||||
|
|
||||||
buildTypes {
|
|
||||||
named("release") { isMinifyEnabled = false }
|
|
||||||
named("debug") {
|
|
||||||
applicationIdSuffix = ".debug"
|
|
||||||
versionNameSuffix = "-debug"
|
|
||||||
isMinifyEnabled = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
project.configureBuildSigning()
|
|
||||||
}
|
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
*/
|
|
||||||
@file:Suppress("UnstableApiUsage")
|
|
||||||
|
|
||||||
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
|
|
||||||
import com.android.build.api.variant.LibraryAndroidComponentsExtension
|
|
||||||
import com.android.build.gradle.TestedExtension
|
|
||||||
import org.gradle.kotlin.dsl.findByType
|
|
||||||
|
|
||||||
extensions.configure<TestedExtension> {
|
|
||||||
setCompileSdkVersion(31)
|
|
||||||
defaultConfig {
|
|
||||||
minSdk = 26
|
|
||||||
targetSdk = 31
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions.findByType<LibraryAndroidComponentsExtension>()?.run {
|
|
||||||
beforeVariants(selector().withBuildType("release")) {
|
|
||||||
it.enableUnitTest = false
|
|
||||||
it.enableAndroidTest = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
extensions.findByType<ApplicationAndroidComponentsExtension>()?.run {
|
|
||||||
beforeVariants(selector().withBuildType("release")) {
|
|
||||||
it.enableUnitTest = false
|
|
||||||
it.enableAndroidTest = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
named("main") { java.srcDirs("src/main/kotlin") }
|
|
||||||
named("test") { java.srcDirs("src/test/kotlin") }
|
|
||||||
named("androidTest") { java.srcDirs("src/androidTest/kotlin") }
|
|
||||||
}
|
|
||||||
|
|
||||||
packagingOptions {
|
|
||||||
resources.excludes.add("**/*.version")
|
|
||||||
resources.excludes.add("**/*.txt")
|
|
||||||
resources.excludes.add("**/*.kotlin_module")
|
|
||||||
resources.excludes.add("**/plugin.properties")
|
|
||||||
resources.excludes.add("**/META-INF/AL2.0")
|
|
||||||
resources.excludes.add("**/META-INF/LGPL2.1")
|
|
||||||
}
|
|
||||||
|
|
||||||
compileOptions {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_11
|
|
||||||
targetCompatibility = JavaVersion.VERSION_11
|
|
||||||
}
|
|
||||||
|
|
||||||
testOptions {
|
|
||||||
animationsDisabled = true
|
|
||||||
unitTests.isReturnDefaultValues = true
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("com.android.library")
|
|
||||||
id("dev.msfjarvis.claw.android-common")
|
|
||||||
}
|
|
||||||
|
|
||||||
android { defaultConfig { consumerProguardFiles("consumer-rules.pro") } }
|
|
|
@ -1,22 +0,0 @@
|
||||||
import artifacts.CollectApksTask
|
|
||||||
import artifacts.CollectBundleTask
|
|
||||||
import com.android.build.api.artifact.SingleArtifact
|
|
||||||
|
|
||||||
plugins { id("com.android.application") }
|
|
||||||
|
|
||||||
androidComponents {
|
|
||||||
onVariants { variant ->
|
|
||||||
project.tasks.register<CollectApksTask>("collect${variant.name.capitalize()}Apks") {
|
|
||||||
variantName.set(variant.name)
|
|
||||||
apkFolder.set(variant.artifacts.get(SingleArtifact.APK))
|
|
||||||
builtArtifactsLoader.set(variant.artifacts.getBuiltArtifactsLoader())
|
|
||||||
outputDirectory.set(project.layout.projectDirectory.dir("outputs"))
|
|
||||||
}
|
|
||||||
project.tasks.register<CollectBundleTask>("collect${variant.name.capitalize()}Bundle") {
|
|
||||||
variantName.set(variant.name)
|
|
||||||
versionName.set(android.defaultConfig.versionName)
|
|
||||||
bundleFile.set(variant.artifacts.get(SingleArtifact.BUNDLE))
|
|
||||||
outputDirectory.set(project.layout.projectDirectory.dir("outputs"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
package dev.msfjarvis.aps.gradle
|
||||||
|
|
||||||
|
import com.android.build.gradle.TestedExtension
|
||||||
|
import org.gradle.api.JavaVersion
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.configure
|
||||||
|
|
||||||
|
@Suppress("UnstableApiUsage")
|
||||||
|
object AndroidCommon {
|
||||||
|
fun configure(project: Project) {
|
||||||
|
project.extensions.configure<TestedExtension> {
|
||||||
|
setCompileSdkVersion(31)
|
||||||
|
defaultConfig {
|
||||||
|
minSdk = 26
|
||||||
|
targetSdk = 31
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
named("main") { java.srcDirs("src/main/kotlin") }
|
||||||
|
named("test") { java.srcDirs("src/test/kotlin") }
|
||||||
|
named("androidTest") { java.srcDirs("src/androidTest/kotlin") }
|
||||||
|
}
|
||||||
|
|
||||||
|
packagingOptions {
|
||||||
|
resources.excludes.add("**/*.version")
|
||||||
|
resources.excludes.add("**/*.txt")
|
||||||
|
resources.excludes.add("**/*.kotlin_module")
|
||||||
|
resources.excludes.add("**/plugin.properties")
|
||||||
|
resources.excludes.add("**/META-INF/AL2.0")
|
||||||
|
resources.excludes.add("**/META-INF/LGPL2.1")
|
||||||
|
}
|
||||||
|
|
||||||
|
compileOptions {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11
|
||||||
|
}
|
||||||
|
|
||||||
|
testOptions {
|
||||||
|
animationsDisabled = true
|
||||||
|
unitTests.isReturnDefaultValues = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
|
package dev.msfjarvis.aps.gradle
|
||||||
|
|
||||||
|
import com.android.build.gradle.AppPlugin
|
||||||
|
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
|
||||||
|
import dev.msfjarvis.aps.gradle.signing.configureBuildSigning
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
import org.gradle.kotlin.dsl.getByType
|
||||||
|
|
||||||
|
@Suppress("Unused")
|
||||||
|
class ApplicationPlugin : Plugin<Project> {
|
||||||
|
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
project.pluginManager.apply(AppPlugin::class)
|
||||||
|
AndroidCommon.configure(project)
|
||||||
|
project.extensions.getByType<BaseAppModuleExtension>().run {
|
||||||
|
adbOptions.installOptions("--user 0")
|
||||||
|
|
||||||
|
dependenciesInfo {
|
||||||
|
includeInBundle = false
|
||||||
|
includeInApk = false
|
||||||
|
}
|
||||||
|
|
||||||
|
buildFeatures {
|
||||||
|
viewBinding = true
|
||||||
|
buildConfig = true
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
named("release") {
|
||||||
|
isMinifyEnabled = false
|
||||||
|
setProguardFiles(
|
||||||
|
listOf(
|
||||||
|
"proguard-android-optimize.txt",
|
||||||
|
"proguard-rules.pro",
|
||||||
|
"proguard-rules-missing-classes.pro",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
named("debug") {
|
||||||
|
applicationIdSuffix = ".debug"
|
||||||
|
versionNameSuffix = "-debug"
|
||||||
|
isMinifyEnabled = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.configureBuildSigning()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Project.isSnapshot(): Boolean {
|
||||||
|
with(project.providers) {
|
||||||
|
val workflow = environmentVariable("GITHUB_WORKFLOW")
|
||||||
|
val snapshot = environmentVariable("SNAPSHOT")
|
||||||
|
return workflow.isPresent || snapshot.isPresent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package dev.msfjarvis.aps.gradle
|
||||||
|
|
||||||
|
import com.android.build.gradle.LibraryPlugin
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
|
||||||
|
@Suppress("Unused")
|
||||||
|
class LibraryPlugin : Plugin<Project> {
|
||||||
|
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
project.pluginManager.apply(LibraryPlugin::class)
|
||||||
|
AndroidCommon.configure(project)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package dev.msfjarvis.aps.gradle
|
||||||
|
|
||||||
|
import com.android.build.api.artifact.SingleArtifact
|
||||||
|
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
|
||||||
|
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
|
||||||
|
import dev.msfjarvis.aps.gradle.artifacts.CollectApksTask
|
||||||
|
import dev.msfjarvis.aps.gradle.artifacts.CollectBundleTask
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.getByType
|
||||||
|
import org.gradle.kotlin.dsl.register
|
||||||
|
|
||||||
|
@Suppress("Unused")
|
||||||
|
class RenameArtifactsPlugin : Plugin<Project> {
|
||||||
|
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
project.pluginManager.withPlugin("com.android.application") {
|
||||||
|
val android = project.extensions.getByType<BaseAppModuleExtension>()
|
||||||
|
project.extensions.getByType<ApplicationAndroidComponentsExtension>().run {
|
||||||
|
onVariants { variant ->
|
||||||
|
project.tasks.register<CollectApksTask>("collect${variant.name.capitalize()}Apks") {
|
||||||
|
variantName.set(variant.name)
|
||||||
|
apkFolder.set(variant.artifacts.get(SingleArtifact.APK))
|
||||||
|
builtArtifactsLoader.set(variant.artifacts.getBuiltArtifactsLoader())
|
||||||
|
outputDirectory.set(project.layout.projectDirectory.dir("outputs"))
|
||||||
|
}
|
||||||
|
project.tasks.register<CollectBundleTask>("collect${variant.name.capitalize()}Bundle") {
|
||||||
|
variantName.set(variant.name)
|
||||||
|
versionName.set(android.defaultConfig.versionName)
|
||||||
|
bundleFile.set(variant.artifacts.get(SingleArtifact.BUNDLE))
|
||||||
|
outputDirectory.set(project.layout.projectDirectory.dir("outputs"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package artifacts
|
package dev.msfjarvis.aps.gradle.artifacts
|
||||||
|
|
||||||
import com.android.build.api.variant.BuiltArtifactsLoader
|
import com.android.build.api.variant.BuiltArtifactsLoader
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
|
@ -1,4 +1,4 @@
|
||||||
package artifacts
|
package dev.msfjarvis.aps.gradle.artifacts
|
||||||
|
|
||||||
import java.nio.file.Files
|
import java.nio.file.Files
|
||||||
import java.nio.file.StandardCopyOption
|
import java.nio.file.StandardCopyOption
|
|
@ -3,13 +3,12 @@
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
* SPDX-License-Identifier: GPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package signing
|
package dev.msfjarvis.aps.gradle.signing
|
||||||
|
|
||||||
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
|
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
|
||||||
import java.util.Properties
|
import java.util.Properties
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.configure
|
import org.gradle.kotlin.dsl.configure
|
||||||
import org.gradle.kotlin.dsl.provideDelegate
|
|
||||||
|
|
||||||
private const val KEYSTORE_CONFIG_PATH = "keystore.properties"
|
private const val KEYSTORE_CONFIG_PATH = "keystore.properties"
|
||||||
|
|
|
@ -17,7 +17,35 @@ afterEvaluate {
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
tasks.withType<KotlinCompile>().configureEach {
|
||||||
kotlinOptions { jvmTarget = JavaVersion.VERSION_11.toString() }
|
kotlinOptions {
|
||||||
|
jvmTarget = JavaVersion.VERSION_11.toString()
|
||||||
|
freeCompilerArgs = freeCompilerArgs + "-Xsam-conversions=class"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gradlePlugin {
|
||||||
|
plugins {
|
||||||
|
register("kotlin-android") {
|
||||||
|
id = "dev.msfjarvis.claw.kotlin-android"
|
||||||
|
implementationClass = "dev.msfjarvis.aps.gradle.KotlinAndroidPlugin"
|
||||||
|
}
|
||||||
|
register("kotlin-common") {
|
||||||
|
id = "dev.msfjarvis.claw.kotlin-common"
|
||||||
|
implementationClass = "dev.msfjarvis.aps.gradle.KotlinCommonPlugin"
|
||||||
|
}
|
||||||
|
register("kotlin-kapt") {
|
||||||
|
id = "dev.msfjarvis.claw.kotlin-kapt"
|
||||||
|
implementationClass = "dev.msfjarvis.aps.gradle.KotlinKaptPlugin"
|
||||||
|
}
|
||||||
|
register("kotlin-library") {
|
||||||
|
id = "dev.msfjarvis.claw.kotlin-library"
|
||||||
|
implementationClass = "dev.msfjarvis.aps.gradle.KotlinLibraryPlugin"
|
||||||
|
}
|
||||||
|
register("spotless") {
|
||||||
|
id = "dev.msfjarvis.claw.spotless"
|
||||||
|
implementationClass = "dev.msfjarvis.aps.gradle.SpotlessPlugin"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +54,4 @@ dependencies {
|
||||||
implementation(libs.build.kotlin.gradle)
|
implementation(libs.build.kotlin.gradle)
|
||||||
implementation(libs.build.kotlin.serialization)
|
implementation(libs.build.kotlin.serialization)
|
||||||
implementation(libs.build.spotless)
|
implementation(libs.build.spotless)
|
||||||
implementation(libs.build.vcu)
|
|
||||||
implementation(libs.build.versions)
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
kotlin("android")
|
|
||||||
id("dev.msfjarvis.claw.kotlin-common")
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.gradle.api.JavaVersion
|
|
||||||
import org.gradle.api.tasks.compile.JavaCompile
|
|
||||||
import org.gradle.api.tasks.testing.Test
|
|
||||||
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
|
||||||
import org.gradle.kotlin.dsl.withType
|
|
||||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
|
||||||
|
|
||||||
val additionalCompilerArgs =
|
|
||||||
listOf(
|
|
||||||
"-Xopt-in=kotlin.RequiresOptIn",
|
|
||||||
"-P",
|
|
||||||
"plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true",
|
|
||||||
)
|
|
||||||
|
|
||||||
tasks.withType<JavaCompile>().configureEach {
|
|
||||||
sourceCompatibility = JavaVersion.VERSION_11.toString()
|
|
||||||
targetCompatibility = JavaVersion.VERSION_11.toString()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<KotlinCompile>().configureEach {
|
|
||||||
kotlinOptions {
|
|
||||||
// TODO: Re-enable once warnings from Aurora-generated code are fixed
|
|
||||||
allWarningsAsErrors = false
|
|
||||||
jvmTarget = JavaVersion.VERSION_11.toString()
|
|
||||||
freeCompilerArgs = freeCompilerArgs + additionalCompilerArgs
|
|
||||||
languageVersion = "1.5"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<Test>().configureEach {
|
|
||||||
maxParallelForks = Runtime.getRuntime().availableProcessors() * 2
|
|
||||||
testLogging { events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) }
|
|
||||||
doNotTrackState("We want tests to always run even if Gradle thinks otherwise")
|
|
||||||
}
|
|
|
@ -1,43 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.gradle.api.Project
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
kotlin("android")
|
|
||||||
kotlin("kapt")
|
|
||||||
}
|
|
||||||
|
|
||||||
afterEvaluate {
|
|
||||||
kapt {
|
|
||||||
javacOptions {
|
|
||||||
if (hasDaggerCompilerDependency()) {
|
|
||||||
// https://dagger.dev/dev-guide/compiler-options#fastinit-mode
|
|
||||||
option("-Adagger.fastInit=enabled")
|
|
||||||
// Enable the better, experimental error messages
|
|
||||||
// https://github.com/google/dagger/commit/0d2505a727b54f47b8677f42dd4fc5c1924e37f5
|
|
||||||
option("-Adagger.experimentalDaggerErrorMessages=enabled")
|
|
||||||
// Share test components for when we start leveraging Hilt for tests
|
|
||||||
// https://github.com/google/dagger/releases/tag/dagger-2.34
|
|
||||||
option("-Adagger.hilt.shareTestComponents=true")
|
|
||||||
// KAPT nests errors causing real issues to be suppressed in CI logs
|
|
||||||
option("-Xmaxerrs", 500)
|
|
||||||
// Enables per-module validation for faster error detection
|
|
||||||
// https://github.com/google/dagger/commit/325b516ac6a53d3fc973d247b5231fafda9870a2
|
|
||||||
option("-Adagger.moduleBindingValidation=ERROR")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// disable kapt tasks for unit tests
|
|
||||||
tasks
|
|
||||||
.matching { it.name.startsWith("kapt") && it.name.endsWith("UnitTestKotlin") }
|
|
||||||
.configureEach { enabled = false }
|
|
||||||
|
|
||||||
fun Project.hasDaggerCompilerDependency(): Boolean {
|
|
||||||
return configurations.any {
|
|
||||||
it.dependencies.any { dependency -> dependency.name == "hilt-compiler" }
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,6 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
plugins { id("dev.msfjarvis.claw.kotlin-common") }
|
|
|
@ -1,28 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
|
||||||
* SPDX-License-Identifier: GPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
plugins { id("com.diffplug.spotless") }
|
|
||||||
|
|
||||||
val KTFMT_VERSION = "0.37"
|
|
||||||
|
|
||||||
spotless {
|
|
||||||
kotlin {
|
|
||||||
ktfmt(KTFMT_VERSION).googleStyle()
|
|
||||||
target("**/*.kt")
|
|
||||||
targetExclude("**/build/", "**/gen/")
|
|
||||||
}
|
|
||||||
kotlinGradle {
|
|
||||||
ktfmt(KTFMT_VERSION).googleStyle()
|
|
||||||
target("**/*.kts")
|
|
||||||
targetExclude("**/build/")
|
|
||||||
}
|
|
||||||
format("xml") {
|
|
||||||
target("**/*.xml")
|
|
||||||
targetExclude("**/build/", ".idea/")
|
|
||||||
trimTrailingWhitespace()
|
|
||||||
indentWithSpaces()
|
|
||||||
endWithNewline()
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,37 +0,0 @@
|
||||||
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("com.github.ben-manes.versions")
|
|
||||||
id("nl.littlerobots.version-catalog-update")
|
|
||||||
}
|
|
||||||
|
|
||||||
versionCatalogUpdate {
|
|
||||||
keep {
|
|
||||||
// This clears out build-logic specific dependencies
|
|
||||||
keepUnusedLibraries.set(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun isNonStable(version: String): Boolean {
|
|
||||||
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) }
|
|
||||||
val regex = "^[0-9,.v-]+(-r)?$".toRegex()
|
|
||||||
val isStable = stableKeyword || regex.matches(version)
|
|
||||||
return isStable.not()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<DependencyUpdatesTask>().configureEach {
|
|
||||||
rejectVersionIf {
|
|
||||||
when (candidate.group) {
|
|
||||||
"com.android.application",
|
|
||||||
"com.android.library",
|
|
||||||
"com.google.accompanist",
|
|
||||||
"org.jetbrains.kotlin" -> true
|
|
||||||
else -> isNonStable(candidate.version) && !isNonStable(currentVersion)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
checkForGradleUpdate = false
|
|
||||||
checkBuildEnvironmentConstraints = true
|
|
||||||
outputFormatter = "json"
|
|
||||||
outputDir = "build/dependencyUpdates"
|
|
||||||
reportfileName = "report"
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package dev.msfjarvis.aps.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
|
||||||
|
|
||||||
|
@Suppress("Unused")
|
||||||
|
class KotlinAndroidPlugin : Plugin<Project> {
|
||||||
|
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
project.pluginManager.run {
|
||||||
|
apply(KotlinAndroidPluginWrapper::class)
|
||||||
|
apply(KotlinCommonPlugin::class)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package dev.msfjarvis.aps.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.JavaVersion
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.tasks.compile.JavaCompile
|
||||||
|
import org.gradle.api.tasks.testing.Test
|
||||||
|
import org.gradle.api.tasks.testing.logging.TestLogEvent
|
||||||
|
import org.gradle.kotlin.dsl.withType
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||||
|
|
||||||
|
@Suppress("Unused")
|
||||||
|
class KotlinCommonPlugin : Plugin<Project> {
|
||||||
|
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
project.tasks.run {
|
||||||
|
withType<JavaCompile>().configureEach {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_11.toString()
|
||||||
|
targetCompatibility = JavaVersion.VERSION_11.toString()
|
||||||
|
}
|
||||||
|
withType<KotlinCompile>().configureEach {
|
||||||
|
kotlinOptions {
|
||||||
|
allWarningsAsErrors = false
|
||||||
|
jvmTarget = JavaVersion.VERSION_11.toString()
|
||||||
|
freeCompilerArgs = freeCompilerArgs + ADDITIONAL_COMPILER_ARGS
|
||||||
|
languageVersion = "1.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
withType<Test>().configureEach {
|
||||||
|
maxParallelForks = Runtime.getRuntime().availableProcessors() * 2
|
||||||
|
testLogging { events(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED) }
|
||||||
|
doNotTrackState("We want tests to always run even if Gradle thinks otherwise")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
private val ADDITIONAL_COMPILER_ARGS =
|
||||||
|
listOf(
|
||||||
|
"-opt-in=kotlin.RequiresOptIn",
|
||||||
|
"-P",
|
||||||
|
"plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=true",
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package dev.msfjarvis.aps.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
import org.gradle.kotlin.dsl.getByType
|
||||||
|
import org.jetbrains.kotlin.gradle.internal.Kapt3GradleSubplugin
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KaptExtension
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper
|
||||||
|
|
||||||
|
@Suppress("Unused")
|
||||||
|
class KotlinKaptPlugin : Plugin<Project> {
|
||||||
|
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
project.pluginManager.run {
|
||||||
|
apply(KotlinAndroidPluginWrapper::class)
|
||||||
|
apply(Kapt3GradleSubplugin::class)
|
||||||
|
}
|
||||||
|
project.afterEvaluate {
|
||||||
|
project.extensions.getByType<KaptExtension>().run {
|
||||||
|
javacOptions {
|
||||||
|
if (hasDaggerCompilerDependency()) {
|
||||||
|
// https://dagger.dev/dev-guide/compiler-options#fastinit-mode
|
||||||
|
option("-Adagger.fastInit=enabled")
|
||||||
|
// Enable the better, experimental error messages
|
||||||
|
// https://github.com/google/dagger/commit/0d2505a727b54f47b8677f42dd4fc5c1924e37f5
|
||||||
|
option("-Adagger.experimentalDaggerErrorMessages=enabled")
|
||||||
|
// Share test components for when we start leveraging Hilt for tests
|
||||||
|
// https://github.com/google/dagger/releases/tag/dagger-2.34
|
||||||
|
option("-Adagger.hilt.shareTestComponents=true")
|
||||||
|
// KAPT nests errors causing real issues to be suppressed in CI logs
|
||||||
|
option("-Xmaxerrs", 500)
|
||||||
|
// Enables per-module validation for faster error detection
|
||||||
|
// https://github.com/google/dagger/commit/325b516ac6a53d3fc973d247b5231fafda9870a2
|
||||||
|
option("-Adagger.moduleBindingValidation=ERROR")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
project.tasks
|
||||||
|
.matching { it.name.startsWith("kapt") && it.name.endsWith("UnitTestKotlin") }
|
||||||
|
.configureEach { enabled = false }
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Project.hasDaggerCompilerDependency(): Boolean {
|
||||||
|
return configurations.any {
|
||||||
|
it.dependencies.any { dependency -> dependency.name == "hilt-compiler" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package dev.msfjarvis.aps.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
|
||||||
|
@Suppress("Unused")
|
||||||
|
class KotlinLibraryPlugin : Plugin<Project> {
|
||||||
|
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
project.pluginManager.apply(KotlinCommonPlugin::class)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright © 2014-2021 The Android Password Store Authors. All Rights Reserved.
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
package dev.msfjarvis.aps.gradle
|
||||||
|
|
||||||
|
import com.diffplug.gradle.spotless.SpotlessExtension
|
||||||
|
import com.diffplug.gradle.spotless.SpotlessPlugin
|
||||||
|
import org.gradle.api.Plugin
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
import org.gradle.kotlin.dsl.getByType
|
||||||
|
|
||||||
|
@Suppress("Unused")
|
||||||
|
class SpotlessPlugin : Plugin<Project> {
|
||||||
|
|
||||||
|
override fun apply(project: Project) {
|
||||||
|
project.pluginManager.apply(SpotlessPlugin::class)
|
||||||
|
project.extensions.getByType<SpotlessExtension>().run {
|
||||||
|
kotlin {
|
||||||
|
ktfmt(KTFMT_VERSION).googleStyle()
|
||||||
|
target("**/*.kt")
|
||||||
|
targetExclude("**/build/", "**/gen/")
|
||||||
|
}
|
||||||
|
kotlinGradle {
|
||||||
|
ktfmt(KTFMT_VERSION).googleStyle()
|
||||||
|
target("**/*.kts")
|
||||||
|
targetExclude("**/build/")
|
||||||
|
}
|
||||||
|
format("xml") {
|
||||||
|
target("**/*.xml")
|
||||||
|
targetExclude("**/build/", ".idea/")
|
||||||
|
trimTrailingWhitespace()
|
||||||
|
indentWithSpaces()
|
||||||
|
endWithNewline()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
private const val KTFMT_VERSION = "0.38"
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("dev.msfjarvis.claw.spotless")
|
id("dev.msfjarvis.claw.spotless")
|
||||||
id("dev.msfjarvis.claw.versions")
|
// id("dev.msfjarvis.claw.versions")
|
||||||
id("dev.msfjarvis.claw.kotlin-common")
|
id("dev.msfjarvis.claw.kotlin-common")
|
||||||
alias(libs.plugins.hilt) apply false
|
alias(libs.plugins.hilt) apply false
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,9 @@ fun ThemedRichText(
|
||||||
CompositionLocalProvider(
|
CompositionLocalProvider(
|
||||||
LocalTextStyle provides MaterialTheme.typography.bodyLarge,
|
LocalTextStyle provides MaterialTheme.typography.bodyLarge,
|
||||||
LocalContentColor provides MaterialTheme.colorScheme.onBackground,
|
LocalContentColor provides MaterialTheme.colorScheme.onBackground,
|
||||||
) { MaterialRichText(modifier) { content() } }
|
) {
|
||||||
|
MaterialRichText(modifier) { content() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
@ -207,7 +207,9 @@ fun TagRow(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
mainAxisSpacing = 8.dp,
|
mainAxisSpacing = 8.dp,
|
||||||
crossAxisSpacing = 8.dp,
|
crossAxisSpacing = 8.dp,
|
||||||
) { tags.forEach { tag -> TagText(tag) } }
|
) {
|
||||||
|
tags.forEach { tag -> TagText(tag) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
|
@ -34,8 +34,6 @@ build-agp = "com.android.tools.build:gradle:7.4.0-alpha02"
|
||||||
build-kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
build-kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
|
||||||
build-kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
|
build-kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
|
||||||
build-spotless = "com.diffplug.spotless:spotless-plugin-gradle:6.7.0"
|
build-spotless = "com.diffplug.spotless:spotless-plugin-gradle:6.7.0"
|
||||||
build-vcu = "nl.littlerobots.version-catalog-update:nl.littlerobots.version-catalog-update.gradle.plugin:0.4.0"
|
|
||||||
build-versions = "com.github.ben-manes:gradle-versions-plugin:0.42.0"
|
|
||||||
coil = { module = "io.coil-kt:coil", version.ref = "coil" }
|
coil = { module = "io.coil-kt:coil", version.ref = "coil" }
|
||||||
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
|
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
|
||||||
compose-richtext-markdown = { module = "com.halilibo.compose-richtext:richtext-commonmark", version.ref = "richtext" }
|
compose-richtext-markdown = { module = "com.halilibo.compose-richtext:richtext-commonmark", version.ref = "richtext" }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue