Допиливание системы зависимостей
This commit is contained in:
Generated
+1
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
|
||||
+15
-2
@@ -56,16 +56,29 @@ android {
|
||||
|
||||
}
|
||||
|
||||
tasks.register("connectToWSA"){
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
//std lib
|
||||
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
|
||||
//app libs
|
||||
/* //app libs
|
||||
implementation(AppDependencies.appLibraries)
|
||||
//test libs
|
||||
testImplementation(AppDependencies.testLibraries)
|
||||
androidTestImplementation(AppDependencies.androidTestLibraries)
|
||||
|
||||
coreLibraryDesugaring(AppDependencies.desugaringLibraries)
|
||||
debugImplementation(AppDependencies.debugLibraries)
|
||||
debugImplementation(AppDependencies.debugLibraries)*/
|
||||
|
||||
//app libs
|
||||
implementation(AppLibraries)
|
||||
//test libs
|
||||
testImplementation(TestLibraries)
|
||||
androidTestImplementation(AndroidTestLibraries)
|
||||
|
||||
coreLibraryDesugaring(DesugaringLibraries)
|
||||
debugImplementation(DebugLibraries)
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package ru.megboyzz.dnevnik
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.window.SplashScreen
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.compose.foundation.layout.*
|
||||
@@ -12,7 +10,6 @@ import ru.megboyzz.dnevnik.navigation.AppNavHost
|
||||
import ru.megboyzz.dnevnik.ui.theme.*
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
|
||||
@@ -1,88 +1,74 @@
|
||||
import org.gradle.api.artifacts.dsl.DependencyHandler
|
||||
|
||||
//TODO - придумать обработчик зависмостей основанный на рефлексии
|
||||
object AppDependencies {
|
||||
|
||||
object AppLibraries: DependencyList() {
|
||||
|
||||
//std lib
|
||||
val kotlinStdLib = "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin}"
|
||||
|
||||
//android ui
|
||||
private val appcompat = "androidx.appcompat:appcompat:${Versions.appcompat}"
|
||||
private val coreKtx = "androidx.core:core-ktx:${Versions.coreKtx}"
|
||||
private val lifecycleRuntimeKtx = "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
|
||||
val appcompat = "androidx.appcompat:appcompat:${Versions.appcompat}"
|
||||
val coreKtx = "androidx.core:core-ktx:${Versions.coreKtx}"
|
||||
val lifecycleRuntimeKtx = "androidx.lifecycle:lifecycle-runtime-ktx:2.3.1"
|
||||
|
||||
//compose
|
||||
private val composeConstraintLayout =
|
||||
val composeConstraintLayout =
|
||||
"androidx.constraintlayout:constraintlayout-compose:1.0.1"
|
||||
private val composeUi = "androidx.compose.ui:ui:${Versions.compose}"
|
||||
private val composeMaterial = "androidx.compose.material:material:${Versions.compose}"
|
||||
private val composePreview = "androidx.compose.ui:ui-tooling-preview:${Versions.compose}"
|
||||
private val composeActivity = "androidx.activity:activity-compose:1.7.0"
|
||||
private val composeIcons = "androidx.compose.material:material-icons-extended:${Versions.compose}"
|
||||
private val composeGraphics = "androidx.compose.ui:ui-graphics:${Versions.compose}"
|
||||
val composeUi = "androidx.compose.ui:ui:${Versions.compose}"
|
||||
val composeMaterial = "androidx.compose.material:material:${Versions.compose}"
|
||||
val composePreview = "androidx.compose.ui:ui-tooling-preview:${Versions.compose}"
|
||||
val composeActivity = "androidx.activity:activity-compose:1.7.0"
|
||||
val composeIcons = "androidx.compose.material:material-icons-extended:${Versions.compose}"
|
||||
val composeGraphics = "androidx.compose.ui:ui-graphics:${Versions.compose}"
|
||||
|
||||
//navigation
|
||||
val composeNavigation = "androidx.navigation:navigation-compose:2.5.3"
|
||||
|
||||
//other
|
||||
val pieChartLib = "com.github.PhilJay:MPAndroidChart:v3.1.0"
|
||||
val retrofit = "com.squareup.retrofit2:retrofit:2.6.4"
|
||||
val retrofitConverterGson = "com.squareup.retrofit2:converter-gson:2.3.0"
|
||||
val accompanist = "com.google.accompanist:accompanist-swiperefresh:0.23.0"
|
||||
val lazyHorizontalGrid = "androidx.compose.foundation:foundation:1.3.1"
|
||||
val calendar = "com.kizitonwose.calendar:compose:2.1.1"
|
||||
val asyncImage = "io.coil-kt:coil-compose:2.2.0"
|
||||
|
||||
}
|
||||
|
||||
object DebugLibraries: DependencyList() {
|
||||
|
||||
//compose-debug
|
||||
private val composeUiTooling = "androidx.compose.ui:ui-tooling:${Versions.compose}"
|
||||
private val composeTestManifest = "androidx.compose.ui:ui-test-manifest:${Versions.compose}"
|
||||
|
||||
}
|
||||
|
||||
//navigation
|
||||
private val composeNavigation = "androidx.navigation:navigation-compose:2.5.3"
|
||||
object DesugaringLibraries: DependencyList() {
|
||||
|
||||
val desugarJdk = "com.android.tools:desugar_jdk_libs:${Versions.desugarJdkVersion}"
|
||||
|
||||
}
|
||||
|
||||
//other
|
||||
private val pieChartLib = "com.github.PhilJay:MPAndroidChart:v3.1.0"
|
||||
private val retrofit = "com.squareup.retrofit2:retrofit:2.6.4"
|
||||
private val retrofitConverterGson = "com.squareup.retrofit2:converter-gson:2.3.0"
|
||||
private val accompanist = "com.google.accompanist:accompanist-swiperefresh:0.23.0"
|
||||
private val lazyHorizontalGrid = "androidx.compose.foundation:foundation:1.3.1"
|
||||
private val calendar = "com.kizitonwose.calendar:compose:2.1.1"
|
||||
private val asyncImage = "io.coil-kt:coil-compose:2.2.0"
|
||||
object AndroidTestLibraries: DependencyList() {
|
||||
|
||||
//test libs
|
||||
private val junit = "junit:junit:${Versions.junit}"
|
||||
private val extJUnit = "androidx.test.ext:junit:${Versions.extJunit}"
|
||||
private val espressoCore = "androidx.test.espresso:espresso-core:${Versions.espresso}"
|
||||
|
||||
//desugaring
|
||||
private val desugarJdk = "com.android.tools:desugar_jdk_libs:${Versions.desugarJdkVersion}"
|
||||
|
||||
val appLibraries = arrayListOf<String>().apply {
|
||||
add(kotlinStdLib)
|
||||
add(coreKtx)
|
||||
add(appcompat)
|
||||
add(composeConstraintLayout)
|
||||
add(composeUi)
|
||||
add(composeMaterial)
|
||||
add(composePreview)
|
||||
add(composeActivity)
|
||||
add(composeIcons)
|
||||
add(pieChartLib)
|
||||
add(composeNavigation)
|
||||
add(retrofit)
|
||||
add(retrofitConverterGson)
|
||||
add(accompanist)
|
||||
add(lazyHorizontalGrid)
|
||||
add(asyncImage)
|
||||
add(calendar)
|
||||
}
|
||||
|
||||
val desugaringLibraries = arrayListOf<String>().apply {
|
||||
add(desugarJdk)
|
||||
}
|
||||
|
||||
val debugLibraries = arrayListOf<String>().apply {
|
||||
add(composeUiTooling)
|
||||
add(composeTestManifest)
|
||||
}
|
||||
|
||||
val androidTestLibraries = arrayListOf<String>().apply {
|
||||
add(extJUnit)
|
||||
add(espressoCore)
|
||||
}
|
||||
|
||||
val testLibraries = arrayListOf<String>().apply {
|
||||
add(junit)
|
||||
}
|
||||
val extJUnit = "androidx.test.ext:junit:${Versions.extJunit}"
|
||||
val espressoCore = "androidx.test.espresso:espresso-core:${Versions.espresso}"
|
||||
|
||||
}
|
||||
|
||||
object TestLibraries: DependencyList() {
|
||||
//test libs
|
||||
private val junit = "junit:junit:${Versions.junit}"
|
||||
}
|
||||
|
||||
/**
|
||||
* Старый подход
|
||||
* создать переменную список зависимостей
|
||||
* раньше это был целый класс, котором объявлялись переменные
|
||||
*/
|
||||
|
||||
|
||||
//util functions for adding the different type dependencies from build.gradle file
|
||||
|
||||
@@ -92,32 +78,58 @@ fun DependencyHandler.kapt(list: List<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
fun DependencyHandler.kapt(list: DependencyList){
|
||||
this.kapt(list.list())
|
||||
}
|
||||
|
||||
fun DependencyHandler.implementation(list: List<String>) {
|
||||
list.forEach { dependency ->
|
||||
add("implementation", dependency)
|
||||
}
|
||||
}
|
||||
|
||||
fun DependencyHandler.implementation(list: DependencyList){
|
||||
this.implementation(list.list())
|
||||
}
|
||||
|
||||
|
||||
fun DependencyHandler.testImplementation(list: List<String>){
|
||||
list.forEach { dependency ->
|
||||
add("testImplementation", dependency)
|
||||
}
|
||||
}
|
||||
|
||||
fun DependencyHandler.testImplementation(list: DependencyList){
|
||||
this.testImplementation(list.list())
|
||||
}
|
||||
|
||||
|
||||
fun DependencyHandler.androidTestImplementation(list: List<String>){
|
||||
list.forEach { dependency ->
|
||||
add("androidTestImplementation", dependency)
|
||||
}
|
||||
}
|
||||
|
||||
fun DependencyHandler.androidTestImplementation(list: DependencyList){
|
||||
this.androidTestImplementation(list.list())
|
||||
}
|
||||
|
||||
fun DependencyHandler.coreLibraryDesugaring(list: List<String>){
|
||||
list.forEach { dependency ->
|
||||
add("coreLibraryDesugaring", dependency)
|
||||
}
|
||||
}
|
||||
|
||||
fun DependencyHandler.coreLibraryDesugaring(list: DependencyList){
|
||||
this.coreLibraryDesugaring(list.list())
|
||||
}
|
||||
|
||||
fun DependencyHandler.debugImplementation(list: List<String>){
|
||||
list.forEach { dependency ->
|
||||
add("debugImplementation", dependency)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun DependencyHandler.debugImplementation(list: DependencyList){
|
||||
this.debugImplementation(list.list())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
open class DependencyList {
|
||||
|
||||
fun list(): List<String>{
|
||||
val list = mutableListOf<String>()
|
||||
this::class.java.methods.filter {
|
||||
it.name.startsWith("get")
|
||||
}.forEach {
|
||||
if(it.returnType.name == "java.lang.String")
|
||||
list.add(it.invoke(this).toString())
|
||||
}
|
||||
return list
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user