From 57ebed903f5390c96e1a4b0b0c066e5c7bfb9b58 Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 8 Aug 2023 18:45:36 +0600 Subject: [PATCH] done migration --- gradle.properties | 1 + .../{androidMain => main}/kotlin/Processor.kt | 50 +------------------ .../{androidMain => main}/kotlin/Provider.kt | 0 ...ols.ksp.processing.SymbolProcessorProvider | 0 local.migrate.folder.sh | 15 ++++-- mppAndroidProject.gradle | 2 +- mppProjectWithSerialization.gradle | 4 +- mppProjectWithSerializationAndCompose.gradle | 4 +- .../{androidMain => main}/kotlin/Processor.kt | 0 .../{androidMain => main}/kotlin/Provider.kt | 0 ...ols.ksp.processing.SymbolProcessorProvider | 0 11 files changed, 18 insertions(+), 58 deletions(-) rename koin/generator/src/{androidMain => main}/kotlin/Processor.kt (84%) rename koin/generator/src/{androidMain => main}/kotlin/Provider.kt (100%) rename koin/generator/src/{androidMain => main}/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider (100%) rename repos/generator/src/{androidMain => main}/kotlin/Processor.kt (100%) rename repos/generator/src/{androidMain => main}/kotlin/Provider.kt (100%) rename repos/generator/src/{androidMain => main}/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider (100%) diff --git a/gradle.properties b/gradle.properties index be8f66a16f9..d5225567187 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,7 @@ org.gradle.parallel=true kotlin.js.generate.externals=true kotlin.incremental=true kotlin.incremental.js=true +#kotlin.experimental.tryK2=true android.useAndroidX=true android.enableJetifier=true org.gradle.jvmargs=-Xmx2g diff --git a/koin/generator/src/androidMain/kotlin/Processor.kt b/koin/generator/src/main/kotlin/Processor.kt similarity index 84% rename from koin/generator/src/androidMain/kotlin/Processor.kt rename to koin/generator/src/main/kotlin/Processor.kt index 8f906e87074..ed77e14d7d1 100644 --- a/koin/generator/src/androidMain/kotlin/Processor.kt +++ b/koin/generator/src/main/kotlin/Processor.kt @@ -159,9 +159,7 @@ class Processor( } if (generateSingle) { - fun FunSpec.Builder.configure( - useInstead: String? = null - ) { + fun FunSpec.Builder.configure() { addKdoc( """ Will register [definition] with [org.koin.core.module.Module.single] and key "${name}" @@ -185,30 +183,9 @@ class Processor( addTypeVariable(it) addModifiers(KModifier.INLINE) } - if (useInstead != null) { - addAnnotation( - AnnotationSpec.builder( - Deprecated::class - ).apply { - addMember( - CodeBlock.of( - """ - "This definition is old style and should not be used anymore. Use $useInstead instead" - """.trimIndent() - ) - ) - addMember(CodeBlock.of("ReplaceWith(\"$useInstead\")")) - }.build() - ) - } } val actualSingleName = "single${name.replaceFirstChar { it.uppercase() }}" - if (targetTypeAsGenericType == null) { // classic type - addFunction( - FunSpec.builder("${name}Single").apply { configure(actualSingleName) }.build() - ) - } addFunction( FunSpec.builder(actualSingleName).apply { configure() }.build() @@ -216,9 +193,7 @@ class Processor( } if (generateFactory) { - fun FunSpec.Builder.configure( - useInstead: String? = null - ) { + fun FunSpec.Builder.configure() { addKdoc( """ Will register [definition] with [org.koin.core.module.Module.factory] and key "${name}" @@ -234,29 +209,8 @@ class Processor( addTypeVariable(it) addModifiers(KModifier.INLINE) } - if (useInstead != null) { - addAnnotation( - AnnotationSpec.builder( - Deprecated::class - ).apply { - addMember( - CodeBlock.of( - """ - "This definition is old style and should not be used anymore. Use $useInstead instead" - """.trimIndent() - ) - ) - addMember(CodeBlock.of("ReplaceWith(\"$useInstead\")")) - }.build() - ) - } } val actualFactoryName = "factory${name.replaceFirstChar { it.uppercase() }}" - if (targetTypeAsGenericType == null) { // classic type - addFunction( - FunSpec.builder("${name}Factory").apply { configure(useInstead = actualFactoryName) }.build() - ) - } addFunction( FunSpec.builder(actualFactoryName).apply { configure() }.build() ) diff --git a/koin/generator/src/androidMain/kotlin/Provider.kt b/koin/generator/src/main/kotlin/Provider.kt similarity index 100% rename from koin/generator/src/androidMain/kotlin/Provider.kt rename to koin/generator/src/main/kotlin/Provider.kt diff --git a/koin/generator/src/androidMain/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider b/koin/generator/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider similarity index 100% rename from koin/generator/src/androidMain/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider rename to koin/generator/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider diff --git a/local.migrate.folder.sh b/local.migrate.folder.sh index 13642e7ff0f..fc0d981188b 100755 --- a/local.migrate.folder.sh +++ b/local.migrate.folder.sh @@ -1,7 +1,12 @@ #!/bin/bash -for folder in $(find . -depth -type d -name "main"); -do - newFolder="`echo $folder | sed 's/main/androidMain/g'`" - mv $folder "$newFolder" -done +function renameFolders() { + for folder in $(find . -depth -type d -name "$1"); + do + sedString="s/$1/$2/g" + newFolder="$(echo $folder | sed $sedString)" + echo $folder "$newFolder" + done +} + +renameFolders "androidTest" "androidUnitTest" diff --git a/mppAndroidProject.gradle b/mppAndroidProject.gradle index a03ed759f7e..1817e67049d 100644 --- a/mppAndroidProject.gradle +++ b/mppAndroidProject.gradle @@ -4,7 +4,7 @@ project.group = "$group" apply from: "$publishGradlePath" kotlin { - androidTarget { + android { publishAllLibraryVariants() } diff --git a/mppProjectWithSerialization.gradle b/mppProjectWithSerialization.gradle index 9d508abc111..8d0239816e5 100644 --- a/mppProjectWithSerialization.gradle +++ b/mppProjectWithSerialization.gradle @@ -15,7 +15,7 @@ kotlin { browser() nodejs() } - androidTarget { + android { publishAllLibraryVariants() } linuxX64() @@ -45,7 +45,7 @@ kotlin { implementation kotlin('test-junit') } } - androidTest { + androidUnitTest { dependencies { implementation kotlin('test-junit') implementation libs.android.test.junit diff --git a/mppProjectWithSerializationAndCompose.gradle b/mppProjectWithSerializationAndCompose.gradle index 589aa293149..e7b75fbd456 100644 --- a/mppProjectWithSerializationAndCompose.gradle +++ b/mppProjectWithSerializationAndCompose.gradle @@ -15,7 +15,7 @@ kotlin { browser() nodejs() } - androidTarget { + android { publishAllLibraryVariants() } @@ -54,7 +54,7 @@ kotlin { implementation kotlin('test-junit') } } - androidTest { + androidUnitTest { dependencies { implementation kotlin('test-junit') implementation libs.android.test.junit diff --git a/repos/generator/src/androidMain/kotlin/Processor.kt b/repos/generator/src/main/kotlin/Processor.kt similarity index 100% rename from repos/generator/src/androidMain/kotlin/Processor.kt rename to repos/generator/src/main/kotlin/Processor.kt diff --git a/repos/generator/src/androidMain/kotlin/Provider.kt b/repos/generator/src/main/kotlin/Provider.kt similarity index 100% rename from repos/generator/src/androidMain/kotlin/Provider.kt rename to repos/generator/src/main/kotlin/Provider.kt diff --git a/repos/generator/src/androidMain/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider b/repos/generator/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider similarity index 100% rename from repos/generator/src/androidMain/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider rename to repos/generator/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider