From 942ca053b625d9bafab9a8d685294b43d14225ef Mon Sep 17 00:00:00 2001 From: "./root" Date: Sat, 19 Oct 2024 10:28:23 +0200 Subject: [PATCH 1/4] introduce convention plugins --- README.md | 12 ++- buildLogic/convention/build.gradle.kts | 86 +++++++++++++++++++ ...droidApplicationComposeConventionPlugin.kt | 19 ++++ .../AndroidApplicationConventionPlugin.kt | 27 ++++++ ...roidApplicationFirebaseConventionPlugin.kt | 38 ++++++++ .../kotlin/AndroidFeatureConventionPlugin.kt | 31 +++++++ .../AndroidLibraryComposeConventionPlugin.kt | 19 ++++ .../kotlin/AndroidLibraryConventionPlugin.kt | 44 ++++++++++ .../kotlin/AndroidLintConventionPlugin.kt | 32 +++++++ .../kotlin/AndroidRoomConventionPlugin.kt | 34 ++++++++ .../kotlin/AndroidTestConventionPlugin.kt | 23 +++++ .../src/main/kotlin/HiltConventionPlugin.kt | 26 ++++++ .../main/kotlin/JVMLibraryConventionPlugin.kt | 59 +++++++++++++ .../com/droidconke/doko/AndroidCompose.kt | 54 ++++++++++++ .../doko/AndroidIntsrumentedTests.kt | 11 +++ .../com/droidconke/doko/KotlinAndroid.kt | 68 +++++++++++++++ .../com/droidconke/doko/ProjectExtensions.kt | 10 +++ compose_compiler_config.conf | 11 +++ 18 files changed, 602 insertions(+), 2 deletions(-) create mode 100644 buildLogic/convention/build.gradle.kts create mode 100644 buildLogic/convention/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/AndroidRoomConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/AndroidTestConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/HiltConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/JVMLibraryConventionPlugin.kt create mode 100644 buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidCompose.kt create mode 100644 buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidIntsrumentedTests.kt create mode 100644 buildLogic/convention/src/main/kotlin/com/droidconke/doko/KotlinAndroid.kt create mode 100644 buildLogic/convention/src/main/kotlin/com/droidconke/doko/ProjectExtensions.kt create mode 100644 compose_compiler_config.conf diff --git a/README.md b/README.md index 2643bd8..5a1ee8a 100644 --- a/README.md +++ b/README.md @@ -17,10 +17,18 @@ The project is designed as: - [ ] A Merchant App to sell items - [ ] Admin App to check on status of everything -- + +### [Tech Stack 🛠] +- [ ] Kotlin +- [ ] Jetpack Compose + +*use JVM 21* + +### [Features 🚀] + ## Contributing - Hop on here for a chat and ask questions. NO DMs please :) + Create an [issue here](https://github.com/droidconKE/doko/issues) and ask questions. NO DMs please :) diff --git a/buildLogic/convention/build.gradle.kts b/buildLogic/convention/build.gradle.kts new file mode 100644 index 0000000..d6ffbf8 --- /dev/null +++ b/buildLogic/convention/build.gradle.kts @@ -0,0 +1,86 @@ +import org.jetbrains.kotlin.gradle.dsl.JvmTarget + +plugins { + `kotlin-dsl` +} + +group = "com.droidconke.doko.buildlogic" + +java { + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 +} + +kotlin { + compilerOptions { + jvmTarget = JvmTarget.JVM_21 + } +} + +dependencies { + compileOnly(libs.android.gradlePlugin) + compileOnly(libs.android.tools.common) + compileOnly(libs.compose.gradlePlugin) + compileOnly(libs.firebase.crashlytics.gradlePlugin) + compileOnly(libs.firebase.performance.gradlePlugin) + compileOnly(libs.kotlin.gradlePlugin) + compileOnly(libs.ksp.gradlePlugin) + compileOnly(libs.room.gradlePlugin) + implementation(libs.truth) +} + +tasks { + validatePlugins { + enableStricterValidation = true + failOnWarning = true + } +} + +gradlePlugin { + plugins { + register("androidApplicationCompose") { + id = "doko.android.application.compose" + implementationClass = "AndroidApplicationComposeConventionPlugin" + } + register("androidApplication") { + id = "doko.android.application" + implementationClass = "AndroidApplicationConventionPlugin" + } + register("androidLibraryCompose") { + id = "doko.android.library.compose" + implementationClass = "AndroidLibraryComposeConventionPlugin" + } + register("androidLibrary") { + id = "doko.android.library" + implementationClass = "AndroidLibraryConventionPlugin" + } + register("androidFeature") { + id = "doko.android.feature" + implementationClass = "AndroidFeatureConventionPlugin" + } + register("androidTest") { + id = "doko.android.test" + implementationClass = "AndroidTestConventionPlugin" + } + register("hilt") { + id = "doko.hilt" + implementationClass = "HiltConventionPlugin" + } + register("androidRoom") { + id = "doko.android.room" + implementationClass = "AndroidRoomConventionPlugin" + } + register("androidFirebase") { + id = "doko.android.application.firebase" + implementationClass = "AndroidApplicationFirebaseConventionPlugin" + } + register("androidLint") { + id = "doko.android.lint" + implementationClass = "AndroidLintConventionPlugin" + } + register("jvmLibrary") { + id = "doko.jvm.library" + implementationClass = "JvmLibraryConventionPlugin" + } + } +} diff --git a/buildLogic/convention/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt new file mode 100644 index 0000000..197199f --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt @@ -0,0 +1,19 @@ +import com.android.build.api.dsl.ApplicationExtension +import com.droidconke.doko.configureAndroidCompose +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.getByType + +class AndroidApplicationComposeConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + apply(plugin = "com.android.application") + apply(plugin = "org.jetbrains.kotlin.plugin.compose") + apply(plugin = "org.jetbrains.kotlin.android") + + val extension = extensions.getByType() + configureAndroidCompose(extension) + } + } +} diff --git a/buildLogic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt new file mode 100644 index 0000000..351d78c --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/AndroidApplicationConventionPlugin.kt @@ -0,0 +1,27 @@ +import com.android.build.api.dsl.ApplicationExtension +import com.droidconke.doko.configureKotlinAndroid +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure + + +class AndroidApplicationConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("com.android.application") + apply("org.jetbrains.kotlin.android") + apply("com.dropbox.dependency-guard") + apply("doko.android.lint") + } + + extensions.configure { + configureKotlinAndroid(this) + defaultConfig.targetSdk = 34 + defaultConfig.minSdk = 28 + @Suppress("UnstableApiUsage") + testOptions.animationsDisabled = true + } + } + } +} diff --git a/buildLogic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt new file mode 100644 index 0000000..1dea0c6 --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/AndroidApplicationFirebaseConventionPlugin.kt @@ -0,0 +1,38 @@ +import com.android.build.api.dsl.ApplicationExtension +import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension +import com.droidconke.doko.libs +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies + +class AndroidApplicationFirebaseConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("com.google.gms.google-services") + apply("com.google.firebase.firebase-perf") + apply("com.google.firebase.crashlytics") + } + + dependencies { + val bom = libs.findLibrary("firebase-bom").get() + add("implementation", platform(bom)) + "implementation"(libs.findLibrary("firebase.analytics").get()) + "implementation"(libs.findLibrary("firebase.performance").get()) + "implementation"(libs.findLibrary("firebase.crashlytics").get()) + } + + extensions.configure { + buildTypes.configureEach { + // Disable the Crashlytics mapping file upload. This feature should only be + // enabled if a Firebase backend is available and configured in + // google-services.json. + configure { + mappingFileUploadEnabled = false + } + } + } + } + } +} diff --git a/buildLogic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt new file mode 100644 index 0000000..a05e4c7 --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/AndroidFeatureConventionPlugin.kt @@ -0,0 +1,31 @@ +import com.android.build.gradle.LibraryExtension +import com.droidconke.doko.libs +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies + + +class AndroidFeatureConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + pluginManager.apply { + apply("doko.android.library") + apply("doko.hilt") + } + extensions.configure { + testOptions.animationsDisabled = true + } + + dependencies { + + add("implementation", libs.findLibrary("androidx.hilt.navigation.compose").get()) + add("implementation", libs.findLibrary("androidx.lifecycle.runtimeCompose").get()) + add("implementation", libs.findLibrary("androidx.lifecycle.viewModelCompose").get()) + add("implementation", libs.findLibrary("androidx.tracing.ktx").get()) + + add("androidTestImplementation", libs.findLibrary("androidx.lifecycle.runtimeTesting").get()) + } + } + } +} diff --git a/buildLogic/convention/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt new file mode 100644 index 0000000..21c0047 --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt @@ -0,0 +1,19 @@ +import com.android.build.gradle.LibraryExtension +import com.droidconke.doko.configureAndroidCompose +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.apply +import org.gradle.kotlin.dsl.getByType + + +class AndroidLibraryComposeConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + apply(plugin = "com.android.library") + apply(plugin = "org.jetbrains.kotlin.plugin.compose") + + val extension = extensions.getByType() + configureAndroidCompose(extension) + } + } +} diff --git a/buildLogic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt new file mode 100644 index 0000000..6f3b125 --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/AndroidLibraryConventionPlugin.kt @@ -0,0 +1,44 @@ +import com.android.build.api.variant.LibraryAndroidComponentsExtension +import com.android.build.gradle.LibraryExtension +import com.droidconke.doko.configureKotlinAndroid +import com.droidconke.doko.disableUnnecessaryAndroidTests +import com.droidconke.doko.libs +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.kotlin + + + +class AndroidLibraryConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("com.android.library") + apply("org.jetbrains.kotlin.android") + apply("doko.android.lint") + } + + extensions.configure { + configureKotlinAndroid(this) + defaultConfig.targetSdk = 34 + defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + testOptions.animationsDisabled = true + // The resource prefix is derived from the module name, + // so resources inside ":core:module1" must be prefixed with "core_module1_" + resourcePrefix = path + .split("""\W""".toRegex()).drop(1).distinct().joinToString(separator = "_").lowercase() + "_" + } + extensions.configure { + disableUnnecessaryAndroidTests(target) + } + dependencies { + add("androidTestImplementation", kotlin("test")) + add("testImplementation", kotlin("test")) + + add("implementation", libs.findLibrary("androidx.tracing.ktx").get()) + } + } + } +} diff --git a/buildLogic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt new file mode 100644 index 0000000..f62b43a --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/AndroidLintConventionPlugin.kt @@ -0,0 +1,32 @@ +import com.android.build.api.dsl.ApplicationExtension +import com.android.build.api.dsl.LibraryExtension +import com.android.build.api.dsl.Lint +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure + + +class AndroidLintConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + when { + pluginManager.hasPlugin("com.android.application") -> + configure { lint(Lint::configure) } + + pluginManager.hasPlugin("com.android.library") -> + configure { lint(Lint::configure) } + + else -> { + pluginManager.apply("com.android.lint") + configure(Lint::configure) + } + } + } + } +} + +private fun Lint.configure() { + xmlReport = true + checkDependencies = true +} + diff --git a/buildLogic/convention/src/main/kotlin/AndroidRoomConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/AndroidRoomConventionPlugin.kt new file mode 100644 index 0000000..8a12393 --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/AndroidRoomConventionPlugin.kt @@ -0,0 +1,34 @@ +import androidx.room.gradle.RoomExtension +import com.google.devtools.ksp.gradle.KspExtension +import com.droidconke.doko.libs +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies + + +class AndroidRoomConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + pluginManager.apply("androidx.room") + pluginManager.apply("com.google.devtools.ksp") + + extensions.configure { + arg("room.generateKotlin", "true") + } + + extensions.configure { + // The schemas directory contains a schema file for each version of the Room database. + // This is required to enable Room auto migrations. + // See https://developer.android.com/reference/kotlin/androidx/room/AutoMigration. + schemaDirectory("$projectDir/schemas") + } + + dependencies { + add("implementation", libs.findLibrary("room.runtime").get()) + add("implementation", libs.findLibrary("room.ktx").get()) + add("ksp", libs.findLibrary("room.compiler").get()) + } + } + } +} \ No newline at end of file diff --git a/buildLogic/convention/src/main/kotlin/AndroidTestConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/AndroidTestConventionPlugin.kt new file mode 100644 index 0000000..02112cd --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/AndroidTestConventionPlugin.kt @@ -0,0 +1,23 @@ +import com.android.build.gradle.TestExtension +import com.droidconke.doko.configureKotlinAndroid +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.configure + + +class AndroidTestConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("com.android.test") + apply("org.jetbrains.kotlin.android") + } + + extensions.configure { + configureKotlinAndroid(this) + defaultConfig.targetSdk = 34 + } + } + } + +} diff --git a/buildLogic/convention/src/main/kotlin/HiltConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/HiltConventionPlugin.kt new file mode 100644 index 0000000..4fe1a9e --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/HiltConventionPlugin.kt @@ -0,0 +1,26 @@ +import com.android.build.gradle.api.AndroidBasePlugin +import com.droidconke.doko.libs +import org.gradle.api.Plugin +import org.gradle.api.Project +import org.gradle.kotlin.dsl.dependencies + + +class HiltConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + pluginManager.apply("com.google.devtools.ksp") + dependencies { + add("ksp", libs.findLibrary("hilt.compiler").get()) + add("implementation", libs.findLibrary("hilt.core").get()) + } + + /** Add support for Android modules, based on [AndroidBasePlugin] */ + pluginManager.withPlugin("com.android.base") { + pluginManager.apply("dagger.hilt.android.plugin") + dependencies { + add("implementation", libs.findLibrary("hilt.android").get()) + } + } + } + } +} diff --git a/buildLogic/convention/src/main/kotlin/JVMLibraryConventionPlugin.kt b/buildLogic/convention/src/main/kotlin/JVMLibraryConventionPlugin.kt new file mode 100644 index 0000000..5f3c0fe --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/JVMLibraryConventionPlugin.kt @@ -0,0 +1,59 @@ +import com.droidconke.doko.configureKotlinJvm +import org.gradle.api.Plugin +import org.gradle.api.Project + +/** + * + * The `JvmLibraryConventionPlugin` class implements the `Plugin` interface in Gradle, + * allowing it to be applied to a Gradle project. This plugin is designed to configure JVM library + * projects with specific settings and dependencies. + * + * The `apply` method is overridden to define the plugin's behavior when it is applied to a project. + * Inside this method, the `with(target)` block is used to operate on the `Project` instance passed as the `target` parameter. + * + * ``` + * class JvmLibraryConventionPlugin : Plugin { + * override fun apply(target: Project) { + * with(target) { + * // Configuration code + * } + * } + * } + * ``` + * + * Within the `with(target)` block, the `pluginManager` is used to apply two plugins: + * `org.jetbrains.kotlin.jvm` for Kotlin JVM support and `grapla.android.lint` for linting. + * + * ``` + * with(pluginManager) { + * apply("org.jetbrains.kotlin.jvm") + * apply("grapla.android.lint") + * } + * ``` + * + * Finally, the `configureKotlinJvm` function is called to apply Kotlin-specific configurations to + * the JVM project. + * + * ``` + * configureKotlinJvm() + * ``` + * + * In summary, this plugin sets up a JVM library project with the necessary plugins and configurations, + * including Kotlin JVM support and linting. + * + * + * */ + + +class JvmLibraryConventionPlugin : Plugin { + override fun apply(target: Project) { + with(target) { + with(pluginManager) { + apply("org.jetbrains.kotlin.jvm") + apply("grapla.android.lint") + } + configureKotlinJvm() + } + } +} + diff --git a/buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidCompose.kt b/buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidCompose.kt new file mode 100644 index 0000000..9ab14ca --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidCompose.kt @@ -0,0 +1,54 @@ +package com.droidconke.doko + +import com.android.build.api.dsl.CommonExtension +import org.gradle.api.Project +import org.gradle.api.provider.Provider +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension + + +internal fun Project.configureAndroidCompose( + commonExtension: CommonExtension<*, *, *, *, *, *>, +) { + commonExtension.apply { + buildFeatures { + compose = true + } + + dependencies { + val bom = libs.findLibrary("androidx-compose-bom").get() + add("implementation", platform(bom)) + add("androidTestImplementation", platform(bom)) + add("implementation", libs.findLibrary("androidx-compose-ui-tooling-preview").get()) + add("debugImplementation", libs.findLibrary("androidx-compose-ui-tooling").get()) + } + + testOptions { + unitTests { + // For Robolectric + isIncludeAndroidResources = true + } + } + } + + extensions.configure { + fun Provider.onlyIfTrue() = flatMap { provider { it.takeIf(String::toBoolean) } } + + fun Provider<*>.relativeToRootProject(dir: String) = flatMap { + rootProject.layout.buildDirectory.dir(projectDir.toRelativeString(rootDir)) + }.map { it.dir(dir) } + + project.providers + .gradleProperty("enableComposeCompilerMetrics").onlyIfTrue() + .relativeToRootProject("compose-metrics") + .let(metricsDestination::set) + + project.providers + .gradleProperty("enableComposeCompilerReports").onlyIfTrue() + .relativeToRootProject("compose-reports") + .let(reportsDestination::set) + + stabilityConfigurationFile = rootProject.layout.projectDirectory.file("compose_compiler_config.conf") + } +} diff --git a/buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidIntsrumentedTests.kt b/buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidIntsrumentedTests.kt new file mode 100644 index 0000000..923f102 --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidIntsrumentedTests.kt @@ -0,0 +1,11 @@ +package com.droidconke.doko + +import com.android.build.api.variant.LibraryAndroidComponentsExtension +import org.gradle.api.Project + +internal fun LibraryAndroidComponentsExtension.disableUnnecessaryAndroidTests( + project: Project, +) = beforeVariants { + it.enableAndroidTest = it.enableAndroidTest + && project.projectDir.resolve("src/androidTest").exists() +} diff --git a/buildLogic/convention/src/main/kotlin/com/droidconke/doko/KotlinAndroid.kt b/buildLogic/convention/src/main/kotlin/com/droidconke/doko/KotlinAndroid.kt new file mode 100644 index 0000000..eff79fd --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/com/droidconke/doko/KotlinAndroid.kt @@ -0,0 +1,68 @@ +package com.droidconke.doko + +import com.android.build.api.dsl.CommonExtension +import org.gradle.api.JavaVersion +import org.gradle.api.Project +import org.gradle.api.plugins.JavaPluginExtension +import org.gradle.kotlin.dsl.assign +import org.gradle.kotlin.dsl.configure +import org.gradle.kotlin.dsl.dependencies +import org.gradle.kotlin.dsl.provideDelegate +import org.jetbrains.kotlin.gradle.dsl.JvmTarget +import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension + +internal fun Project.configureKotlinAndroid(commonExtension: CommonExtension<*, *, *, *, *, *>) { + commonExtension.apply { + compileSdk = 34 + + defaultConfig { + minSdk = 26 + } + + compileOptions { + // Up to Java 11 APIs are available through desugaring + // https://developer.android.com/studio/write/java11-minimal-support-table + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 + isCoreLibraryDesugaringEnabled = true + } + } + + configureKotlin() + + dependencies { + add("coreLibraryDesugaring", libs.findLibrary("android.desugarJdkLibs").get()) + } +} + +internal fun Project.configureKotlinJvm() { + extensions.configure { + // Up to Java 11 APIs are available through desugaring + // https://developer.android.com/studio/write/java11-minimal-support-table + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 + } + + configureKotlin() +} + +private inline fun Project.configureKotlin() = + configure { + // Treat all Kotlin warnings as errors (disabled by default) + // Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties + val warningsAsErrors: String? by project + when (this) { + is KotlinAndroidProjectExtension -> compilerOptions + is KotlinJvmProjectExtension -> compilerOptions + else -> TODO("Unsupported project extension $this ${T::class}") + }.apply { + jvmTarget = JvmTarget.JVM_21 + allWarningsAsErrors = warningsAsErrors.toBoolean() + freeCompilerArgs.add( + // Enable experimental coroutines APIs, including Flow + "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + ) + } + } diff --git a/buildLogic/convention/src/main/kotlin/com/droidconke/doko/ProjectExtensions.kt b/buildLogic/convention/src/main/kotlin/com/droidconke/doko/ProjectExtensions.kt new file mode 100644 index 0000000..d70ddb4 --- /dev/null +++ b/buildLogic/convention/src/main/kotlin/com/droidconke/doko/ProjectExtensions.kt @@ -0,0 +1,10 @@ +package com.droidconke.doko + +import org.gradle.api.Project +import org.gradle.api.artifacts.VersionCatalog +import org.gradle.api.artifacts.VersionCatalogsExtension +import org.gradle.kotlin.dsl.getByType + + +val Project.libs + get(): VersionCatalog = extensions.getByType().named("libs") diff --git a/compose_compiler_config.conf b/compose_compiler_config.conf new file mode 100644 index 0000000..40da0eb --- /dev/null +++ b/compose_compiler_config.conf @@ -0,0 +1,11 @@ +// This file contains classes (with possible wildcards) that the Compose Compiler will treat as stable. +// It allows us to define classes that our not part of our codebase without wrapping them in a stable class. +// For more information, check https://developer.android.com/jetpack/compose/performance/stability/fix#configuration-file + +// We always use immutable classes for our data model, to avoid running the Compose compiler +// in the module we declare it to be stable here. + + +// Java standard library classes +java.time.ZoneId +java.time.ZoneOffset From 3c62b38c4a98061e4fc9bd7d21777f14189668bc Mon Sep 17 00:00:00 2001 From: "./root" Date: Sat, 19 Oct 2024 11:15:01 +0200 Subject: [PATCH 2/4] add new modules --- app/build.gradle.kts | 71 -------- .../com/droidconke/doko/AndroidCompose.kt | 1 + {app => ddsdemo}/.gitignore | 0 ddsdemo/build.gradle.kts | 59 ++++++ ddsdemo/proguard-rules.pro | 21 +++ .../ddsdemo/ExampleInstrumentedTest.kt | 24 +++ ddsdemo/src/main/AndroidManifest.xml | 24 +++ .../com/droidconke/ddsdemo/MainActivity.kt | 47 +++++ .../com/droidconke/ddsdemo/ui/theme/Color.kt | 11 ++ .../com/droidconke/ddsdemo/ui/theme/Theme.kt | 58 ++++++ .../com/droidconke/ddsdemo/ui/theme/Type.kt | 34 ++++ .../res/drawable/ic_launcher_background.xml | 0 .../res/drawable}/ic_launcher_foreground.xml | 0 .../main/res/mipmap-anydpi}/ic_launcher.xml | 0 .../res/mipmap-anydpi/ic_launcher_round.xml | 6 + .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin .../res/mipmap-hdpi/ic_launcher_round.webp | Bin .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin .../res/mipmap-mdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin .../src/main/res/values/colors.xml | 0 ddsdemo/src/main/res/values/strings.xml | 3 + ddsdemo/src/main/res/values/themes.xml | 5 + .../com/droidconke/ddsdemo/ExampleUnitTest.kt | 17 ++ docs/Ideas.md | 7 +- doko/.gitignore | 1 + doko/build.gradle.kts | 80 +++++++++ {app => doko}/proguard-rules.pro | 0 .../dckeswag/ExampleInstrumentedTest.kt | 0 {app => doko}/src/main/AndroidManifest.xml | 0 .../com/droidconke/dckeswag/MainActivity.kt | 0 .../com/droidconke/dckeswag/ui/theme/Color.kt | 0 .../com/droidconke/dckeswag/ui/theme/Shape.kt | 0 .../com/droidconke/dckeswag/ui/theme/Theme.kt | 0 .../com/droidconke/dckeswag/ui/theme/Type.kt | 0 .../drawable-v24/ic_launcher_foreground.xml | 30 ++++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++++ .../res/mipmap-anydpi-v26/ic_launcher.xml | 0 .../mipmap-anydpi-v26/ic_launcher_round.xml | 0 .../res/mipmap-anydpi-v33/ic_launcher.xml | 6 + .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes doko/src/main/res/values/colors.xml | 10 ++ {app => doko}/src/main/res/values/strings.xml | 0 {app => doko}/src/main/res/values/themes.xml | 0 .../src/main/res/xml/backup_rules.xml | 0 .../main/res/xml/data_extraction_rules.xml | 0 .../droidconke/dckeswag/ExampleUnitTest.kt | 0 dokoadmin/.gitignore | 1 + dokoadmin/build.gradle.kts | 59 ++++++ dokoadmin/proguard-rules.pro | 21 +++ .../dokoadmin/ExampleInstrumentedTest.kt | 24 +++ dokoadmin/src/main/AndroidManifest.xml | 24 +++ .../com/droidonke/dokoadmin/MainActivity.kt | 47 +++++ .../com/droidonke/dokoadmin/ui/theme/Color.kt | 11 ++ .../com/droidonke/dokoadmin/ui/theme/Theme.kt | 58 ++++++ .../com/droidonke/dokoadmin/ui/theme/Type.kt | 34 ++++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++++ .../res/drawable/ic_launcher_foreground.xml | 30 ++++ .../main/res/mipmap-anydpi/ic_launcher.xml | 6 + .../res/mipmap-anydpi/ic_launcher_round.xml | 6 + .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes dokoadmin/src/main/res/values/colors.xml | 10 ++ dokoadmin/src/main/res/values/strings.xml | 3 + dokoadmin/src/main/res/values/themes.xml | 5 + .../droidonke/dokoadmin/ExampleUnitTest.kt | 17 ++ dokomerchant/.gitignore | 1 + dokomerchant/build.gradle.kts | 59 ++++++ dokomerchant/proguard-rules.pro | 21 +++ .../dokomerchant/ExampleInstrumentedTest.kt | 24 +++ dokomerchant/src/main/AndroidManifest.xml | 24 +++ .../droidconke/dokomerchant/MainActivity.kt | 47 +++++ .../droidconke/dokomerchant/ui/theme/Color.kt | 11 ++ .../droidconke/dokomerchant/ui/theme/Theme.kt | 58 ++++++ .../droidconke/dokomerchant/ui/theme/Type.kt | 34 ++++ .../res/drawable/ic_launcher_background.xml | 170 ++++++++++++++++++ .../res/drawable/ic_launcher_foreground.xml | 30 ++++ .../main/res/mipmap-anydpi/ic_launcher.xml | 6 + .../res/mipmap-anydpi/ic_launcher_round.xml | 6 + .../src/main/res/mipmap-hdpi/ic_launcher.webp | Bin 0 -> 1404 bytes .../res/mipmap-hdpi/ic_launcher_round.webp | Bin 0 -> 2898 bytes .../src/main/res/mipmap-mdpi/ic_launcher.webp | Bin 0 -> 982 bytes .../res/mipmap-mdpi/ic_launcher_round.webp | Bin 0 -> 1772 bytes .../main/res/mipmap-xhdpi/ic_launcher.webp | Bin 0 -> 1900 bytes .../res/mipmap-xhdpi/ic_launcher_round.webp | Bin 0 -> 3918 bytes .../main/res/mipmap-xxhdpi/ic_launcher.webp | Bin 0 -> 2884 bytes .../res/mipmap-xxhdpi/ic_launcher_round.webp | Bin 0 -> 5914 bytes .../main/res/mipmap-xxxhdpi/ic_launcher.webp | Bin 0 -> 3844 bytes .../res/mipmap-xxxhdpi/ic_launcher_round.webp | Bin 0 -> 7778 bytes dokomerchant/src/main/res/values/colors.xml | 10 ++ dokomerchant/src/main/res/values/strings.xml | 3 + dokomerchant/src/main/res/values/themes.xml | 5 + .../dokomerchant/ExampleUnitTest.kt | 17 ++ gradle/libs.versions.toml | 2 +- settings.gradle.kts | 5 +- 117 files changed, 1668 insertions(+), 76 deletions(-) delete mode 100644 app/build.gradle.kts rename {app => ddsdemo}/.gitignore (100%) create mode 100644 ddsdemo/build.gradle.kts create mode 100644 ddsdemo/proguard-rules.pro create mode 100644 ddsdemo/src/androidTest/java/com/droidconke/ddsdemo/ExampleInstrumentedTest.kt create mode 100644 ddsdemo/src/main/AndroidManifest.xml create mode 100644 ddsdemo/src/main/java/com/droidconke/ddsdemo/MainActivity.kt create mode 100644 ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Color.kt create mode 100644 ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Theme.kt create mode 100644 ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Type.kt rename {app => ddsdemo}/src/main/res/drawable/ic_launcher_background.xml (100%) rename {app/src/main/res/drawable-v24 => ddsdemo/src/main/res/drawable}/ic_launcher_foreground.xml (100%) rename {app/src/main/res/mipmap-anydpi-v33 => ddsdemo/src/main/res/mipmap-anydpi}/ic_launcher.xml (100%) create mode 100644 ddsdemo/src/main/res/mipmap-anydpi/ic_launcher_round.xml rename {app => ddsdemo}/src/main/res/mipmap-hdpi/ic_launcher.webp (100%) rename {app => ddsdemo}/src/main/res/mipmap-hdpi/ic_launcher_round.webp (100%) rename {app => ddsdemo}/src/main/res/mipmap-mdpi/ic_launcher.webp (100%) rename {app => ddsdemo}/src/main/res/mipmap-mdpi/ic_launcher_round.webp (100%) rename {app => ddsdemo}/src/main/res/mipmap-xhdpi/ic_launcher.webp (100%) rename {app => ddsdemo}/src/main/res/mipmap-xhdpi/ic_launcher_round.webp (100%) rename {app => ddsdemo}/src/main/res/mipmap-xxhdpi/ic_launcher.webp (100%) rename {app => ddsdemo}/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp (100%) rename {app => ddsdemo}/src/main/res/mipmap-xxxhdpi/ic_launcher.webp (100%) rename {app => ddsdemo}/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp (100%) rename {app => ddsdemo}/src/main/res/values/colors.xml (100%) create mode 100644 ddsdemo/src/main/res/values/strings.xml create mode 100644 ddsdemo/src/main/res/values/themes.xml create mode 100644 ddsdemo/src/test/java/com/droidconke/ddsdemo/ExampleUnitTest.kt create mode 100644 doko/.gitignore create mode 100644 doko/build.gradle.kts rename {app => doko}/proguard-rules.pro (100%) rename {app => doko}/src/androidTest/java/com/droidconke/dckeswag/ExampleInstrumentedTest.kt (100%) rename {app => doko}/src/main/AndroidManifest.xml (100%) rename {app => doko}/src/main/java/com/droidconke/dckeswag/MainActivity.kt (100%) rename {app => doko}/src/main/java/com/droidconke/dckeswag/ui/theme/Color.kt (100%) rename {app => doko}/src/main/java/com/droidconke/dckeswag/ui/theme/Shape.kt (100%) rename {app => doko}/src/main/java/com/droidconke/dckeswag/ui/theme/Theme.kt (100%) rename {app => doko}/src/main/java/com/droidconke/dckeswag/ui/theme/Type.kt (100%) create mode 100644 doko/src/main/res/drawable-v24/ic_launcher_foreground.xml create mode 100644 doko/src/main/res/drawable/ic_launcher_background.xml rename {app => doko}/src/main/res/mipmap-anydpi-v26/ic_launcher.xml (100%) rename {app => doko}/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml (100%) create mode 100644 doko/src/main/res/mipmap-anydpi-v33/ic_launcher.xml create mode 100644 doko/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 doko/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 doko/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 doko/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 doko/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 doko/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 doko/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 doko/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 doko/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 doko/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 doko/src/main/res/values/colors.xml rename {app => doko}/src/main/res/values/strings.xml (100%) rename {app => doko}/src/main/res/values/themes.xml (100%) rename {app => doko}/src/main/res/xml/backup_rules.xml (100%) rename {app => doko}/src/main/res/xml/data_extraction_rules.xml (100%) rename {app => doko}/src/test/java/com/droidconke/dckeswag/ExampleUnitTest.kt (100%) create mode 100644 dokoadmin/.gitignore create mode 100644 dokoadmin/build.gradle.kts create mode 100644 dokoadmin/proguard-rules.pro create mode 100644 dokoadmin/src/androidTest/java/com/droidonke/dokoadmin/ExampleInstrumentedTest.kt create mode 100644 dokoadmin/src/main/AndroidManifest.xml create mode 100644 dokoadmin/src/main/java/com/droidonke/dokoadmin/MainActivity.kt create mode 100644 dokoadmin/src/main/java/com/droidonke/dokoadmin/ui/theme/Color.kt create mode 100644 dokoadmin/src/main/java/com/droidonke/dokoadmin/ui/theme/Theme.kt create mode 100644 dokoadmin/src/main/java/com/droidonke/dokoadmin/ui/theme/Type.kt create mode 100644 dokoadmin/src/main/res/drawable/ic_launcher_background.xml create mode 100644 dokoadmin/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 dokoadmin/src/main/res/mipmap-anydpi/ic_launcher.xml create mode 100644 dokoadmin/src/main/res/mipmap-anydpi/ic_launcher_round.xml create mode 100644 dokoadmin/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 dokoadmin/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 dokoadmin/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 dokoadmin/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 dokoadmin/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 dokoadmin/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 dokoadmin/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 dokoadmin/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 dokoadmin/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 dokoadmin/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 dokoadmin/src/main/res/values/colors.xml create mode 100644 dokoadmin/src/main/res/values/strings.xml create mode 100644 dokoadmin/src/main/res/values/themes.xml create mode 100644 dokoadmin/src/test/java/com/droidonke/dokoadmin/ExampleUnitTest.kt create mode 100644 dokomerchant/.gitignore create mode 100644 dokomerchant/build.gradle.kts create mode 100644 dokomerchant/proguard-rules.pro create mode 100644 dokomerchant/src/androidTest/java/com/droidconke/dokomerchant/ExampleInstrumentedTest.kt create mode 100644 dokomerchant/src/main/AndroidManifest.xml create mode 100644 dokomerchant/src/main/java/com/droidconke/dokomerchant/MainActivity.kt create mode 100644 dokomerchant/src/main/java/com/droidconke/dokomerchant/ui/theme/Color.kt create mode 100644 dokomerchant/src/main/java/com/droidconke/dokomerchant/ui/theme/Theme.kt create mode 100644 dokomerchant/src/main/java/com/droidconke/dokomerchant/ui/theme/Type.kt create mode 100644 dokomerchant/src/main/res/drawable/ic_launcher_background.xml create mode 100644 dokomerchant/src/main/res/drawable/ic_launcher_foreground.xml create mode 100644 dokomerchant/src/main/res/mipmap-anydpi/ic_launcher.xml create mode 100644 dokomerchant/src/main/res/mipmap-anydpi/ic_launcher_round.xml create mode 100644 dokomerchant/src/main/res/mipmap-hdpi/ic_launcher.webp create mode 100644 dokomerchant/src/main/res/mipmap-hdpi/ic_launcher_round.webp create mode 100644 dokomerchant/src/main/res/mipmap-mdpi/ic_launcher.webp create mode 100644 dokomerchant/src/main/res/mipmap-mdpi/ic_launcher_round.webp create mode 100644 dokomerchant/src/main/res/mipmap-xhdpi/ic_launcher.webp create mode 100644 dokomerchant/src/main/res/mipmap-xhdpi/ic_launcher_round.webp create mode 100644 dokomerchant/src/main/res/mipmap-xxhdpi/ic_launcher.webp create mode 100644 dokomerchant/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp create mode 100644 dokomerchant/src/main/res/mipmap-xxxhdpi/ic_launcher.webp create mode 100644 dokomerchant/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp create mode 100644 dokomerchant/src/main/res/values/colors.xml create mode 100644 dokomerchant/src/main/res/values/strings.xml create mode 100644 dokomerchant/src/main/res/values/themes.xml create mode 100644 dokomerchant/src/test/java/com/droidconke/dokomerchant/ExampleUnitTest.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts deleted file mode 100644 index 62c33a4..0000000 --- a/app/build.gradle.kts +++ /dev/null @@ -1,71 +0,0 @@ -plugins { - id("com.android.application") - id("org.jetbrains.kotlin.android") -} - -android { - namespace = "com.droidconke.doko" - compileSdk = 33 - - defaultConfig { - applicationId = "com.droidconke.doko" - minSdk = 26 - targetSdk = 33 - versionCode = 1 - versionName = "1.0" - - testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" - vectorDrawables { - useSupportLibrary = true - } - } - - buildTypes { - getByName("release") { - isMinifyEnabled = false - proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") - } - } - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_11 - targetCompatibility = JavaVersion.VERSION_11 - } - - kotlinOptions { - jvmTarget = "11" - } - - buildFeatures { - compose = true - } - - composeOptions { - kotlinCompilerExtensionVersion = "1.5.15" - } - - packagingOptions { - resources { - excludes += "/META-INF/{AL2.0,LGPL2.1}" - } - } -} - -dependencies { - - implementation("androidx.core:core-ktx:1.13.1") - implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.6") - - implementation("androidx.activity:activity-compose:1.9.3") - implementation("androidx.compose.ui:ui:1.7.4") - implementation("androidx.compose.ui:ui-tooling-preview:1.7.4") - implementation("androidx.compose.material:material:1.7.4") - debugImplementation("androidx.compose.ui:ui-tooling:1.7.4") - debugImplementation("androidx.compose.ui:ui-test-manifest:1.7.4") - - testImplementation("junit:junit:4.13.2") - - androidTestImplementation("androidx.test.ext:junit:1.2.1") - androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") - androidTestImplementation("androidx.compose.ui:ui-test-junit4:1.7.4") -} diff --git a/buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidCompose.kt b/buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidCompose.kt index 9ab14ca..43b5dfd 100644 --- a/buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidCompose.kt +++ b/buildLogic/convention/src/main/kotlin/com/droidconke/doko/AndroidCompose.kt @@ -3,6 +3,7 @@ package com.droidconke.doko import com.android.build.api.dsl.CommonExtension import org.gradle.api.Project import org.gradle.api.provider.Provider +import org.gradle.kotlin.dsl.assign import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.dependencies import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension diff --git a/app/.gitignore b/ddsdemo/.gitignore similarity index 100% rename from app/.gitignore rename to ddsdemo/.gitignore diff --git a/ddsdemo/build.gradle.kts b/ddsdemo/build.gradle.kts new file mode 100644 index 0000000..de4c3ee --- /dev/null +++ b/ddsdemo/build.gradle.kts @@ -0,0 +1,59 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.jetbrains.kotlin.android) + alias(libs.plugins.compose.compiler) +} + +android { + namespace = "com.droidconke.ddsdemo" + compileSdk = 34 + + defaultConfig { + applicationId = "com.droidconke.ddsdemo" + minSdk = 28 + targetSdk = 34 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + isMinifyEnabled = false + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } + buildFeatures { + compose = true + } +} + +dependencies { + + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.lifecycle.runtime.ktx) + implementation(libs.androidx.activity.compose) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + implementation(libs.androidx.ui.graphics) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.compose.material3) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) + androidTestImplementation(platform(libs.androidx.compose.bom)) + androidTestImplementation(libs.androidx.ui.test.junit4) + debugImplementation(libs.androidx.ui.tooling) + debugImplementation(libs.androidx.ui.test.manifest) +} \ No newline at end of file diff --git a/ddsdemo/proguard-rules.pro b/ddsdemo/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/ddsdemo/proguard-rules.pro @@ -0,0 +1,21 @@ +# 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 \ No newline at end of file diff --git a/ddsdemo/src/androidTest/java/com/droidconke/ddsdemo/ExampleInstrumentedTest.kt b/ddsdemo/src/androidTest/java/com/droidconke/ddsdemo/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..f1b755b --- /dev/null +++ b/ddsdemo/src/androidTest/java/com/droidconke/ddsdemo/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.droidconke.ddsdemo + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.droidconke.ddsdemo", appContext.packageName) + } +} \ No newline at end of file diff --git a/ddsdemo/src/main/AndroidManifest.xml b/ddsdemo/src/main/AndroidManifest.xml new file mode 100644 index 0000000..6e34c8c --- /dev/null +++ b/ddsdemo/src/main/AndroidManifest.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ddsdemo/src/main/java/com/droidconke/ddsdemo/MainActivity.kt b/ddsdemo/src/main/java/com/droidconke/ddsdemo/MainActivity.kt new file mode 100644 index 0000000..e2ea485 --- /dev/null +++ b/ddsdemo/src/main/java/com/droidconke/ddsdemo/MainActivity.kt @@ -0,0 +1,47 @@ +package com.droidconke.ddsdemo + +import android.os.Bundle +import androidx.activity.ComponentActivity +import androidx.activity.compose.setContent +import androidx.activity.enableEdgeToEdge +import androidx.compose.foundation.layout.fillMaxSize +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.ui.Modifier +import androidx.compose.ui.tooling.preview.Preview +import com.droidconke.ddsdemo.ui.theme.DokoTheme + +class MainActivity : ComponentActivity() { + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContent { + DokoTheme { + Scaffold(modifier = Modifier.fillMaxSize()) { innerPadding -> + Greeting( + name = "Android", + modifier = Modifier.padding(innerPadding) + ) + } + } + } + } +} + +@Composable +fun Greeting(name: String, modifier: Modifier = Modifier) { + Text( + text = "Hello $name!", + modifier = modifier + ) +} + +@Preview(showBackground = true) +@Composable +fun GreetingPreview() { + DokoTheme { + Greeting("Android") + } +} \ No newline at end of file diff --git a/ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Color.kt b/ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Color.kt new file mode 100644 index 0000000..22a40ab --- /dev/null +++ b/ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Color.kt @@ -0,0 +1,11 @@ +package com.droidconke.ddsdemo.ui.theme + +import androidx.compose.ui.graphics.Color + +val Purple80 = Color(0xFFD0BCFF) +val PurpleGrey80 = Color(0xFFCCC2DC) +val Pink80 = Color(0xFFEFB8C8) + +val Purple40 = Color(0xFF6650a4) +val PurpleGrey40 = Color(0xFF625b71) +val Pink40 = Color(0xFF7D5260) \ No newline at end of file diff --git a/ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Theme.kt b/ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Theme.kt new file mode 100644 index 0000000..602e395 --- /dev/null +++ b/ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Theme.kt @@ -0,0 +1,58 @@ +package com.droidconke.ddsdemo.ui.theme + +import android.app.Activity +import android.os.Build +import androidx.compose.foundation.isSystemInDarkTheme +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.darkColorScheme +import androidx.compose.material3.dynamicDarkColorScheme +import androidx.compose.material3.dynamicLightColorScheme +import androidx.compose.material3.lightColorScheme +import androidx.compose.runtime.Composable +import androidx.compose.ui.platform.LocalContext + +private val DarkColorScheme = darkColorScheme( + primary = Purple80, + secondary = PurpleGrey80, + tertiary = Pink80 +) + +private val LightColorScheme = lightColorScheme( + primary = Purple40, + secondary = PurpleGrey40, + tertiary = Pink40 + + /* Other default colors to override + background = Color(0xFFFFFBFE), + surface = Color(0xFFFFFBFE), + onPrimary = Color.White, + onSecondary = Color.White, + onTertiary = Color.White, + onBackground = Color(0xFF1C1B1F), + onSurface = Color(0xFF1C1B1F), + */ +) + +@Composable +fun DokoTheme( + darkTheme: Boolean = isSystemInDarkTheme(), + // Dynamic color is available on Android 12+ + dynamicColor: Boolean = true, + content: @Composable () -> Unit +) { + val colorScheme = when { + dynamicColor && Build.VERSION.SDK_INT >= Build.VERSION_CODES.S -> { + val context = LocalContext.current + if (darkTheme) dynamicDarkColorScheme(context) else dynamicLightColorScheme(context) + } + + darkTheme -> DarkColorScheme + else -> LightColorScheme + } + + MaterialTheme( + colorScheme = colorScheme, + typography = Typography, + content = content + ) +} \ No newline at end of file diff --git a/ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Type.kt b/ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Type.kt new file mode 100644 index 0000000..0e96ad2 --- /dev/null +++ b/ddsdemo/src/main/java/com/droidconke/ddsdemo/ui/theme/Type.kt @@ -0,0 +1,34 @@ +package com.droidconke.ddsdemo.ui.theme + +import androidx.compose.material3.Typography +import androidx.compose.ui.text.TextStyle +import androidx.compose.ui.text.font.FontFamily +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.unit.sp + +// Set of Material typography styles to start with +val Typography = Typography( + bodyLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 16.sp, + lineHeight = 24.sp, + letterSpacing = 0.5.sp + ) + /* Other default text styles to override + titleLarge = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Normal, + fontSize = 22.sp, + lineHeight = 28.sp, + letterSpacing = 0.sp + ), + labelSmall = TextStyle( + fontFamily = FontFamily.Default, + fontWeight = FontWeight.Medium, + fontSize = 11.sp, + lineHeight = 16.sp, + letterSpacing = 0.5.sp + ) + */ +) \ No newline at end of file diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/ddsdemo/src/main/res/drawable/ic_launcher_background.xml similarity index 100% rename from app/src/main/res/drawable/ic_launcher_background.xml rename to ddsdemo/src/main/res/drawable/ic_launcher_background.xml diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/ddsdemo/src/main/res/drawable/ic_launcher_foreground.xml similarity index 100% rename from app/src/main/res/drawable-v24/ic_launcher_foreground.xml rename to ddsdemo/src/main/res/drawable/ic_launcher_foreground.xml diff --git a/app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml b/ddsdemo/src/main/res/mipmap-anydpi/ic_launcher.xml similarity index 100% rename from app/src/main/res/mipmap-anydpi-v33/ic_launcher.xml rename to ddsdemo/src/main/res/mipmap-anydpi/ic_launcher.xml diff --git a/ddsdemo/src/main/res/mipmap-anydpi/ic_launcher_round.xml b/ddsdemo/src/main/res/mipmap-anydpi/ic_launcher_round.xml new file mode 100644 index 0000000..6f3b755 --- /dev/null +++ b/ddsdemo/src/main/res/mipmap-anydpi/ic_launcher_round.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.webp b/ddsdemo/src/main/res/mipmap-hdpi/ic_launcher.webp similarity index 100% rename from app/src/main/res/mipmap-hdpi/ic_launcher.webp rename to ddsdemo/src/main/res/mipmap-hdpi/ic_launcher.webp diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp b/ddsdemo/src/main/res/mipmap-hdpi/ic_launcher_round.webp similarity index 100% rename from app/src/main/res/mipmap-hdpi/ic_launcher_round.webp rename to ddsdemo/src/main/res/mipmap-hdpi/ic_launcher_round.webp diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.webp b/ddsdemo/src/main/res/mipmap-mdpi/ic_launcher.webp similarity index 100% rename from app/src/main/res/mipmap-mdpi/ic_launcher.webp rename to ddsdemo/src/main/res/mipmap-mdpi/ic_launcher.webp diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp b/ddsdemo/src/main/res/mipmap-mdpi/ic_launcher_round.webp similarity index 100% rename from app/src/main/res/mipmap-mdpi/ic_launcher_round.webp rename to ddsdemo/src/main/res/mipmap-mdpi/ic_launcher_round.webp diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.webp b/ddsdemo/src/main/res/mipmap-xhdpi/ic_launcher.webp similarity index 100% rename from app/src/main/res/mipmap-xhdpi/ic_launcher.webp rename to ddsdemo/src/main/res/mipmap-xhdpi/ic_launcher.webp diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp b/ddsdemo/src/main/res/mipmap-xhdpi/ic_launcher_round.webp similarity index 100% rename from app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp rename to ddsdemo/src/main/res/mipmap-xhdpi/ic_launcher_round.webp diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp b/ddsdemo/src/main/res/mipmap-xxhdpi/ic_launcher.webp similarity index 100% rename from app/src/main/res/mipmap-xxhdpi/ic_launcher.webp rename to ddsdemo/src/main/res/mipmap-xxhdpi/ic_launcher.webp diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp b/ddsdemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp similarity index 100% rename from app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp rename to ddsdemo/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp b/ddsdemo/src/main/res/mipmap-xxxhdpi/ic_launcher.webp similarity index 100% rename from app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp rename to ddsdemo/src/main/res/mipmap-xxxhdpi/ic_launcher.webp diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp b/ddsdemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp similarity index 100% rename from app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp rename to ddsdemo/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp diff --git a/app/src/main/res/values/colors.xml b/ddsdemo/src/main/res/values/colors.xml similarity index 100% rename from app/src/main/res/values/colors.xml rename to ddsdemo/src/main/res/values/colors.xml diff --git a/ddsdemo/src/main/res/values/strings.xml b/ddsdemo/src/main/res/values/strings.xml new file mode 100644 index 0000000..7da2f15 --- /dev/null +++ b/ddsdemo/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + ddsdemo + \ No newline at end of file diff --git a/ddsdemo/src/main/res/values/themes.xml b/ddsdemo/src/main/res/values/themes.xml new file mode 100644 index 0000000..8d7fdb6 --- /dev/null +++ b/ddsdemo/src/main/res/values/themes.xml @@ -0,0 +1,5 @@ + + + +