Parcourir la source

@fun: add dependency

bai il y a 3 ans
Parent
commit
4cf2d05e3d

+ 0 - 65
app/build.gradle

@@ -1,65 +0,0 @@
-plugins {
-    id 'com.android.application'
-    id 'kotlin-android'
-}
-
-android {
-    compileSdk 31
-
-    defaultConfig {
-        applicationId "com.ys.bdtp.adm"
-        minSdk 28
-        targetSdk 31
-        versionCode 1
-        versionName "1.0"
-
-        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
-        vectorDrawables {
-            useSupportLibrary true
-        }
-    }
-
-    buildTypes {
-        release {
-            minifyEnabled false
-            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
-        }
-    }
-    compileOptions {
-        sourceCompatibility JavaVersion.VERSION_1_8
-        targetCompatibility JavaVersion.VERSION_1_8
-    }
-    kotlinOptions {
-        jvmTarget = '1.8'
-        useIR = true
-    }
-    buildFeatures {
-        compose true
-    }
-    composeOptions {
-        kotlinCompilerExtensionVersion compose_version
-        kotlinCompilerVersion '1.5.10'
-    }
-    packagingOptions {
-        resources {
-            excludes += '/META-INF/{AL2.0,LGPL2.1}'
-        }
-    }
-}
-
-dependencies {
-
-    implementation 'androidx.core:core-ktx:1.3.2'
-    implementation 'androidx.appcompat:appcompat:1.2.0'
-    implementation 'com.google.android.material:material:1.3.0'
-    implementation "androidx.compose.ui:ui:$compose_version"
-    implementation "androidx.compose.material:material:$compose_version"
-    implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
-    implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1'
-    implementation 'androidx.activity:activity-compose:1.3.0-alpha06'
-    testImplementation 'junit:junit:4.+'
-    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
-    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
-    androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
-    debugImplementation "androidx.compose.ui:ui-tooling:$compose_version"
-}

+ 124 - 0
app/build.gradle.kts

@@ -0,0 +1,124 @@
+plugins {
+    id("com.android.application")
+    id("org.jetbrains.kotlin.android")
+    kotlin("kapt") version Sdk.kotlin
+}
+
+android {
+    compileSdk = Sdk.compileSdk
+
+    defaultConfig {
+        applicationId = "com.ys.bdtp.adm"
+        minSdk = Sdk.minSdk
+        targetSdk = Sdk.targetSdk
+        versionCode = Sdk.versionCode
+        versionName = Sdk.versionName
+
+        testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
+        vectorDrawables {
+            useSupportLibrary = true
+        }
+    }
+
+    buildTypes {
+        release {
+            isMinifyEnabled = false
+            proguardFiles(
+                getDefaultProguardFile("proguard-android-optimize.txt"),
+                "proguard-rules.pro"
+            )
+        }
+    }
+    compileOptions {
+        sourceCompatibility = JavaVersion.VERSION_1_8
+        targetCompatibility = JavaVersion.VERSION_1_8
+    }
+
+    kotlinOptions {
+        jvmTarget = "1.8"
+    }
+
+    buildFeatures {
+        compose = true
+    }
+
+    composeOptions {
+        kotlinCompilerExtensionVersion = Sdk.compose
+    }
+
+    packagingOptions {
+        resources {
+            excludes += "/META-INF/{AL2.0,LGPL2.1}"
+
+        }
+    }
+}
+dependencies {
+
+    // androidx
+    implementation(Deps.Androidx.Core)
+    implementation(Deps.Androidx.Appcompat)
+
+    // google
+    implementation(Deps.Google.Material)
+    implementation(Deps.Google.Accompanist.Coil)
+    implementation(Deps.Google.Accompanist.Insets)
+    implementation(Deps.Google.Gson)
+
+    // lifecycle
+    implementation(Deps.Lifecycle.Runtime)
+    implementation(Deps.Lifecycle.Livedata)
+    implementation(Deps.Lifecycle.ViewModel)
+    implementation(Deps.Lifecycle.Compose)
+
+    // room
+    kapt(Deps.Room.Compiler)
+    implementation(Deps.Room.Ktx)
+    implementation(Deps.Room.Runtime)
+
+    // navigation
+    implementation(Deps.Navigation.Runtime)
+    implementation(Deps.Navigation.Compose)
+
+    // kodein
+    implementation(Deps.Kodein.Di)
+    implementation(Deps.Kodein.Compose)
+    implementation(Deps.Kodein.Androidx)
+    implementation(Deps.Kodein.ViewModel)
+
+    // kotlinx
+    implementation(Deps.Kotlinx.Json)
+
+    // square
+    implementation(Deps.Square.Retrofit)
+    implementation(Deps.Square.Converter.Gson)
+    implementation(Deps.Square.Interceptor.Logging)
+
+    // Compose
+    implementation(Deps.Compose.Animation)
+    implementation(Deps.Compose.Compiler)
+    implementation(Deps.Compose.Foundation)
+    implementation(Deps.Compose.Material.Material)
+    implementation(Deps.Compose.Material.Extended)
+    implementation(Deps.Compose.Runtime.Runtime)
+    implementation(Deps.Compose.Runtime.LiveData)
+    implementation(Deps.Compose.UI.UI)
+    implementation(Deps.Compose.UI.Preview)
+    implementation(Deps.Compose.UI.Tooling)
+    implementation(Deps.Compose.Paging)
+    implementation(Deps.Compose.ConstraintLayout)
+
+    // .Compose
+    implementation(Deps.Androidx.Compose)
+    implementation(Deps.Lifecycle.Compose)
+    implementation(Deps.Navigation.Compose)
+
+    // test
+    testImplementation(Deps.Test.Junit)
+    testImplementation(Deps.Room.Test)
+    androidTestImplementation(Deps.AndroidXTest.Espresso)
+    androidTestImplementation(Deps.Compose.Test.Compose)
+    androidTestImplementation(Deps.AndroidXTest.Ktx)
+    androidTestImplementation(Deps.AndroidXTest.Ext)
+    debugImplementation(Deps.Compose.Debug.Tooling)
+}

