support kotlin multiplatform modules#20
Conversation
|
|
||
| project.isJava || project.isKotlinJvm -> JarAppSizeVariant(project) | ||
|
|
||
| project.isKotlinMultiplatform -> JarAppSizeVariant(project, "jvmJar", "jvmRuntimeClasspath") |
There was a problem hiding this comment.
The issue is that a KMP module could be both a jvmJar and an Android module at the same time. (Provide a jar file & aar file)
It's broken the current SizerVariant; let me update the API to support this feature.
There was a problem hiding this comment.
I already work on this issue, let me share the MR later
There was a problem hiding this comment.
The KMP module requires the android-library plugin to be included if an Android target is specified. Therefore, the Android AppSizeVariant already includes all sources when building AAR
There was a problem hiding this comment.
| @@ -275,17 +282,19 @@ internal class DefaultVariantExtractor @Inject constructor( | |||
| } | |||
|
|
|||
| internal class JarAppSizeVariant( | |||
There was a problem hiding this comment.
internal const val KMP_JAR_TASK = "jvmJar"
internal const val KMP_RUNTIME_CONFIGURATION = "jvmRuntimeClasspath"
Let's have a separate class for KMP.
internal class KmpSizerVariant(
private val project: Project
) : SizerVariant {
override val binaryOutPut: File
get() {
val jarTask = project.tasks.findByName(KMP_JAR_TASK) as Jar
return jarTask.archiveFile.get().asFile
}
override val runtimeConfiguration: Configuration by lazy {
project.configurations.first {
it.name.equals(KMP_RUNTIME_CONFIGURATION, true)
}
}
override val buildType: String
get() = ""
override val buildFlavor: String
get() = ""
}
| ) | ||
| } | ||
|
|
||
| project.isKotlinMultiplatform -> { |
There was a problem hiding this comment.
Can merge with the other two
project.isKotlinJvm || project.isJava || project.isKotlinMultiplatform -> {
return JavaModuleDependency(
name = project.pathTrimColon,
pathToArtifact = matchVariant.binaryOutPut.path
)
}
| } | ||
|
|
||
| project.isKotlinMultiplatform -> { | ||
| task.dependsOn(project.tasks.named("jvmJar")) |
There was a problem hiding this comment.
Could you help to merge
internal const val KMP_JAR_TASK = "jvmJar"
...
project.isKotlinMultiplatform -> {
task.dependsOn(project.tasks.named(KMP_JAR_TASK))
}
project.isKotlinJvm || project.isJava -> {
task.dependsOn(project.tasks.named(JavaPlugin.JAR_TASK_NAME))
}

closes #13