File tree Expand file tree Collapse file tree 5 files changed +54
-10
lines changed
module-communication-plugin/src/main/kotlin/com/flyjingfish/module_communication_plugin Expand file tree Collapse file tree 5 files changed +54
-10
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,9 @@ plugins {
55 id(" communication.export" )
66}
77
8- communicationConfig{
9- exportModuleName = " communication2"
10- }
8+ // communicationConfig{
9+ // exportModuleName = "communication2"
10+ // }
1111
1212android {
1313 namespace = " com.flyjingfish.login"
Original file line number Diff line number Diff line change @@ -4,9 +4,9 @@ plugins {
44// id("com.google.devtools.ksp")
55 id(" communication.export" )
66}
7- communicationConfig{
8- exportModuleName = " communication"
9- }
7+ // communicationConfig{
8+ // exportModuleName = "communication"
9+ // }
1010android {
1111 namespace = " com.flyjingfish.user"
1212 compileSdk = 34
@@ -34,7 +34,7 @@ dependencies {
3434 androidTestImplementation(libs.androidx.test.ext.junit)
3535 androidTestImplementation(libs.espresso.core)
3636 implementation(project(" :base-lib" ))
37- compileOnly(project(" :communication2 " ))
37+ compileOnly(project(" :communication " ))
3838// implementation(project(":module-communication-annotation"))
3939// ksp(project(":module-communication-ksp"))
4040}
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.flyjingfish.module_communication_plugin
33import com.android.build.api.variant.AndroidComponentsExtension
44import org.gradle.api.Plugin
55import org.gradle.api.Project
6+ import org.gradle.configurationcache.extensions.capitalized
67import java.io.File
78
89class CommunicationModulePlugin : Plugin <Project > {
@@ -19,5 +20,12 @@ class CommunicationModulePlugin : Plugin<Project> {
1920 java.addStaticSourceDirectory(" build/${LibVersion .pathName} /${variant.name} " )
2021 }
2122 }
23+ // project.afterEvaluate {
24+ // for (variant in variantList) {
25+ // val variantName = variant.name
26+ // val variantNameCapitalized = variantName.capitalized()
27+ // project.tasks.findByName("ksp${variantNameCapitalized}Kotlin")?.finalizedBy("generateCommunication$variantNameCapitalized")
28+ // }
29+ // }
2230 }
2331}
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ abstract class ExportTask : DefaultTask() {
1919 abstract var variant: Variant
2020 @get:Input
2121 abstract var exportModuleName: String
22+
2223 @TaskAction
2324 fun taskAction () {
2425 val variantName = variant.name
@@ -30,12 +31,16 @@ abstract class ExportTask : DefaultTask() {
3031
3132 val dir = project.project(" :${exportModuleName} " .replace(" \" " ," " )).projectDir
3233 val path = " build/${LibVersion .pathName} /${variantName} "
33- val packageFile = File (dir, path)
34- packageFile.deleteRecursively()
34+ val buildFile = File (dir, path)
35+
36+ val moduleKey = curProject.buildDir.absolutePath
37+ PackageRecordUtils .clear(moduleKey,buildFile)
38+
3539 for (file in collection.files) {
3640 val packageName = getPackageName(file)
3741 packageName?.let {
38- val packagePath = packageFile.absolutePath + " /" + it.replace(" ." ," /" )
42+ PackageRecordUtils .record(moduleKey,it)
43+ val packagePath = buildFile.absolutePath + " /" + it.replace(" ." ," /" )
3944 val targetFile = File (packagePath,file.name.replace(" .api" ," " ))
4045 file.copyTo(targetFile,true )
4146 }
Original file line number Diff line number Diff line change 1+ package com.flyjingfish.module_communication_plugin
2+
3+ import java.io.File
4+
5+ object PackageRecordUtils {
6+ private val lastRecordPackageMap = mutableMapOf<String ,MutableSet <String >>()
7+
8+ fun record (moduleKey : String ,packageName : String ){
9+ var lastRecordPackageSet = lastRecordPackageMap[moduleKey]
10+ if (lastRecordPackageSet == null ){
11+ lastRecordPackageSet = mutableSetOf ()
12+ lastRecordPackageMap[moduleKey] = lastRecordPackageSet
13+ }
14+ lastRecordPackageSet.add(packageName)
15+ }
16+
17+ fun clear (moduleKey : String ,buildFile : File ){
18+ val lastRecordPackageSet = lastRecordPackageMap[moduleKey]
19+ lastRecordPackageSet?.let {
20+ println (" lastRecordPackageSet-size=" + it.size);
21+
22+ for (packageName in it) {
23+ val packageFile = File (buildFile.absolutePath + " /" + packageName.replace(" ." ," /" ))
24+ packageFile.deleteRecursively()
25+ }
26+
27+ it.clear()
28+ }
29+ }
30+
31+ }
You can’t perform that action at this time.
0 commit comments