Skip to content

Commit

Permalink
done migration
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanusMokrassar committed Aug 8, 2023
1 parent 4478193 commit 57ebed9
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 58 deletions.
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand All @@ -185,40 +183,17 @@ 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()
)
}

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}"
Expand All @@ -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()
)
Expand Down
File renamed without changes.
15 changes: 10 additions & 5 deletions local.migrate.folder.sh
Original file line number Diff line number Diff line change
@@ -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"
2 changes: 1 addition & 1 deletion mppAndroidProject.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ project.group = "$group"
apply from: "$publishGradlePath"

kotlin {
androidTarget {
android {
publishAllLibraryVariants()
}

Expand Down
4 changes: 2 additions & 2 deletions mppProjectWithSerialization.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ kotlin {
browser()
nodejs()
}
androidTarget {
android {
publishAllLibraryVariants()
}
linuxX64()
Expand Down Expand Up @@ -45,7 +45,7 @@ kotlin {
implementation kotlin('test-junit')
}
}
androidTest {
androidUnitTest {
dependencies {
implementation kotlin('test-junit')
implementation libs.android.test.junit
Expand Down
4 changes: 2 additions & 2 deletions mppProjectWithSerializationAndCompose.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ kotlin {
browser()
nodejs()
}
androidTarget {
android {
publishAllLibraryVariants()
}

Expand Down Expand Up @@ -54,7 +54,7 @@ kotlin {
implementation kotlin('test-junit')
}
}
androidTest {
androidUnitTest {
dependencies {
implementation kotlin('test-junit')
implementation libs.android.test.junit
Expand Down
File renamed without changes.

0 comments on commit 57ebed9

Please sign in to comment.