-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
support kotlin multiplatform modules #20
Conversation
@@ -158,6 +162,9 @@ internal class DefaultVariantExtractor @Inject constructor( | |||
) | |||
|
|||
project.isJava || project.isKotlinJvm -> JarAppSizeVariant(project) | |||
|
|||
project.isKotlinMultiplatform -> JarAppSizeVariant(project, "jvmJar", "jvmRuntimeClasspath") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I already work on this issue, let me share the MR later
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -275,17 +282,19 @@ internal class DefaultVariantExtractor @Inject constructor( | |||
} | |||
|
|||
internal class JarAppSizeVariant( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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() = ""
}
@@ -73,6 +74,13 @@ internal class DefaultArchiveExtractor @Inject constructor( | |||
) | |||
} | |||
|
|||
project.isKotlinMultiplatform -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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