diff --git a/foundation/di/anvil-codegen/.gitignore b/foundation/di/anvil-codegen/.gitignore deleted file mode 100644 index 1603eacc..00000000 --- a/foundation/di/anvil-codegen/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/build -/out diff --git a/foundation/di/anvil-codegen/README_ru.md b/foundation/di/anvil-codegen/README_ru.md deleted file mode 100644 index f03f12c4..00000000 --- a/foundation/di/anvil-codegen/README_ru.md +++ /dev/null @@ -1,3 +0,0 @@ -# anvil-codegen - -Генератор anvil/dagger кода по аннотациям. diff --git a/foundation/di/anvil-codegen/di-anvil-codegen.gradle.kts b/foundation/di/anvil-codegen/di-anvil-codegen.gradle.kts deleted file mode 100644 index b42027c4..00000000 --- a/foundation/di/anvil-codegen/di-anvil-codegen.gradle.kts +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023, the Pixnews project authors and contributors. Please see the AUTHORS file for details. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - -import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions - -plugins { - id("ru.pixnews.gradle.kotlin.library") - kotlin("kapt") -} - -group = "ru.pixnews.foundation.di.anvil-codegen" - -tasks.withType>().configureEach { - compilerOptions { - freeCompilerArgs.addAll( - "-opt-in=com.squareup.anvil.annotations.ExperimentalAnvilApi", - "-opt-in=org.jetbrains.kotlin.compiler.plugin.ExperimentalCompilerApi", - ) - } -} - -dependencies { - implementation(projects.foundation.di.base) - - api(libs.inject) - api(libs.anvil.compiler.api) - implementation(libs.anvil.compiler.utils) - implementation(libs.kotlinpoet) - implementation(libs.dagger) - - compileOnly(libs.auto.service.annotations) - kapt(libs.auto.service.compiler) - - testImplementation(libs.anvil.annotations.optional) - testImplementation(testFixtures(libs.anvil.compiler.utils)) - testImplementation(libs.kotest.assertions.core) -} diff --git a/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/AnnotationSpecs.kt b/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/AnnotationSpecs.kt deleted file mode 100644 index 6876fa51..00000000 --- a/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/AnnotationSpecs.kt +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2023, the Pixnews project authors and contributors. Please see the AUTHORS file for details. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - -package ru.pixnews.foundation.di.anvil.codegen.util - -import com.squareup.kotlinpoet.AnnotationSpec -import com.squareup.kotlinpoet.ClassName -import com.squareup.kotlinpoet.TypeName - -/** - * `@ContributesTo(className::class, replaces = [..])` - */ -internal fun contributesToAnnotation( - className: ClassName, - replaces: List = emptyList(), -): AnnotationSpec { - return with(AnnotationSpec.builder(ClassNames.Anvil.contributesTo)) { - addMember("%T::class", className) - if (replaces.isNotEmpty()) { - @Suppress("SpreadOperator") - addMember( - "replaces = [${replaces.joinToString(",") { "%T::class" }}]", - *replaces.toTypedArray(), - ) - } - build() - } -} - -/** - * `@ContributesTo(className::class)` - */ -internal fun contributesMultibindingAnnotation(scope: ClassName): AnnotationSpec { - return AnnotationSpec.builder(ClassNames.Anvil.contributesMultibinding) - .addMember("scope = %T::class", scope) - .build() -} diff --git a/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/ClassNames.kt b/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/ClassNames.kt deleted file mode 100644 index deab7981..00000000 --- a/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/ClassNames.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2023, the Pixnews project authors and contributors. Please see the AUTHORS file for details. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - -package ru.pixnews.foundation.di.anvil.codegen.util - -import com.squareup.anvil.annotations.ContributesMultibinding -import com.squareup.anvil.annotations.ContributesTo -import com.squareup.kotlinpoet.ClassName -import com.squareup.kotlinpoet.asClassName -import dagger.Binds -import dagger.MembersInjector -import dagger.Module -import dagger.Provides -import dagger.Reusable -import dagger.assisted.AssistedFactory -import dagger.multibindings.ClassKey -import dagger.multibindings.IntoMap -import dagger.multibindings.IntoSet -import ru.pixnews.foundation.di.base.qualifiers.ApplicationContext -import ru.pixnews.foundation.di.base.scopes.AppScope - -internal object ClassNames { - val applicationContext = ApplicationContext::class.asClassName() - val singleIn = ClassName("com.squareup.anvil.annotations.optional", "SingleIn") - val activityMapKey = ClassName("ru.pixnews.foundation.di.ui.base.activity", "ActivityMapKey") - val coroutineWorkerMapKey = ClassName("ru.pixnews.foundation.di.workmanager", "CoroutineWorkerMapKey") - val appInitializersScope = ClassName("ru.pixnews.foundation.initializers.inject", "AppInitializersScope") - val appScope = AppScope::class.asClassName() - val coroutineWorkerFactory = ClassName("ru.pixnews.foundation.di.workmanager", "CoroutineWorkerFactory") - val workManagerScope: ClassName = ClassName("ru.pixnews.foundation.di.workmanager", "WorkManagerScope") - val experiment = ClassName("ru.pixnews.foundation.featuretoggles", "Experiment") - val experimentScope = ClassName("ru.pixnews.foundation.featuretoggles.inject", "ExperimentScope") - val experimentVariantMapKey = ClassName("ru.pixnews.foundation.featuretoggles.inject", "ExperimentVariantMapKey") - val experimentVariantSerializer = ClassName("ru.pixnews.foundation.featuretoggles", "ExperimentVariantSerializer") - val singleInstrumentedTestInjector = ClassName( - packageName = "ru.pixnews.foundation.instrumented.test.di", - "SingleInstrumentedTestInjector", - ) - val viewModelFactory = ClassName("ru.pixnews.foundation.di.ui.base.viewmodel", "ViewModelFactory") - val viewModelMapKey = ClassName("ru.pixnews.foundation.di.ui.base.viewmodel", "ViewModelMapKey") - val viewModelScope = ClassName("ru.pixnews.foundation.di.ui.base.viewmodel", "ViewModelScope") - val asyncInitializer = ClassName("ru.pixnews.foundation.initializers", "AsyncInitializer") - val initializer = ClassName("ru.pixnews.foundation.initializers", "Initializer") - - internal object Anvil { - val contributesMultibinding = ContributesMultibinding::class.asClassName() - val contributesTo = ContributesTo::class.asClassName() - } - - internal object Dagger { - val assistedFactory = AssistedFactory::class.asClassName() - val binds = Binds::class.asClassName() - val classKey = ClassKey::class.asClassName() - val intoMap = IntoMap::class.asClassName() - val intoSet = IntoSet::class.asClassName() - val membersInjector = MembersInjector::class.asClassName() - val module = Module::class.asClassName() - val provides = Provides::class.asClassName() - val reusable = Reusable::class.asClassName() - } - - internal object Android { - val activity = ClassName("android.app", "Activity") - val context = ClassName("android.content", "Context") - val savedStateHandle = ClassName("androidx.lifecycle", "SavedStateHandle") - val workerParameters = ClassName("androidx.work", "WorkerParameters") - } -} diff --git a/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/ConstructorParameter.kt b/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/ConstructorParameter.kt deleted file mode 100644 index 1504f330..00000000 --- a/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/ConstructorParameter.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (c) 2023, the Pixnews project authors and contributors. Please see the AUTHORS file for details. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - -package ru.pixnews.foundation.di.anvil.codegen.util - -import com.squareup.anvil.compiler.internal.reference.ClassReference -import com.squareup.anvil.compiler.internal.reference.ParameterReference -import com.squareup.kotlinpoet.TypeName -import ru.pixnews.foundation.di.anvil.codegen.util.ClassNames.Android - -internal class ConstructorParameter( - val name: String, - val resolvedType: TypeName, -) - -internal fun ConstructorParameter.isSavedStateHandle(): Boolean = resolvedType == Android.savedStateHandle - -internal fun List.parseConstructorParameters( - implementingClass: ClassReference, -): List = this.map { - ConstructorParameter(it.name, it.resolveTypeName(implementingClass)) -} diff --git a/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/FqNames.kt b/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/FqNames.kt deleted file mode 100644 index 9a7ec9f2..00000000 --- a/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/FqNames.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023, the Pixnews project authors and contributors. Please see the AUTHORS file for details. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - -package ru.pixnews.foundation.di.anvil.codegen.util - -import com.squareup.kotlinpoet.ClassName -import org.jetbrains.kotlin.name.FqName - -internal object FqNames { - val contributesActivity = FqName("ru.pixnews.foundation.di.ui.base.activity.ContributesActivity") - val contributesCoroutineWorker = FqName("ru.pixnews.foundation.di.workmanager.ContributesCoroutineWorker") - val contributesExperiment = FqName("ru.pixnews.foundation.featuretoggles.inject.ContributesExperiment") - val contributesInitializer = FqName("ru.pixnews.foundation.initializers.inject.ContributesInitializer") - val contributesTest = FqName("ru.pixnews.foundation.instrumented.test.di.ContributesTest") - val contributesVariantSerializer = FqName( - "ru.pixnews.foundation.featuretoggles.inject.ContributesExperimentVariantSerializer", - ) - val contributesViewModel = FqName("ru.pixnews.foundation.di.ui.base.viewmodel.ContributesViewModel") - val experiment = ClassNames.experiment.asFqName() - val experimentVariantSerializer = ClassNames.experimentVariantSerializer.asFqName() - - internal object Android { - val activity = ClassNames.Android.activity.asFqName() - val coroutineWorker = FqName("androidx.work.CoroutineWorker") - val viewModel = FqName("androidx.lifecycle.ViewModel") - } - - private fun ClassName.asFqName(): FqName = FqName(this.canonicalName) -} diff --git a/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/Preconditions.kt b/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/Preconditions.kt deleted file mode 100644 index 731e43f1..00000000 --- a/foundation/di/anvil-codegen/main/ru/pixnews/foundation/di/anvil/codegen/util/Preconditions.kt +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2023, the Pixnews project authors and contributors. Please see the AUTHORS file for details. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - -package ru.pixnews.foundation.di.anvil.codegen.util - -import com.squareup.anvil.compiler.internal.reference.AnvilCompilationExceptionClassReference -import com.squareup.anvil.compiler.internal.reference.ClassReference -import com.squareup.anvil.compiler.internal.reference.allSuperTypeClassReferences -import org.jetbrains.kotlin.name.FqName - -internal fun ClassReference.checkClassExtendsType(type: FqName) { - if (allSuperTypeClassReferences().none { it.fqName == type }) { - throw AnvilCompilationExceptionClassReference( - message = "${this.fqName} doesn't extend $type", - classReference = this, - ) - } -} - -internal fun ClassReference.checkClassExtendsAnyOfType( - vararg types: FqName, -) { - if (allSuperTypeClassReferences().none { it.fqName in types }) { - throw AnvilCompilationExceptionClassReference( - message = "${this.fqName} doesn't extend any od $types", - classReference = this, - ) - } -} diff --git a/foundation/di/anvil-codegen/test/ru/pixnews/foundation/di/anvil/codegen/util/TestingUtils.kt b/foundation/di/anvil-codegen/test/ru/pixnews/foundation/di/anvil/codegen/util/TestingUtils.kt deleted file mode 100644 index 2343c827..00000000 --- a/foundation/di/anvil-codegen/test/ru/pixnews/foundation/di/anvil/codegen/util/TestingUtils.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright (c) 2023, the Pixnews project authors and contributors. Please see the AUTHORS file for details. - * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. - */ - -package ru.pixnews.foundation.di.anvil.codegen.util - -import com.squareup.kotlinpoet.ClassName - -fun ClassLoader.loadClass(clazz: ClassName): Class<*> = this.loadClass(clazz.canonicalName) - -@Suppress("UNCHECKED_CAST") -public fun Annotation.getElementValue(elementName: String): T = - this::class.java.declaredMethods.single { it.name == elementName }.invoke(this) as T diff --git a/foundation/di/workmanager/src/main/kotlin/ru/pixnews/foundation/di/workmanager/WorkManagerSubcomponentModule.kt b/foundation/di/workmanager/src/main/kotlin/ru/pixnews/foundation/di/workmanager/WorkManagerSubcomponentModule.kt index 6765c17c..1d5a1f05 100644 --- a/foundation/di/workmanager/src/main/kotlin/ru/pixnews/foundation/di/workmanager/WorkManagerSubcomponentModule.kt +++ b/foundation/di/workmanager/src/main/kotlin/ru/pixnews/foundation/di/workmanager/WorkManagerSubcomponentModule.kt @@ -19,5 +19,5 @@ import ru.pixnews.foundation.di.base.DaggerMap @RestrictTo(RestrictTo.Scope.LIBRARY) public interface WorkManagerSubcomponentModule { @Multibinds - public fun workerProviders(): DaggerMap, CoroutineWorkerFactory> + public fun workerFactories(): DaggerMap, CoroutineWorkerFactory> } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e40074ef..542b6066 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -5,7 +5,7 @@ targetSdk = "33" agp = "8.4.0-alpha04" android-tools-common = "31.4.0-alpha04" -anvil = "2.4.8" +anvil = "2.4.9" bmversions = "0.50.0" detekt = "1.23.4" diktat = "1.2.5" @@ -73,7 +73,7 @@ mockwebserver-dsl = "1.0.0" okhttp = "4.12.0" okio = "3.7.0" paparazzi = "1.3.2" -pixnews-anvil-codegen = "0.1-SNAPSHOT" +pixnews-anvil-codegen = "0.1" prefiller = "1.6.0-SNAPSHOT" retrofit = "2.9.0" radiography = "2.5" diff --git a/gradle/verification-keyring.keys b/gradle/verification-keyring.keys index 5cb9fafa..79cbdbe3 100644 --- a/gradle/verification-keyring.keys +++ b/gradle/verification-keyring.keys @@ -770,6 +770,35 @@ jKjGuiwdKSnkFbNcFS3g =2XPd -----END PGP PUBLIC KEY BLOCK----- +pub A325BAA35D60E68F +uid Rick Busarow (this process is painful) + +sub 2C1A2B57086C6522 +-----BEGIN PGP PUBLIC KEY BLOCK----- +Version: BCPG v1.68 + +mQENBF4JXMYBCACoC7KtRhpAkipoLMmehf+Oe9pdZA0unuaIPmtpte9i+ichAiSN +RlB81fREd53cluBGpeFTAnlGjuTX30ZGednQqV7GhMt5K9IqUHA6E1zZR5yDmfzH +gV415YdJDScB75VZD1NAbTT9bl1D3QSQpqCUKYyLY/aWXO7K5y4AYBEu9KGvywPc +0dVZgBvf4KCbP0KoSo9KegVPr+Spf/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IC KEY BLOCK----- diff --git a/gradle/verification-metadata.xml b/gradle/verification-metadata.xml index 530d390a..47c7c534 100644 --- a/gradle/verification-metadata.xml +++ b/gradle/verification-metadata.xml @@ -113,6 +113,7 @@ +