+ 0 - 21
build.gradle

@@ -1,21 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-buildscript {
-    ext {
-        compose_version = '1.0.0'
-    }
-    repositories {
-        google()
-        mavenCentral()
-    }
-    dependencies {
-        classpath "com.android.tools.build:gradle:7.0.0"
-        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
-
-        // NOTE: Do not place your application dependencies here; they belong
-        // in the individual module build.gradle files
-    }
-}
-
-task clean(type: Delete) {
-    delete rootProject.buildDir
-}

+ 5 - 0
build.gradle.kts

@@ -0,0 +1,5 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+
+tasks.register("clean", Delete::class) {
+    delete(rootProject.buildDir)
+}

+ 1 - 0
buildSrc/.gitignore

@@ -0,0 +1 @@
+/build

+ 7 - 0
buildSrc/build.gradle.kts

@@ -0,0 +1,7 @@
+plugins {
+    `kotlin-dsl`
+}
+
+repositories {
+    mavenCentral()
+}

+ 155 - 0
buildSrc/src/main/kotlin/Build.kt

@@ -0,0 +1,155 @@
+object Sdk {
+    const val kotlin = "1.5.31"
+    const val compose = "1.0.5"
+    const val compileSdk = 31
+    const val minSdk = 28
+    const val targetSdk = 31
+    const val versionCode = 1
+    const val versionName = "1.0"
+    const val buildToolsVersion = "31.0.0"
+}
+
+object Deps {
+    object Androidx {
+        const val Core = "androidx.core:core-ktx:1.7.0"
+        const val Appcompat = "androidx.appcompat:appcompat:1.4.0"
+        const val Compose = "androidx.activity:activity-compose:1.4.0"
+    }
+
+    object Compose {
+        private const val compose = "1.0.5"
+
+        const val Animation = "androidx.compose.animation:animation:$compose"
+        const val Compiler = "androidx.compose.compiler:compiler:$compose"
+        const val Foundation = "androidx.compose.foundation:foundation:$compose"
+
+        object Material {
+            const val Material = "androidx.compose.material:material:$compose"
+            const val Material3 = "androidx.compose.material3:material3:1.0.0-alpha01"
+            const val Core = "androidx.compose.material:material-icons-core:$compose"
+            const val Extended =
+                "androidx.compose.material:material-icons-extended:$compose"
+        }
+
+        object Runtime {
+            const val Runtime = "androidx.compose.runtime:runtime:$compose"
+            const val LiveData = "androidx.compose.runtime:runtime-livedata:$compose"
+        }
+
+        object UI {
+            const val UI = "androidx.compose.ui:ui:$compose"
+            const val Preview = "androidx.compose.ui:ui-tooling-preview:$compose"
+            const val Tooling = "androidx.compose.ui:ui-tooling:$compose"
+            const val Manifest = "androidx.compose.ui:ui-test-manifest:$compose"
+        }
+
+        object Test {
+            const val Compose = "androidx.compose.ui:ui-test-junit4:$compose"
+        }
+
+        object Debug {
+            const val Tooling = "androidx.compose.ui:ui-tooling:$compose"
+        }
+
+        const val ConstraintLayout =
+            "androidx.constraintlayout:constraintlayout-compose:1.0.0-rc02"
+
+        const val Paging = "androidx.paging:paging-compose:1.0.0-alpha14"
+    }
+
+    object Google {
+        const val Material = "com.google.android.material:material:1.4.0"
+        const val Gson = "com.google.code.gson:gson:2.8.9"
+
+        object Accompanist {
+            private const val accompanist = "0.10.0"
+            const val Coil =
+                "com.google.accompanist:accompanist-coil:$accompanist"
+            const val Insets =
+                "com.google.accompanist:accompanist-insets:$accompanist"
+        }
+    }
+
+    object Lifecycle {
+        private const val lifecycle = "2.4.0"
+        const val Runtime =
+            "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle"
+        const val Livedata =
+            "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle"
+        const val ViewModel =
+            "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle"
+        const val Compose =
+            "androidx.lifecycle:lifecycle-viewmodel-compose:$lifecycle"
+    }
+
+    object Room {
+        private const val room = "2.4.0-rc01"
+        const val Runtime = "androidx.room:room-runtime:$room"
+        const val Compiler = "androidx.room:room-compiler:$room"
+        const val Ktx = "androidx.room:room-ktx:$room"
+        const val Test = "androidx.room:room-testing:$room"
+    }
+
+    object Navigation {
+        const val Compose =
+            "androidx.navigation:navigation-compose:2.4.0-beta02"
+        const val Runtime =
+            "androidx.navigation:navigation-runtime-ktx:2.3.5"
+        const val Ktx =
+            "androidx.navigation:navigation-ui-ktx:2.3.5"
+    }
+
+    object Kodein {
+        // kodein
+        private const val kodein = "7.9.0"
+        const val Di = "org.kodein.di:kodein-di:$kodein"
+        const val Compose = "org.kodein.di:kodein-di-framework-compose:$kodein"
+        const val Androidx = "org.kodein.di:kodein-di-framework-android-x:$kodein"
+        const val ViewModel =
+            "org.kodein.di:kodein-di-framework-android-x-viewmodel:$kodein"
+        const val SavedStateHandle =
+            "org.kodein.di:kodein-di-framework-android-x-viewmodel-savedstatehandle:$kodein"
+    }
+
+    object Kotlinx {
+        const val Json =
+            "org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0"
+    }
+
+    object Square {
+        private const val retrofit = "2.9.0"
+        private const val log = "4.9.0"
+        private const val moshi = "1.12.0"
+
+        const val Retrofit = "com.squareup.retrofit2:retrofit:$retrofit"
+
+        object Converter {
+            const val Gson =
+                "com.squareup.retrofit2:converter-gson:$retrofit"
+            const val Scalars =
+                "com.squareup.retrofit2:converter-scalars:$retrofit"
+            const val Moshi = "com.squareup.retrofit2:converter-moshi:$retrofit"
+        }
+
+        object Interceptor {
+            const val Logging =
+                "com.squareup.okhttp3:logging-interceptor:$log"
+        }
+
+        object Moshi {
+            const val Moshi = "com.squareup.moshi:moshi:$moshi"
+            const val Codegen = "com.squareup.moshi:moshi-kotlin-codegen:$moshi"
+        }
+    }
+
+    object Test {
+        const val Junit = "junit:junit:4.13.2"
+    }
+
+    object AndroidXTest {
+        const val Ext = "androidx.test.ext:junit:1.1.3"
+        const val Ktx = "androidx.test.ext:junit-ktx:1.1.3"
+        const val Espresso = "androidx.test.espresso:espresso-core:3.4.0"
+        const val UI = "androidx.ui:ui-test:1.0.0-alpha07"
+    }
+}

+ 0 - 10
settings.gradle

@@ -1,10 +0,0 @@
-dependencyResolutionManagement {
-    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
-    repositories {
-        google()
-        mavenCentral()
-        jcenter() // Warning: this repository is going to shut down soon
-    }
-}
-rootProject.name = "Adm"
-include ':app'

+ 21 - 0
settings.gradle.kts

@@ -0,0 +1,21 @@
+pluginManagement {
+    repositories {
+        gradlePluginPortal()
+        google()
+        mavenCentral()
+    }
+    plugins {
+        id("com.android.application") version "7.0.4"
+        id("com.android.library") version "7.0.4"
+        id("org.jetbrains.kotlin.android") version "1.5.31"
+    }
+}
+dependencyResolutionManagement {
+    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
+    repositories {
+        google()
+        mavenCentral()
+    }
+}
+rootProject.name = "Adm"
+include(":app")