From 04a6587289936f5c1ed5935d9e0bafc1460989d4 Mon Sep 17 00:00:00 2001 From: Art Pinch Date: Fri, 8 Dec 2023 20:41:06 +0300 Subject: [PATCH] Update dependencies & Move build logic to convention plugins --- .github/workflows/build_debug.yml | 4 +- .github/workflows/release.yml | 6 +- .github/workflows/static_analysis.yml | 6 +- .github/workflows/unit_test.yml | 4 +- app/build.gradle.kts | 18 +- build.gradle.kts | 15 +- buildSrc/build.gradle.kts | 19 +- buildSrc/settings.gradle.kts | 3 +- .../kotlin/convention.android.base.gradle.kts | 175 ++++++++++ .../main/kotlin/convention.android.gradle.kts | 7 + .../main/kotlin/convention.dagger.gradle.kts | 29 ++ .../main/kotlin/convention.feature.gradle.kts | 35 ++ .../src/main/kotlin/convention.kmp.gradle.kts | 81 +++++ .../main/kotlin/ru/art2000/modules/modules.kt | 317 ------------------ calculator/build.gradle.kts | 13 +- .../db/model/HistoryDatabaseItem.kt | 6 +- .../calculator/di/CalculatorModule.kt | 12 +- .../calculator/view/LexemeListAdapter.kt | 3 + common/build.gradle.kts | 18 +- .../calculator/common/view/AppActivity.kt | 1 - currency/build.gradle.kts | 15 +- .../calculator/currency/di/CurrencyModule.kt | 8 +- {extensions => ext}/.gitignore | 0 {extensions => ext}/build.gradle.kts | 11 +- .../activities/AutoThemeActivity.kt | 0 .../extensions/activities/DayNightActivity.kt | 0 .../extensions/activities/EdgeToEdge.kt | 0 .../extensions/activities/arguments.kt | 0 .../ru/art2000/extensions/arch/lifecycles.kt | 0 .../ru/art2000/extensions/arch/viewmodels.kt | 0 .../extensions/collections/ArrayLiveList.kt | 0 .../collections/LifecycleObserverWrapper.kt | 0 .../extensions/collections/LiveHashMap.kt | 0 .../extensions/collections/LiveList.kt | 0 .../art2000/extensions/collections/LiveMap.kt | 0 .../extensions/collections/LiveObservable.kt | 0 .../collections/LiveObserverWrapper.kt | 0 .../extensions/collections/MutableLiveMap.kt | 0 .../collections/PermanentObserverWrapper.kt | 0 .../ru/art2000/extensions/collections/diff.kt | 0 .../fragments/CommonReplaceableFragment.kt | 0 .../fragments/ExtendedPreferenceFragment.kt | 0 .../PreferenceReplaceableFragment.kt | 0 .../fragments/ReplaceableFragmentHelper.kt | 0 .../fragments/ReplaceableFragments.kt | 0 .../extensions/fragments/ReplaceableItems.kt | 0 .../extensions/net/TLSSocketFactory.kt | 0 .../art2000/extensions/net/trustManagers.kt | 0 .../preferences/ListenerDelegate.kt | 0 .../preferences/Material3SwitchPreference.kt | 0 .../MaterialTimePickerPreference.kt | 0 .../preferences/MyDropDownPreference.kt | 0 .../preferences/SharedPreferences.kt | 0 .../preferences/ThemeSettingsHolder.kt | 0 .../preferences/TimePickerPreference.kt | 0 .../preferences/TimePickerPreferenceDialog.kt | 0 .../kotlin/ru/art2000/extensions/resources.kt | 0 .../extensions/views/ColoringToolbar.kt | 0 .../extensions/views/CustomInputEditText.kt | 0 .../ru/art2000/extensions/views/Displaying.kt | 0 .../FloatingActionButtonScrollingBehaviour.kt | 0 .../views/HorizontalScrollViewCompat.kt | 0 .../views/MyFragmentStateAdapter.kt | 0 .../extensions/views/MyTabLayoutMediator.kt | 0 .../ru/art2000/extensions/views/Paging.kt | 0 .../extensions/views/RecyclerWithEmptyView.kt | 0 .../views/ReplaceableNavigationView.kt | 0 .../extensions/views/SimpleTextWatcher.kt | 0 .../ru/art2000/extensions/views/Views.kt | 0 .../ru/art2000/extensions/views/Windows.kt | 0 .../material3_switch_preference_widget.xml | 0 .../collections/ArrayLiveListTest.kt | 0 .../extensions/collections/Collections.kt | 0 .../extensions/collections/DiffComparable.kt | 0 .../collections/ExtendedMutableList.kt | 0 .../kotlin/ru/art2000/extensions/datetime.kt | 0 .../fragments/IReplaceableFragment.kt | 0 .../extensions/fragments/IReplaceableItem.kt | 0 .../ru/art2000/extensions/kt/coroutines.kt | 0 .../extensions/preferences/AppPreferences.kt | 0 .../preferences/ListenerDelegate.kt | 0 .../preferences/PreferenceDelegates.kt | 0 .../preferences/ThemeSettingsHolder.kt | 0 .../ru/art2000/extensions/strings/numbers.kt | 0 .../preferences/ListenerDelegate.kt | 0 .../preferences/ThemeSettingsHolder.kt | 0 .../extensions/preferences/UserDefaults.kt | 0 gradle.properties | 2 - gradle/libs.versions.toml | 151 ++++++++- gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 174 +--------- settings/build.gradle.kts | 6 +- .../settings/view/SettingsFragment.kt | 1 - shared/build.gradle.kts | 49 +-- shared/shared.podspec | 11 + unit/build.gradle.kts | 13 +- 96 files changed, 557 insertions(+), 658 deletions(-) create mode 100644 buildSrc/src/main/kotlin/convention.android.base.gradle.kts create mode 100644 buildSrc/src/main/kotlin/convention.android.gradle.kts create mode 100644 buildSrc/src/main/kotlin/convention.dagger.gradle.kts create mode 100644 buildSrc/src/main/kotlin/convention.feature.gradle.kts create mode 100644 buildSrc/src/main/kotlin/convention.kmp.gradle.kts delete mode 100644 buildSrc/src/main/kotlin/ru/art2000/modules/modules.kt rename {extensions => ext}/.gitignore (100%) rename {extensions => ext}/build.gradle.kts (72%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/activities/AutoThemeActivity.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/activities/DayNightActivity.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/activities/EdgeToEdge.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/activities/arguments.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/arch/lifecycles.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/arch/viewmodels.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/collections/ArrayLiveList.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/collections/LifecycleObserverWrapper.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveHashMap.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveList.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveMap.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveObservable.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveObserverWrapper.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/collections/MutableLiveMap.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/collections/PermanentObserverWrapper.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/collections/diff.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/fragments/CommonReplaceableFragment.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/fragments/ExtendedPreferenceFragment.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/fragments/PreferenceReplaceableFragment.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableFragmentHelper.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableFragments.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableItems.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/net/TLSSocketFactory.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/net/trustManagers.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/preferences/Material3SwitchPreference.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/preferences/MaterialTimePickerPreference.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/preferences/MyDropDownPreference.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/preferences/SharedPreferences.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/preferences/TimePickerPreference.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/preferences/TimePickerPreferenceDialog.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/resources.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/ColoringToolbar.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/CustomInputEditText.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/Displaying.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/FloatingActionButtonScrollingBehaviour.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/HorizontalScrollViewCompat.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/MyFragmentStateAdapter.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/MyTabLayoutMediator.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/Paging.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/RecyclerWithEmptyView.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/ReplaceableNavigationView.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/SimpleTextWatcher.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/Views.kt (100%) rename {extensions => ext}/src/androidMain/kotlin/ru/art2000/extensions/views/Windows.kt (100%) rename {extensions => ext}/src/androidMain/res/layout/material3_switch_preference_widget.xml (100%) rename {extensions => ext}/src/androidUnitTest/kotlin/ru/art2000/extensions/collections/ArrayLiveListTest.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/collections/Collections.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/collections/DiffComparable.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/collections/ExtendedMutableList.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/datetime.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/fragments/IReplaceableFragment.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/fragments/IReplaceableItem.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/kt/coroutines.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/preferences/AppPreferences.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/preferences/PreferenceDelegates.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt (100%) rename {extensions => ext}/src/commonMain/kotlin/ru/art2000/extensions/strings/numbers.kt (100%) rename {extensions => ext}/src/iosMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt (100%) rename {extensions => ext}/src/iosMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt (100%) rename {extensions => ext}/src/iosMain/kotlin/ru/art2000/extensions/preferences/UserDefaults.kt (100%) diff --git a/.github/workflows/build_debug.yml b/.github/workflows/build_debug.yml index 37e3828c..6df8c98e 100644 --- a/.github/workflows/build_debug.yml +++ b/.github/workflows/build_debug.yml @@ -10,12 +10,12 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '11' + java-version: '17' cache: 'gradle' - run: chmod +x gradlew - name: Build debug diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6b074bcc..ce5b83ab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,12 +9,12 @@ jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '11' + java-version: '17' cache: 'gradle' - run: chmod +x gradlew - name: Build release @@ -36,7 +36,7 @@ jobs: runs-on: ubuntu-latest needs: build steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/download-artifact@v3 - name: Extract changelog id: extract_changelog diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index 99529f40..f7722c6e 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -10,11 +10,11 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '11' + java-version: '17' - name: Run static analysis - uses: natiginfo/action-detekt-all@1.22.0-RC1 \ No newline at end of file + uses: natiginfo/action-detekt-all@1.23.1 \ No newline at end of file diff --git a/.github/workflows/unit_test.yml b/.github/workflows/unit_test.yml index 2e79d13b..23f54712 100644 --- a/.github/workflows/unit_test.yml +++ b/.github/workflows/unit_test.yml @@ -10,12 +10,12 @@ jobs: test: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: gradle/wrapper-validation-action@v1 - uses: actions/setup-java@v3 with: distribution: 'temurin' - java-version: '11' + java-version: '17' cache: 'gradle' - run: chmod +x gradlew - name: Unit test diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 472e51f2..a2303391 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -4,23 +4,20 @@ import com.android.build.api.dsl.PostProcessing import com.android.build.api.dsl.VariantDimension import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties import org.jetbrains.kotlin.konan.properties.hasProperty -import ru.art2000.modules.setupAndroidModule -import ru.art2000.modules.kapt import java.util.* plugins { - id("com.android.application") - id("kotlin-android") + id("convention.android") } -setupAndroidModule() - val major = 1 val minor = 5 val patch = 4 val code = 18 android { + namespace = "ru.art2000.calculator" + signingConfigs { create("release") { @@ -89,7 +86,7 @@ android { } } -val newVersion = tasks.create("newVersion") { +tasks.create("newVersion") { val version = "v${android.defaultConfig.versionName}" @@ -129,11 +126,9 @@ val newVersion = tasks.create("newVersion") { dependencies { implementation(fileTree("include" to listOf("*.jar"), "dir" to "libs")) - implementation(project(":shared")) + implementation(projects.shared) implementation(libs.constraintlayout) - implementation(libs.bundles.hilt.impl) - kapt(libs.bundles.hilt.kapt) implementation(libs.lifecycle.viewmodel) implementation(libs.viewbindingdelegate) @@ -141,5 +136,4 @@ dependencies { debugImplementation(libs.leakcanary) "minApi21Implementation"(libs.bundles.compose) - -} \ No newline at end of file +} diff --git a/build.gradle.kts b/build.gradle.kts index 5747faa9..61d35cdd 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,3 @@ -@Suppress("DSL_SCOPE_VIOLATION") -plugins { - alias(libs.plugins.dagger) apply false -} - buildscript { repositories { google() @@ -11,6 +6,7 @@ buildscript { dependencies { classpath(libs.android.gradle) classpath(libs.kotlin.gradle) + classpath(libs.dagger.gradle) } } @@ -20,13 +16,4 @@ allprojects { mavenCentral() maven("https://jitpack.io") } - tasks.withType { - options.compilerArgs.plusAssign(listOf( - "-Xlint:unchecked", "-Xlint:deprecation" - )) - } -} - -tasks.create("clean", Delete::class.java) { - delete(rootProject.buildDir) } diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index a6f6b81f..6adcbf4e 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,17 +1,18 @@ plugins { `kotlin-dsl` + java } -fun library(alias: String) = - extensions.getByType() - .named("libs") - .findLibrary(alias) - .get() - dependencies { - implementation(library("android-gradle")) - implementation(library("kotlin-gradle")) - implementation(library("javapoet")) + implementation(libs.android.gradle) + implementation(libs.kotlin.gradle) + implementation(libs.ksp.gradle) + implementation(libs.dagger.gradle) +// compileClasspath(libs.dagger.gradle) +// kotlinCompilerClasspath(libs.dagger.gradle) + implementation(libs.javapoet) + // https://github.com/gradle/gradle/issues/15383 + implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location)) } repositories { diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts index b0ef6dc5..cd7c4b9a 100644 --- a/buildSrc/settings.gradle.kts +++ b/buildSrc/settings.gradle.kts @@ -1,5 +1,6 @@ +rootProject.name = "buildSrc" + dependencyResolutionManagement { - @Suppress("UnstableApiUsage") versionCatalogs { create("libs") { from(files("../gradle/libs.versions.toml")) diff --git a/buildSrc/src/main/kotlin/convention.android.base.gradle.kts b/buildSrc/src/main/kotlin/convention.android.base.gradle.kts new file mode 100644 index 00000000..8ccf7bec --- /dev/null +++ b/buildSrc/src/main/kotlin/convention.android.base.gradle.kts @@ -0,0 +1,175 @@ +import com.android.build.api.dsl.ComposeOptions +import com.android.build.api.dsl.ProductFlavor +import com.android.build.api.variant.AndroidComponentsExtension +import com.android.build.gradle.internal.TaskManager +import com.android.build.gradle.internal.component.ComponentCreationConfig +import com.android.build.gradle.internal.dsl.DefaultConfig +import com.android.build.gradle.internal.dsl.InternalCommonExtension +import com.android.build.gradle.internal.utils.addComposeArgsToKotlinCompile +import org.gradle.accessors.dm.LibrariesForLibs +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + id("com.android.base") +} + +val libs = the() +val javaVersion = JavaVersion.toVersion(libs.versions.java.get()) + +android { + + namespace = "ru.art2000.calculator.${project.name}" + compileSdk = 34 + + defaultConfig { + minSdk = 16 + targetSdk = 34 + + multiDexEnabled = true + vectorDrawables.useSupportLibrary = true + } + + buildFeatures { + viewBinding = true + buildConfig = true + } + + compileOptions { + isCoreLibraryDesugaringEnabled = true + } + testOptions { + unitTests.all { + it.useJUnitPlatform() + } + } + + flavorDimensions += listOf("sdk") + productFlavors { + + create("minApi16") { + minSdk = 16 + dimension = "sdk" + } + + create("minApi21") { + minSdk = 21 + dimension = "sdk" + addCompose(this) { + kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get() + } + } + } + compileOptions { + targetCompatibility = javaVersion + sourceCompatibility = javaVersion + } +} + +kotlin { + jvmToolchain(javaVersion.majorVersion.toInt()) + + // Nevertheless it is applied in kmp convention plugin, code below is run before + // and we need android source set to add dependencies in this plugin + if (this is KotlinMultiplatformExtension) { + androidTarget() + } +} + +dependencies { + val implementationConfigurationName = when (val extension = kotlin as? KotlinMultiplatformExtension) { + null -> "implementation" + else -> extension.sourceSets.getByName("androidMain").implementationConfigurationName + } + + fun unifiedImplementation(dependencyNotation: Any) { + add(implementationConfigurationName, dependencyNotation) + } + + unifiedImplementation(libs.androidx.core) + unifiedImplementation(libs.appcompat) + unifiedImplementation(libs.fragment) + unifiedImplementation(libs.preference) + unifiedImplementation(libs.recycler) + unifiedImplementation(libs.material) + unifiedImplementation(libs.multidex) + + "coreLibraryDesugaring"(libs.desugaring) + "minApi21Implementation"(libs.bundles.compose) +} + +tasks.withType().configureEach { + useJUnitPlatform() +} + +// ===== Utils ===================================================================================== + +fun Project.addCompose(flavor: ProductFlavor, options: ComposeOptions.() -> Unit = {}) { + + val composeOptions = object : ComposeOptions { + override var kotlinCompilerExtensionVersion: String? = null + + @Deprecated("") + override var kotlinCompilerVersion: String? + get() = null + set(_) { logger.warn("ComposeOptions.kotlinCompilerVersion is deprecated. Compose now uses the kotlin compiler defined in your buildscript.") } + + override var useLiveLiterals: Boolean= true + + } + + composeOptions.options() + + // adapted from [com.android.build.gradle.internal.TaskManager] + + val kotlinCompilerExtensionVersionInDsl = + composeOptions.kotlinCompilerExtensionVersion + + val useLiveLiterals = composeOptions.useLiveLiterals + + // Create a project configuration that holds the androidx compose kotlin + // compiler extension + val kotlinExtension = project.configurations.create("kotlin-extension") + project.dependencies + .add( + kotlinExtension.name, "androidx.compose.compiler:compiler:" + + (kotlinCompilerExtensionVersionInDsl + ?: TaskManager.COMPOSE_KOTLIN_COMPILER_EXTENSION_VERSION)) + kotlinExtension.isTransitive = false + kotlinExtension.description = "Configuration for Compose related kotlin compiler extension" + + extensions.configure>("androidComponents") { + onVariants { + if (it.flavorName != flavor.name) return@onVariants + + val creationConfig = it as ComponentCreationConfig + + val taskNamePrefix = creationConfig.computeTaskName("compile") + val possibleTaskNames = listOf( + "${taskNamePrefix}Kotlin", + "${taskNamePrefix}KotlinAndroid", + ) + + project.tasks.whenTaskAdded { + if (name !in possibleTaskNames) return@whenTaskAdded + + addComposeArgsToKotlinCompile( + this as KotlinCompile, + creationConfig, + project.files(kotlinExtension), + useLiveLiterals, + ) + } + } + } +} + +fun android(configure: Action>) = + extensions.configure("android", configure) + +val Project.kotlin: KotlinProjectExtension + get() = extensions.getByName("kotlin") as KotlinProjectExtension + +fun Project.kotlin(configure: Action) = + extensions.configure("kotlin", configure) \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/convention.android.gradle.kts b/buildSrc/src/main/kotlin/convention.android.gradle.kts new file mode 100644 index 00000000..26212ff7 --- /dev/null +++ b/buildSrc/src/main/kotlin/convention.android.gradle.kts @@ -0,0 +1,7 @@ +plugins { + kotlin("android") + id("com.android.application") + id("convention.android.base") + id("com.google.devtools.ksp") + id("convention.dagger") +} diff --git a/buildSrc/src/main/kotlin/convention.dagger.gradle.kts b/buildSrc/src/main/kotlin/convention.dagger.gradle.kts new file mode 100644 index 00000000..2a3205e2 --- /dev/null +++ b/buildSrc/src/main/kotlin/convention.dagger.gradle.kts @@ -0,0 +1,29 @@ +import org.gradle.accessors.dm.LibrariesForLibs +import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension +import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension + +plugins { + id("com.google.devtools.ksp") + id("com.google.dagger.hilt.android") +} + +val libs = the() + +dependencies { + val unifiedImplementation = when (val extension = kotlin as? KotlinMultiplatformExtension) { + null -> "implementation" + else -> extension.sourceSets.getByName("androidMain").implementationConfigurationName + } + + val unifiedKsp = when (kotlin as? KotlinMultiplatformExtension) { + null -> "ksp" + else -> "kspAndroid" + } + + unifiedImplementation(libs.bundles.hilt.impl) + + unifiedKsp(libs.bundles.hilt.preprocessing) +} + +val Project.kotlin: KotlinProjectExtension + get() = extensions.getByName("kotlin") as KotlinProjectExtension \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/convention.feature.gradle.kts b/buildSrc/src/main/kotlin/convention.feature.gradle.kts new file mode 100644 index 00000000..fbbe5e6d --- /dev/null +++ b/buildSrc/src/main/kotlin/convention.feature.gradle.kts @@ -0,0 +1,35 @@ +import org.gradle.accessors.dm.LibrariesForLibs +import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler + +plugins { + id("convention.kmp") + id("convention.dagger") +} + +val libs = the() + +kotlin { + + sourceSets { + val commonMain by getting { + dependencies { + implementation(project(":common")) + implementation(project(":ext")) + } + } + + val androidMain by getting { + dependencies { + + implementation(libs.lifecycle.viewmodel) + implementation(libs.viewbindingdelegate) + + implementation(libs.bundles.room.impl) + kspAndroid(libs.bundles.room.preprocessing) + } + } + } +} + +fun KotlinDependencyHandler.kspAndroid(dependencyNotation: Any) = + project.dependencies.add("kspAndroid", dependencyNotation) diff --git a/buildSrc/src/main/kotlin/convention.kmp.gradle.kts b/buildSrc/src/main/kotlin/convention.kmp.gradle.kts new file mode 100644 index 00000000..a6f8ad3b --- /dev/null +++ b/buildSrc/src/main/kotlin/convention.kmp.gradle.kts @@ -0,0 +1,81 @@ +import com.android.build.api.dsl.ComposeOptions +import com.android.build.api.dsl.ProductFlavor +import com.android.build.api.variant.AndroidComponentsExtension +import com.android.build.gradle.internal.TaskManager +import com.android.build.gradle.internal.component.ComponentCreationConfig +import com.android.build.gradle.internal.utils.addComposeArgsToKotlinCompile +import org.gradle.accessors.dm.LibrariesForLibs +import org.gradle.kotlin.dsl.kotlin +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + kotlin("multiplatform") + id("com.google.devtools.ksp") + id("com.android.library") + id("convention.android.base") +} + +val libs = the() + +val javaVersion = JavaVersion.toVersion(libs.versions.java.get()) + +kotlin { + androidTarget() + + listOf( + iosX64(), + iosArm64(), + iosSimulatorArm64() + ).forEach { + it.binaries.framework { + baseName = project.name + } + } + + applyDefaultHierarchyTemplate() + + jvmToolchain(javaVersion.majorVersion.toInt()) + + sourceSets { + val commonMain by getting + val commonTest by getting { + dependencies { + implementation(kotlin("test-common")) + implementation(libs.bundles.kotest.common) + } + } + val androidUnitTest by getting { + dependencies { + implementation(libs.bundles.kotest.jvm) + } + } + val iosMain by getting { + dependencies { + implementation(libs.koin.core) + } + } + } +} + +tasks.withType().configureEach { + kotlinOptions { + freeCompilerArgs += listOf( + "-Xexpect-actual-classes", +// "-P", +// "plugin:androidx.compose.compiler.plugins.kotlin:suppressKotlinVersionCompatibilityCheck=1.9.20-RC2" + ) + } +} + +tasks.withType().configureEach { + useJUnitPlatform() +} + +android { + sourceSets { + val main by getting + main.manifest { + srcFile("src/androidMain/AndroidManifest.xml") + } + } +} diff --git a/buildSrc/src/main/kotlin/ru/art2000/modules/modules.kt b/buildSrc/src/main/kotlin/ru/art2000/modules/modules.kt deleted file mode 100644 index 1db974ed..00000000 --- a/buildSrc/src/main/kotlin/ru/art2000/modules/modules.kt +++ /dev/null @@ -1,317 +0,0 @@ -@file:Suppress("UNUSED_VARIABLE") - -package ru.art2000.modules - -import com.android.build.api.dsl.ComposeOptions -import com.android.build.api.dsl.ProductFlavor -import com.android.build.api.variant.AndroidComponentsExtension -import com.android.build.gradle.internal.TaskManager -import com.android.build.gradle.internal.component.ComponentCreationConfig -import com.android.build.gradle.internal.dsl.DefaultConfig -import com.android.build.gradle.internal.dsl.InternalCommonExtension -import com.android.build.gradle.internal.utils.addComposeArgsToKotlinCompile -import org.gradle.api.* -import org.gradle.api.artifacts.Dependency -import org.gradle.api.artifacts.VersionCatalogsExtension -import org.gradle.api.artifacts.dsl.DependencyHandler -import org.gradle.api.tasks.testing.Test -import org.gradle.jvm.toolchain.JavaLanguageVersion -import org.gradle.kotlin.dsl.* -import org.gradle.kotlin.dsl.getting -import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension -import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension -import org.jetbrains.kotlin.gradle.plugin.KotlinDependencyHandler -import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - -private fun Project.version(alias: String) = - extensions.getByType() - .named("libs") - .findVersion(alias) - .get() - -private fun Project.library(alias: String) = - extensions.getByType() - .named("libs") - .findLibrary(alias) - .get() - -private fun Project.bundle(alias: String) = - extensions.getByType() - .named("libs") - .findBundle(alias) - .get() - -private fun Project.addCompose(flavor: ProductFlavor, options: ComposeOptions.() -> Unit = {}) { - - val composeOptions = object : ComposeOptions { - override var kotlinCompilerExtensionVersion: String? = null - - @Deprecated("") - override var kotlinCompilerVersion: String? - get() = null - set(_) { logger.warn("ComposeOptions.kotlinCompilerVersion is deprecated. Compose now uses the kotlin compiler defined in your buildscript.") } - - override var useLiveLiterals: Boolean= true - - } - - composeOptions.options() - - // adapted from [com.android.build.gradle.internal.TaskManager] - - val kotlinCompilerExtensionVersionInDsl = - composeOptions.kotlinCompilerExtensionVersion - - val useLiveLiterals = composeOptions.useLiveLiterals - - // Create a project configuration that holds the androidx compose kotlin - // compiler extension - val kotlinExtension = project.configurations.create("kotlin-extension") - project.dependencies - .add( - kotlinExtension.name, "androidx.compose.compiler:compiler:" - + (kotlinCompilerExtensionVersionInDsl - ?: TaskManager.COMPOSE_KOTLIN_COMPILER_EXTENSION_VERSION)) - kotlinExtension.isTransitive = false - kotlinExtension.description = "Configuration for Compose related kotlin compiler extension" - - extensions.configure>("androidComponents") { - onVariants { - if (it.flavorName != flavor.name) return@onVariants - - val creationConfig = it as ComponentCreationConfig - - val taskNamePrefix = creationConfig.computeTaskName("compile") - val possibleTaskNames = listOf( - "${taskNamePrefix}Kotlin", - "${taskNamePrefix}KotlinAndroid", - ) - - project.tasks.whenTaskAdded { - if (name !in possibleTaskNames) return@whenTaskAdded - - addComposeArgsToKotlinCompile( - this as KotlinCompile, - creationConfig, - project.files(kotlinExtension), - useLiveLiterals, - ) - } - } - } -} - -private val javaVersion = JavaVersion.VERSION_11 - -private fun Project.setupAndroid(moduleNamespace: String) { - - android { - namespace = moduleNamespace - compileSdk = 33 - - defaultConfig { - minSdk = 16 - targetSdk = 33 - - multiDexEnabled = true - vectorDrawables.useSupportLibrary = true - } - - buildFeatures { - viewBinding = true - buildConfig = true - } - - compileOptions { - isCoreLibraryDesugaringEnabled = true - } - testOptions { - unitTests.all { - it.useJUnitPlatform() - } - } - - flavorDimensions += listOf("sdk") - productFlavors { - - create("minApi16") { - minSdk = 16 - dimension = "sdk" - } - - create("minApi21") { - minSdk = 21 - dimension = "sdk" - addCompose(this) { - kotlinCompilerExtensionVersion = version("composeCompiler").toString() - } - } - } - dependencies { - "minApi21Implementation"(bundle("compose")) - } - compileOptions { - targetCompatibility = javaVersion - sourceCompatibility = javaVersion - } - } -} - -private fun Project.setupModule(scope: DependencyHandler) { - apply(plugin = "kotlin-kapt") - scope.apply { - implementation(library("androidx-core")) - implementation(library("appcompat")) - implementation(library("fragment")) - implementation(library("preference")) - implementation(library("recycler")) - implementation(library("material")) - - coreLibraryDesugaring(library("desugaring")) - - implementation(library("multidex")) - } - tasks.withType().configureEach { - useJUnitPlatform() - } - - kotlin { - jvmToolchain(javaVersion.majorVersion.toInt()) - } -} - -fun Project.setupAndroidModule( - moduleNamespace: String = "ru.art2000.calculator", - dependencies: DependencyHandler = this.dependencies, -) { - setupAndroid(moduleNamespace) - setupModule(dependencies) - apply(plugin = "com.google.dagger.hilt.android") -} - -fun Project.setupKmmModule(androidPrefix: String = "ru.art2000.calculator") { - - kotlin { - android() - - listOf( - iosX64(), - iosArm64(), - iosSimulatorArm64() - ).forEach { - it.binaries.framework { - baseName = this@setupKmmModule.name - } - } - - sourceSets { - val commonMain by getting - val commonTest by getting { - dependencies { - implementation(kotlin("test-common")) - implementation(bundle("kotest-common")) - } - } - val androidMain by getting { - setupAndroid("$androidPrefix.${this@setupKmmModule.name}") - setupModule(dependencies) - } - val androidUnitTest by getting { - dependencies { - implementation(bundle("kotest-jvm")) - } - } - val iosX64Main by getting - val iosArm64Main by getting - val iosSimulatorArm64Main by getting - val iosMain by creating { - dependsOn(commonMain) - iosX64Main.dependsOn(this) - iosArm64Main.dependsOn(this) - iosSimulatorArm64Main.dependsOn(this) - - dependencies { - implementation(library("koin-core")) - } - } - val iosX64Test by getting - val iosArm64Test by getting - val iosSimulatorArm64Test by getting - val iosTest by creating { - dependsOn(commonTest) - iosX64Test.dependsOn(this) - iosArm64Test.dependsOn(this) - iosSimulatorArm64Test.dependsOn(this) - } - } - } - - android { - sourceSets { - val main by getting - main.manifest { - srcFile("src/androidMain/AndroidManifest.xml") - } - } - } -} - -fun Project.setupFeatureModule() { - apply(plugin = "com.google.dagger.hilt.android") - setupKmmModule() - kotlin { - sourceSets { - - val commonMain by getting { - dependencies { - implementation(project(":common")) - implementation(project(":extensions")) - } - } - - val androidMain by getting { - dependencies { - - implementation(project(":common")) - implementation(project(":extensions")) - - implementation(bundle("hilt-impl")) - kapt(bundle("hilt-kapt")) - - implementation(library("lifecycle-viewmodel")) - implementation(library("viewbindingdelegate")) - } - } - } - } -} - -fun KotlinDependencyHandler.kapt(dependencyNotation: Any) = - project.dependencies.add("kapt", dependencyNotation) - -fun DependencyHandler.kapt(dependencyNotation: Any) = - add("kapt", dependencyNotation) - -//=========== Internal ============ - -internal fun Project.kotlin(configure: Action) = - extensions.configure("kotlin", configure) - -internal fun KotlinMultiplatformExtension.sourceSets(configure: Action>) = - (this as org.gradle.api.plugins.ExtensionAware).extensions.configure("sourceSets", configure) - -internal fun Project.android(configure: Action>) = - extensions.configure("android", configure) - -internal inline val > U.getting - get() = NamedDomainObjectCollectionDelegateProvider.of(this) - -internal fun > U.getting(configuration: T.() -> Unit) = - NamedDomainObjectCollectionDelegateProvider.of(this, configuration) - -internal fun DependencyHandler.implementation(dependencyNotation: Any): Dependency? = - add("implementation", dependencyNotation) - -internal fun DependencyHandler.coreLibraryDesugaring(dependencyNotation: Any): Dependency? = - add("coreLibraryDesugaring", dependencyNotation) diff --git a/calculator/build.gradle.kts b/calculator/build.gradle.kts index e5b1e07a..c1ce690f 100644 --- a/calculator/build.gradle.kts +++ b/calculator/build.gradle.kts @@ -1,15 +1,7 @@ -@file:Suppress("UNUSED_VARIABLE") - -import ru.art2000.modules.setupFeatureModule -import ru.art2000.modules.kapt - plugins { - kotlin("multiplatform") - id("com.android.library") + id("convention.feature") } -setupFeatureModule() - kotlin { sourceSets { @@ -26,9 +18,6 @@ kotlin { implementation(libs.slidingUpPanel) implementation(libs.datetime) - - implementation(libs.bundles.room.impl) - kapt(libs.bundles.room.kapt) } } } diff --git a/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/db/model/HistoryDatabaseItem.kt b/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/db/model/HistoryDatabaseItem.kt index 4da3ce8c..bcf61502 100644 --- a/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/db/model/HistoryDatabaseItem.kt +++ b/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/db/model/HistoryDatabaseItem.kt @@ -9,12 +9,12 @@ import ru.art2000.extensions.collections.DiffComparable import java.util.* @Entity(tableName = "history") -internal data class HistoryDatabaseItem @JvmOverloads constructor( +internal data class HistoryDatabaseItem( val expression: String, val angle: AngleType, val date: Calendar, var comment: String?, - val result: String = "", // for backwards compatibility + val result: String, ) : DiffComparable { @PrimaryKey(autoGenerate = true) @@ -33,7 +33,7 @@ internal data class HistoryDatabaseItem @JvmOverloads constructor( companion object { fun of(item: HistoryContentItem) = with(item) { - HistoryDatabaseItem(expression, angleType, Calendar.getInstance(), comment) + HistoryDatabaseItem(expression, angleType, Calendar.getInstance(), comment, "") } } } \ No newline at end of file diff --git a/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/di/CalculatorModule.kt b/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/di/CalculatorModule.kt index 9b5cc0d5..4a1d7a4c 100644 --- a/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/di/CalculatorModule.kt +++ b/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/di/CalculatorModule.kt @@ -90,22 +90,22 @@ internal abstract class CalculatorModule { private class CalculationHistoryMigration1to2 : Migration(1, 2) { - override fun migrate(database: SupportSQLiteDatabase) { - database.execSQL("ALTER TABLE history ADD COLUMN date INTEGER NOT NULL DEFAULT 0") + override fun migrate(db: SupportSQLiteDatabase) { + db.execSQL("ALTER TABLE history ADD COLUMN date INTEGER NOT NULL DEFAULT 0") } } private class CalculationHistoryMigration2to3 : Migration(2, 3) { - override fun migrate(database: SupportSQLiteDatabase) { - database.execSQL("ALTER TABLE history ADD COLUMN comment TEXT") + override fun migrate(db: SupportSQLiteDatabase) { + db.execSQL("ALTER TABLE history ADD COLUMN comment TEXT") } } private class CalculationHistoryMigration3to4 : Migration(3, 4) { - override fun migrate(database: SupportSQLiteDatabase) { - database.execSQL("ALTER TABLE history ADD COLUMN angle TEXT NOT NULL DEFAULT 'DEGREES'") + override fun migrate(db: SupportSQLiteDatabase) { + db.execSQL("ALTER TABLE history ADD COLUMN angle TEXT NOT NULL DEFAULT 'DEGREES'") } } } diff --git a/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/view/LexemeListAdapter.kt b/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/view/LexemeListAdapter.kt index 6d5b1eea..a368face 100644 --- a/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/view/LexemeListAdapter.kt +++ b/calculator/src/androidMain/kotlin/ru/art2000/calculator/calculator/view/LexemeListAdapter.kt @@ -2,6 +2,7 @@ package ru.art2000.calculator.calculator.view import android.annotation.SuppressLint import android.content.Context +import android.view.Gravity import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView @@ -26,6 +27,8 @@ internal class LexemeListAdapter( override fun onBindViewHolder(holder: LexemeViewHolder, position: Int) { val lexeme = lexemes[position] + holder.lexemeTextView.gravity = Gravity.START + holder.lexemeTextView.text = if (lexeme is ExpressionValue) numberFormatter(lexeme.value) else diff --git a/common/build.gradle.kts b/common/build.gradle.kts index b8e514fb..07518344 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,36 +1,26 @@ -@file:Suppress("UNUSED_VARIABLE") - -import ru.art2000.modules.setupKmmModule -import ru.art2000.modules.kapt - plugins { - kotlin("multiplatform") - id("com.android.library") + id("convention.kmp") + id("convention.dagger") } -setupKmmModule() - kotlin { sourceSets { val commonMain by getting { dependencies { - implementation(project(":extensions")) + implementation(projects.ext) } } val androidMain by getting { dependencies { - implementation(project(":extensions")) + implementation(projects.ext) implementation(libs.lifecycle.viewmodel) implementation(libs.bundles.room.impl) implementation(libs.constraintlayout) - - implementation(libs.bundles.hilt.impl) - kapt(libs.bundles.hilt.kapt) } } } diff --git a/common/src/androidMain/kotlin/ru/art2000/calculator/common/view/AppActivity.kt b/common/src/androidMain/kotlin/ru/art2000/calculator/common/view/AppActivity.kt index 362f76fb..11013eae 100644 --- a/common/src/androidMain/kotlin/ru/art2000/calculator/common/view/AppActivity.kt +++ b/common/src/androidMain/kotlin/ru/art2000/calculator/common/view/AppActivity.kt @@ -5,7 +5,6 @@ import dagger.hilt.EntryPoint import dagger.hilt.InstallIn import dagger.hilt.android.EntryPointAccessors import dagger.hilt.components.SingletonComponent -import ru.art2000.calculator.common.R import ru.art2000.calculator.common.preferences.GeneralPreferenceHelper import ru.art2000.extensions.activities.AutoThemeActivity import ru.art2000.extensions.activities.IEdgeToEdgeActivity diff --git a/currency/build.gradle.kts b/currency/build.gradle.kts index 143d5d36..54e411b4 100644 --- a/currency/build.gradle.kts +++ b/currency/build.gradle.kts @@ -1,15 +1,7 @@ -@file:Suppress("UNUSED_VARIABLE") - -import ru.art2000.modules.setupFeatureModule -import ru.art2000.modules.kapt - plugins { - kotlin("multiplatform") - id("com.android.library") + id("convention.feature") } -setupFeatureModule() - configurations.all { exclude(group = "stax", module = "stax-api") exclude(group = "stax", module = "stax") @@ -29,9 +21,6 @@ kotlin { val androidMain by getting { dependencies { - implementation(libs.bundles.room.impl) - kapt(libs.bundles.room.kapt) - implementation(libs.work) implementation(libs.swiperefreshlayout) @@ -75,4 +64,4 @@ android { consumerProguardFile("proguard-rules.pro") } } -} \ No newline at end of file +} diff --git a/currency/src/androidMain/kotlin/ru/art2000/calculator/currency/di/CurrencyModule.kt b/currency/src/androidMain/kotlin/ru/art2000/calculator/currency/di/CurrencyModule.kt index e73d1b56..5203981c 100644 --- a/currency/src/androidMain/kotlin/ru/art2000/calculator/currency/di/CurrencyModule.kt +++ b/currency/src/androidMain/kotlin/ru/art2000/calculator/currency/di/CurrencyModule.kt @@ -115,13 +115,13 @@ internal abstract class CurrencyModule { .build() private class V2Migration : Migration(1, 2) { - override fun migrate(database: SupportSQLiteDatabase) { - database.execSQL("drop table info") + override fun migrate(db: SupportSQLiteDatabase) { + db.execSQL("drop table info") } } private class V3Migration : Migration(2, 3) { - override fun migrate(database: SupportSQLiteDatabase) { + override fun migrate(db: SupportSQLiteDatabase) { // language=sql listOf( """ @@ -135,7 +135,7 @@ internal abstract class CurrencyModule { "DROP TABLE currency;", "ALTER TABLE currency3 RENAME TO currency;", ).forEach { - database.execSQL(it) + db.execSQL(it) } } } diff --git a/extensions/.gitignore b/ext/.gitignore similarity index 100% rename from extensions/.gitignore rename to ext/.gitignore diff --git a/extensions/build.gradle.kts b/ext/build.gradle.kts similarity index 72% rename from extensions/build.gradle.kts rename to ext/build.gradle.kts index 019f480c..cb753ef5 100644 --- a/extensions/build.gradle.kts +++ b/ext/build.gradle.kts @@ -1,13 +1,10 @@ -@file:Suppress("UNUSED_VARIABLE") - -import ru.art2000.modules.setupKmmModule - plugins { - kotlin("multiplatform") - id("com.android.library") + id("convention.kmp") } -setupKmmModule("ru.art2000") +android { + namespace = "ru.art2000.extensions" +} kotlin { diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/activities/AutoThemeActivity.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/activities/AutoThemeActivity.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/activities/AutoThemeActivity.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/activities/AutoThemeActivity.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/activities/DayNightActivity.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/activities/DayNightActivity.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/activities/DayNightActivity.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/activities/DayNightActivity.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/activities/EdgeToEdge.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/activities/EdgeToEdge.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/activities/EdgeToEdge.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/activities/EdgeToEdge.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/activities/arguments.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/activities/arguments.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/activities/arguments.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/activities/arguments.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/arch/lifecycles.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/arch/lifecycles.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/arch/lifecycles.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/arch/lifecycles.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/arch/viewmodels.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/arch/viewmodels.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/arch/viewmodels.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/arch/viewmodels.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/ArrayLiveList.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/collections/ArrayLiveList.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/ArrayLiveList.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/collections/ArrayLiveList.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LifecycleObserverWrapper.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LifecycleObserverWrapper.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LifecycleObserverWrapper.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LifecycleObserverWrapper.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveHashMap.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveHashMap.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveHashMap.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveHashMap.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveList.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveList.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveList.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveList.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveMap.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveMap.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveMap.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveMap.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveObservable.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveObservable.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveObservable.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveObservable.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveObserverWrapper.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveObserverWrapper.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveObserverWrapper.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/collections/LiveObserverWrapper.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/MutableLiveMap.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/collections/MutableLiveMap.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/MutableLiveMap.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/collections/MutableLiveMap.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/PermanentObserverWrapper.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/collections/PermanentObserverWrapper.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/PermanentObserverWrapper.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/collections/PermanentObserverWrapper.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/diff.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/collections/diff.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/collections/diff.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/collections/diff.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/CommonReplaceableFragment.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/CommonReplaceableFragment.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/CommonReplaceableFragment.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/CommonReplaceableFragment.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/ExtendedPreferenceFragment.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/ExtendedPreferenceFragment.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/ExtendedPreferenceFragment.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/ExtendedPreferenceFragment.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/PreferenceReplaceableFragment.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/PreferenceReplaceableFragment.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/PreferenceReplaceableFragment.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/PreferenceReplaceableFragment.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableFragmentHelper.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableFragmentHelper.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableFragmentHelper.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableFragmentHelper.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableFragments.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableFragments.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableFragments.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableFragments.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableItems.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableItems.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableItems.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/fragments/ReplaceableItems.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/net/TLSSocketFactory.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/net/TLSSocketFactory.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/net/TLSSocketFactory.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/net/TLSSocketFactory.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/net/trustManagers.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/net/trustManagers.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/net/trustManagers.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/net/trustManagers.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/Material3SwitchPreference.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/Material3SwitchPreference.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/Material3SwitchPreference.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/Material3SwitchPreference.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/MaterialTimePickerPreference.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/MaterialTimePickerPreference.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/MaterialTimePickerPreference.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/MaterialTimePickerPreference.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/MyDropDownPreference.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/MyDropDownPreference.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/MyDropDownPreference.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/MyDropDownPreference.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/SharedPreferences.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/SharedPreferences.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/SharedPreferences.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/SharedPreferences.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/TimePickerPreference.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/TimePickerPreference.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/TimePickerPreference.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/TimePickerPreference.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/TimePickerPreferenceDialog.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/TimePickerPreferenceDialog.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/preferences/TimePickerPreferenceDialog.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/preferences/TimePickerPreferenceDialog.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/resources.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/resources.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/resources.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/resources.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/ColoringToolbar.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/ColoringToolbar.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/ColoringToolbar.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/ColoringToolbar.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/CustomInputEditText.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/CustomInputEditText.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/CustomInputEditText.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/CustomInputEditText.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/Displaying.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/Displaying.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/Displaying.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/Displaying.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/FloatingActionButtonScrollingBehaviour.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/FloatingActionButtonScrollingBehaviour.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/FloatingActionButtonScrollingBehaviour.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/FloatingActionButtonScrollingBehaviour.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/HorizontalScrollViewCompat.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/HorizontalScrollViewCompat.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/HorizontalScrollViewCompat.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/HorizontalScrollViewCompat.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/MyFragmentStateAdapter.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/MyFragmentStateAdapter.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/MyFragmentStateAdapter.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/MyFragmentStateAdapter.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/MyTabLayoutMediator.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/MyTabLayoutMediator.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/MyTabLayoutMediator.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/MyTabLayoutMediator.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/Paging.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/Paging.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/Paging.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/Paging.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/RecyclerWithEmptyView.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/RecyclerWithEmptyView.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/RecyclerWithEmptyView.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/RecyclerWithEmptyView.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/ReplaceableNavigationView.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/ReplaceableNavigationView.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/ReplaceableNavigationView.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/ReplaceableNavigationView.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/SimpleTextWatcher.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/SimpleTextWatcher.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/SimpleTextWatcher.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/SimpleTextWatcher.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/Views.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/Views.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/Views.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/Views.kt diff --git a/extensions/src/androidMain/kotlin/ru/art2000/extensions/views/Windows.kt b/ext/src/androidMain/kotlin/ru/art2000/extensions/views/Windows.kt similarity index 100% rename from extensions/src/androidMain/kotlin/ru/art2000/extensions/views/Windows.kt rename to ext/src/androidMain/kotlin/ru/art2000/extensions/views/Windows.kt diff --git a/extensions/src/androidMain/res/layout/material3_switch_preference_widget.xml b/ext/src/androidMain/res/layout/material3_switch_preference_widget.xml similarity index 100% rename from extensions/src/androidMain/res/layout/material3_switch_preference_widget.xml rename to ext/src/androidMain/res/layout/material3_switch_preference_widget.xml diff --git a/extensions/src/androidUnitTest/kotlin/ru/art2000/extensions/collections/ArrayLiveListTest.kt b/ext/src/androidUnitTest/kotlin/ru/art2000/extensions/collections/ArrayLiveListTest.kt similarity index 100% rename from extensions/src/androidUnitTest/kotlin/ru/art2000/extensions/collections/ArrayLiveListTest.kt rename to ext/src/androidUnitTest/kotlin/ru/art2000/extensions/collections/ArrayLiveListTest.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/collections/Collections.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/collections/Collections.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/collections/Collections.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/collections/Collections.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/collections/DiffComparable.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/collections/DiffComparable.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/collections/DiffComparable.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/collections/DiffComparable.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/collections/ExtendedMutableList.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/collections/ExtendedMutableList.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/collections/ExtendedMutableList.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/collections/ExtendedMutableList.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/datetime.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/datetime.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/datetime.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/datetime.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/fragments/IReplaceableFragment.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/fragments/IReplaceableFragment.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/fragments/IReplaceableFragment.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/fragments/IReplaceableFragment.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/fragments/IReplaceableItem.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/fragments/IReplaceableItem.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/fragments/IReplaceableItem.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/fragments/IReplaceableItem.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/kt/coroutines.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/kt/coroutines.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/kt/coroutines.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/kt/coroutines.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/preferences/AppPreferences.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/preferences/AppPreferences.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/preferences/AppPreferences.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/preferences/AppPreferences.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/preferences/PreferenceDelegates.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/preferences/PreferenceDelegates.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/preferences/PreferenceDelegates.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/preferences/PreferenceDelegates.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt diff --git a/extensions/src/commonMain/kotlin/ru/art2000/extensions/strings/numbers.kt b/ext/src/commonMain/kotlin/ru/art2000/extensions/strings/numbers.kt similarity index 100% rename from extensions/src/commonMain/kotlin/ru/art2000/extensions/strings/numbers.kt rename to ext/src/commonMain/kotlin/ru/art2000/extensions/strings/numbers.kt diff --git a/extensions/src/iosMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt b/ext/src/iosMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt similarity index 100% rename from extensions/src/iosMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt rename to ext/src/iosMain/kotlin/ru/art2000/extensions/preferences/ListenerDelegate.kt diff --git a/extensions/src/iosMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt b/ext/src/iosMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt similarity index 100% rename from extensions/src/iosMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt rename to ext/src/iosMain/kotlin/ru/art2000/extensions/preferences/ThemeSettingsHolder.kt diff --git a/extensions/src/iosMain/kotlin/ru/art2000/extensions/preferences/UserDefaults.kt b/ext/src/iosMain/kotlin/ru/art2000/extensions/preferences/UserDefaults.kt similarity index 100% rename from extensions/src/iosMain/kotlin/ru/art2000/extensions/preferences/UserDefaults.kt rename to ext/src/iosMain/kotlin/ru/art2000/extensions/preferences/UserDefaults.kt diff --git a/gradle.properties b/gradle.properties index 26db5224..f6012748 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,8 +13,6 @@ org.gradle.jvmargs=-Xmx2048m # org.gradle.parallel=true # Android -# TODO 'This is the default behavior in Android Gradle plugin 8.0.0 and higher' -android.nonTransitiveRClass=true android.useAndroidX=true #Kotlin diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index cf240419..5ae28bd9 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,9 +1,154 @@ [versions] -kotlin = "1.8.10" -agp = "7.4.2" +kotlin = "1.9.21" +ksp = "1.9.21-1.0.15" +agp = "8.2.0" javapoet = "1.13.0" +java = "17" + +koin = "3.4.3" +kotest = "5.6.2" +viewbindingdelegate = "1.5.9" +#noinspection GradleDependency +okhttpMinApi16 = "3.12.13" +okhttpMinApi21 = "4.11.0" +retrofit = "2.9.0" + +activity = "1.8.1" +appcompat = "1.6.1" +constraintlayout = "2.1.4" +androidx-core = "1.12.0" +fragment = "1.6.2" +lifecycle = "2.6.2" +multidex = "2.0.1" +preference = "1.2.1" +recycler = "1.3.2" +desugaring = "2.0.4" +material = "1.10.0" +room = "2.6.1" +swiperefreshlayout = "1.1.0" +work = "2.9.0" + +compose = "1.5.4" +# https://developer.android.com/jetpack/androidx/releases/compose-kotlin +composeCompiler = "1.5.6" +composeMaterial3 = "1.1.2" +accompanist = "0.32.0" + +androidxHilt = "1.1.0" +# 2.47+ doesn't see plugin +daggerHilt = "2.49" + +leakcanary = "2.12" +commonsMath = "3.6.1" +slidingUpPanel = "4.5.0" + +datetime = "0.4.0" +coroutines-core = "1.7.3" +multiplatformSettings = "1.0.0" [libraries] kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } android-gradle = { module = "com.android.tools.build:gradle", version.ref = "agp" } -javapoet = { module = "com.squareup:javapoet", version.ref = "javapoet" } \ No newline at end of file +dagger-gradle = { module = "com.google.dagger:hilt-android-gradle-plugin", version.ref = "daggerHilt" } +ksp-gradle = { module = "com.google.devtools.ksp:com.google.devtools.ksp.gradle.plugin", version.ref = "ksp" } +javapoet = { module = "com.squareup:javapoet", version.ref = "javapoet" } + +appcompat = { module = "androidx.appcompat:appcompat", version.ref="appcompat" } +constraintlayout = { module = "androidx.constraintlayout:constraintlayout", version.ref="constraintlayout" } +androidx-core = { module = "androidx.core:core-ktx", version.ref="androidx-core" } +fragment = { module = "androidx.fragment:fragment-ktx", version.ref="fragment" } +lifecycle-process = { module = "androidx.lifecycle:lifecycle-process", version.ref="lifecycle" } +lifecycle-viewmodel = { module = "androidx.lifecycle:lifecycle-viewmodel-ktx", version.ref="lifecycle" } +multidex = { module = "androidx.multidex:multidex", version.ref="multidex" } +preference = { module = "androidx.preference:preference-ktx", version.ref="preference" } +recycler = { module = "androidx.recyclerview:recyclerview", version.ref="recycler" } +room-compiler = { module = "androidx.room:room-compiler", version.ref="room" } +room = { module = "androidx.room:room-ktx", version.ref="room" } +room-runtime = { module = "androidx.room:room-runtime", version.ref="room" } +swiperefreshlayout = { module = "androidx.swiperefreshlayout:swiperefreshlayout", version.ref="swiperefreshlayout" } +work = { module = "androidx.work:work-runtime-ktx", version.ref="work" } +desugaring = { module = "com.android.tools:desugar_jdk_libs", version.ref="desugaring" } +material = { module = "com.google.android.material:material", version.ref="material" } + +koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" } + +kotest-framework-engine = { module = "io.kotest:kotest-framework-engine", version.ref = "kotest" } +kotest-assertions-core = { module = "io.kotest:kotest-assertions-core", version.ref = "kotest" } +kotest-property = { module = "io.kotest:kotest-property", version.ref = "kotest" } +kotest-framework-datatest = { module = "io.kotest:kotest-framework-datatest", version.ref = "kotest" } +kotest-runner-junit5 = { module = "io.kotest:kotest-runner-junit5", version.ref = "kotest" } + +viewbindingdelegate = { module = "com.github.kirich1409:viewbindingpropertydelegate-full", version.ref = "viewbindingdelegate" } + +okhttp-okhttpMinApi16 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttpMinApi16" } +okhttp-okhttpMinApi21 = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttpMinApi21" } +retrofit-retrofit = { module = "com.squareup.retrofit2:retrofit", version.ref = "retrofit" } +retrofit-convertersimplexml = { module = "com.squareup.retrofit2:converter-simplexml", version.ref = "retrofit" } + +compose-activity = { module = "androidx.activity:activity-compose", version.ref = "activity" } +compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "composeCompiler" } +compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" } +compose-material = { module = "androidx.compose.material:material", version.ref = "compose" } +compose-material3 = { module = "androidx.compose.material3:material3", version.ref = "composeMaterial3" } +compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" } +compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" } +compose-theme-adapter3 = { module = "com.google.accompanist:accompanist-themeadapter-material3", version.ref = "accompanist" } + +hilt-work = { module = "androidx.hilt:hilt-work", version.ref = "androidxHilt" } +hilt-compiler = { module = "androidx.hilt:hilt-compiler", version.ref = "androidxHilt" } +hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "daggerHilt" } +hilt-android-compiler = { module = "com.google.dagger:hilt-compiler", version.ref = "daggerHilt" } + +leakcanary = { module = "com.squareup.leakcanary:leakcanary-android", version.ref = "leakcanary" } +apache-commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commonsMath" } +slidingUpPanel = { module = "com.github.hannesa2:AndroidSlidingUpPanel", version.ref = "slidingUpPanel" } + +coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines-core" } +datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "datetime" } +multiplatformSettings = { module = "com.russhwolf:multiplatform-settings", version.ref = "multiplatformSettings" } + +[bundles] +kotest-common = [ + "kotest-assertions-core", + "kotest-framework-engine", + "kotest-framework-datatest", + "kotest-property", +] + +kotest-jvm = [ + "kotest-runner-junit5", +] + +compose = [ + "compose-activity", + "compose-compiler", + "compose-foundation", + "compose-material", + "compose-material3", + "compose-ui", + "compose-ui-tooling", + "compose-theme-adapter3", +] + +hilt-impl = [ + "hilt-work", + "hilt-android", +] + +hilt-preprocessing = [ + "hilt-compiler", + "hilt-android-compiler", +] + +room-impl = [ + "room", + "room-runtime", +] + +room-preprocessing = [ + "room-compiler", +] + +[plugins] +dagger = { id = "com.google.dagger.hilt.android", version.ref = "daggerHilt" } +ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" } \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bc4f39c0..9d7bb1aa 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ #Thu Apr 07 19:28:56 MSK 2022 distributionBase=GRADLE_USER_HOME -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip distributionPath=wrapper/dists zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/settings.gradle.kts b/settings.gradle.kts index e3d9cc1c..e632e6a0 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,180 +1,12 @@ -dependencyResolutionManagement { - versionCatalogs { - create("libs") { - val lifecycle = version("lifecycle", "2.6.0") - val androidxHilt = version("androidxHilt", "1.0.0") - val daggerHilt = version("daggerHilt", "2.45") - val room = version("room", "2.5.0") - val kotest = version("kotest", "5.5.4") - val activity = version("activity", "1.6.1") - val compose = version("compose", "1.3.1") - val composeCompiler = version("composeCompiler", "1.4.3") - val composeMaterial3 = version("composeMaterial3", "1.0.1") - val accompanist = version("accompanist", "0.28.0") - val koin = version("koin", "3.3.3") - val work = version("work", "2.8.0") - val swiperefreshlayout = version("swiperefreshlayout", "1.1.0") - val okhttpMinApi16 = version("okhttpMinApi16", "3.12.13") - val okhttpMinApi21 = version("okhttpMinApi21", "4.10.0") - val okhttpVersions = listOf( - okhttpMinApi16, - okhttpMinApi21, - ) - val retrofit = version("retrofit", "2.9.0") - val leakcanary = version("leakcanary", "2.10") - val commonsMath = version("commonsMath", "3.6.1") - val slidingUpPanel = version("slidingUpPanel", "4.5.0") - val multiplatformSettings = version("multiplatformSettings", "1.0.0") +enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS") - library("desugaring", "com.android.tools:desugar_jdk_libs:2.0.2") - library("appcompat", "androidx.appcompat:appcompat:1.6.1") - library("androidx.core", "androidx.core:core-ktx:1.9.0") - library("preference", "androidx.preference:preference-ktx:1.2.0") - library("fragment", "androidx.fragment:fragment-ktx:1.5.5") - library("recycler", "androidx.recyclerview:recyclerview:1.3.0") - library("material", "com.google.android.material:material:1.8.0") - - listOf("lifecycle-process", "lifecycle-viewmodel-ktx").forEach { - library(it.removeSuffix("-ktx"), "androidx.lifecycle", it) - .versionRef(lifecycle) - } - - library("viewbindingdelegate", "com.github.kirich1409:viewbindingpropertydelegate-full:1.5.8") - - listOf("hilt-work", "hilt-compiler").forEach { - library(it, "androidx.hilt", it).versionRef(androidxHilt) - } - - listOf("hilt-android", "hilt-android-compiler").forEach { - library(it, "com.google.dagger", it).versionRef(daggerHilt) - } - - bundle("hilt-impl", listOf("hilt-work", "hilt-android")) - bundle("hilt-kapt", listOf("hilt-compiler", "hilt-android-compiler")) - - listOf("room-compiler", "room-ktx", "room-runtime").forEach { - library(it.removeSuffix("-ktx"), "androidx.room", it).versionRef(room) - } - - bundle("room-impl", listOf("room", "room-runtime")) - bundle("room-kapt", listOf("room-compiler")) - - library("datetime", "org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") - library("coroutines-core", "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") - - library("multidex", "androidx.multidex:multidex:2.0.1") - - library("constraintlayout", "androidx.constraintlayout:constraintlayout:2.1.4") - - listOf( - "kotest-framework-engine", - "kotest-assertions-core", - "kotest-property", - "kotest-framework-datatest", - "kotest-runner-junit5", - ).forEach { - library(it, "io.kotest", it).versionRef(kotest) - } - - bundle("kotest-common", listOf( - "kotest-framework-engine", - "kotest-assertions-core", - "kotest-property", - "kotest-framework-datatest", - )) - - bundle("kotest-jvm", listOf("kotest-runner-junit5")) - - plugin("dagger", "com.google.dagger.hilt.android").versionRef(daggerHilt) - - val composeAliases = mutableListOf() - - listOf( - "androidx.compose.ui:ui", - "androidx.compose.ui:ui-tooling", - "androidx.compose.foundation:foundation", - "androidx.compose.material:material", - ).forEach { - val (group, artifact) = it.split(':') - val alias = "compose-$artifact" - composeAliases += alias - library(alias, group, artifact).versionRef(compose) - } - - library("compose-activity".also { composeAliases += it }, "androidx.activity", "activity-compose") - .versionRef(activity) - - library("compose-compiler".also { composeAliases += it }, "androidx.compose.compiler", "compiler") - .versionRef(composeCompiler) - - library("compose-material3".also { composeAliases += it }, "androidx.compose.material3", "material3") - .versionRef(composeMaterial3) - - library("compose-theme-adapter3".also { composeAliases += it }, "com.google.accompanist", "accompanist-themeadapter-material3") - .versionRef(accompanist) - - bundle("compose", composeAliases) - - library("koin-core", "io.insert-koin", "koin-core").versionRef(koin) - library("work", "androidx.work", "work-runtime-ktx").versionRef(work) - library("swiperefreshlayout", "androidx.swiperefreshlayout", "swiperefreshlayout") - .versionRef(swiperefreshlayout) - - fun Iterable.collectionSizeOrDefault(default: Int): Int = if (this is Collection<*>) this.size else default - - fun Iterable.zipAll(other: Iterable, transform: (a: T, b: R) -> V): List { - val first = iterator() - val list = ArrayList(collectionSizeOrDefault(10) + other.collectionSizeOrDefault(10)) - while (first.hasNext()) { - val firstElem = first.next() - val second = other.iterator() - while (second.hasNext()) { - list.add(transform(firstElem, second.next())) - } - } - return list - } - - infix fun Iterable.zipAll(other: Iterable): List> { - return zipAll(other) { t1, t2 -> t1 to t2 } - } - - listOf( - "okhttp", - ).zipAll(okhttpVersions).forEach { (artifact, version) -> - val type = version.substringAfter("okhttp") - val alias = "okhttp-${artifact.replace("-", "")}$type" - library(alias, "com.squareup.okhttp3", artifact).versionRef(version) - } - - listOf( - "retrofit", - "converter-simplexml", - ).forEach { artifact -> - val alias = "retrofit-${artifact.replace("-", "")}" - library(alias, "com.squareup.retrofit2", artifact).versionRef(retrofit) - } - - library("leakcanary", "com.squareup.leakcanary", "leakcanary-android") - .versionRef(leakcanary) - - library("apache-commons-math3", "org.apache.commons", "commons-math3") - .versionRef(commonsMath) - - library("slidingUpPanel", "com.github.hannesa2", "AndroidSlidingUpPanel") - .versionRef(slidingUpPanel) - - library("multiplatformSettings", "com.russhwolf", "multiplatform-settings") - .versionRef(multiplatformSettings) - } - } -} +rootProject.name = "RTCalculator" include(":app") include(":currency") include(":calculator") include(":unit") include(":common") -include(":extensions") +include(":ext") include(":shared") include(":settings") diff --git a/settings/build.gradle.kts b/settings/build.gradle.kts index a196c22c..07dbbf79 100644 --- a/settings/build.gradle.kts +++ b/settings/build.gradle.kts @@ -1,13 +1,9 @@ -import ru.art2000.modules.setupFeatureModule import java.util.* plugins { - kotlin("multiplatform") - id("com.android.library") + id("convention.feature") } -setupFeatureModule() - android { defaultConfig { buildConfigField("long", "BUILD_TIME", "${Date().time}") diff --git a/settings/src/androidMain/kotlin/ru/art2000/calculator/settings/view/SettingsFragment.kt b/settings/src/androidMain/kotlin/ru/art2000/calculator/settings/view/SettingsFragment.kt index 861c35b9..059b5d04 100644 --- a/settings/src/androidMain/kotlin/ru/art2000/calculator/settings/view/SettingsFragment.kt +++ b/settings/src/androidMain/kotlin/ru/art2000/calculator/settings/view/SettingsFragment.kt @@ -185,7 +185,6 @@ internal class SettingsFragment : MainScreenPreferenceFragment() { requireContext().packageName, PackageInfoFlags.of(0) ) } else { - @Suppress("DEPRECATION") it.getPackageInfo( requireContext().packageName, 0 ) diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 98a619a6..987eaa9d 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -1,52 +1,17 @@ -@file:Suppress("UNUSED_VARIABLE") - -import ru.art2000.modules.setupKmmModule - plugins { - kotlin("multiplatform") + id("convention.kmp") kotlin("native.cocoapods") - id("com.android.library") -} - -setupKmmModule() - -// TODO remove when native.cocoapods properly supports gradle 8 -val myAttribute = Attribute.of("configurationDisambiguation", String::class.java) - -val archTypes = listOf("Arm64", "SimulatorArm64", "X64", "Fat") -val buildTypes = listOf("debug", "release") -val podTypes = listOf("", "pod") - -val names = podTypes.flatMap { pod -> - buildTypes.flatMap { build -> - val podBuild = when { - pod.isEmpty() -> build - else -> "$pod${build.replaceFirstChar { it.uppercaseChar() }}" - } - archTypes.map { arch -> - "${podBuild}FrameworkIos$arch" - } - } -} - -configurations.configureEach { - if (name in names) { - attributes { - attribute(myAttribute, name) - } - } } -// END kotlin { val projects = listOf( - project(":extensions"), - project(":common"), - project(":calculator"), - project(":unit"), - project(":currency"), - project(":settings"), + projects.ext, + projects.common, + projects.calculator, + projects.unit, + projects.currency, + projects.settings, ) cocoapods { diff --git a/shared/shared.podspec b/shared/shared.podspec index 628240d4..478b9d45 100644 --- a/shared/shared.podspec +++ b/shared/shared.podspec @@ -11,6 +11,17 @@ Pod::Spec.new do |spec| spec.ios.deployment_target = '14.1' + if !Dir.exist?('build/cocoapods/framework/shared.framework') || Dir.empty?('build/cocoapods/framework/shared.framework') + raise " + + Kotlin framework 'shared' doesn't exist yet, so a proper Xcode project can't be generated. + 'pod install' should be executed after running ':generateDummyFramework' Gradle task: + + ./gradlew :shared:generateDummyFramework + + Alternatively, proper pod installation is performed during Gradle sync in the IDE (if Podfile location is set)" + end + spec.pod_target_xcconfig = { 'KOTLIN_PROJECT_PATH' => ':shared', 'PRODUCT_MODULE_NAME' => 'shared', diff --git a/unit/build.gradle.kts b/unit/build.gradle.kts index f1587a9b..850b9957 100644 --- a/unit/build.gradle.kts +++ b/unit/build.gradle.kts @@ -1,25 +1,18 @@ -@file:Suppress("UNUSED_VARIABLE") - -import ru.art2000.modules.setupFeatureModule - plugins { - kotlin("multiplatform") - id("com.android.library") + id("convention.feature") } -setupFeatureModule() - kotlin { sourceSets { val commonMain by getting { dependencies { - implementation(project(":calculator")) + implementation(projects.calculator) } } val androidMain by getting { dependencies { - implementation(project(":calculator")) + implementation(projects.calculator) } } }