Kapt: Fix source root importing in MPP projects
This commit is contained in:
@@ -175,7 +175,6 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
||||
): KotlinTarget? {
|
||||
val targetClass = gradleTarget.javaClass
|
||||
val getPlatformType = targetClass.getMethodOrNull("getPlatformType") ?: return null
|
||||
val getCompilations = targetClass.getMethodOrNull("getCompilations") ?: return null
|
||||
val getDisambiguationClassifier = targetClass.getMethodOrNull("getDisambiguationClassifier") ?: return null
|
||||
val platformId = (getPlatformType.invoke(gradleTarget) as? Named)?.name ?: return null
|
||||
val platform = KotlinPlatform.byId(platformId) ?: return null
|
||||
@@ -189,9 +188,8 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
||||
} catch (e: Throwable) {
|
||||
"${e::class.java.name}:${e.message}"
|
||||
}
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val gradleCompilations =
|
||||
(getCompilations.invoke(gradleTarget) as? NamedDomainObjectContainer<Named>)?.asMap?.values ?: emptyList<Named>()
|
||||
|
||||
val gradleCompilations = getCompilations(gradleTarget) ?: return null
|
||||
val compilations = gradleCompilations.mapNotNull {
|
||||
buildCompilation(it, disambiguationClassifier, sourceSetMap, dependencyResolver, project)
|
||||
}
|
||||
@@ -227,10 +225,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val kotlinGradleSourceSets = (getKotlinSourceSets(gradleCompilation) as? Collection<Named>) ?: return null
|
||||
val kotlinSourceSets = kotlinGradleSourceSets.mapNotNull { sourceSetMap[it.name] }
|
||||
val getCompileKotlinTaskName = compilationClass.getMethodOrNull("getCompileKotlinTaskName") ?: return null
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val compileKotlinTaskName = (getCompileKotlinTaskName(gradleCompilation) as? String) ?: return null
|
||||
val compileKotlinTask = project.tasks.findByName(compileKotlinTaskName) ?: return null
|
||||
val compileKotlinTask = getCompileKotlinTaskName(project, gradleCompilation) ?: return null
|
||||
val output = buildCompilationOutput(gradleCompilation, compileKotlinTask) ?: return null
|
||||
val arguments = buildCompilationArguments(compileKotlinTask) ?: return null
|
||||
val dependencyClasspath = buildDependencyClasspath(compileKotlinTask)
|
||||
@@ -547,6 +542,20 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return (getTargets.invoke(kotlinExt) as? NamedDomainObjectContainer<Named>)?.asMap?.values ?: emptyList()
|
||||
}
|
||||
|
||||
fun getCompilations(target: Named): Collection<Named>? {
|
||||
val getCompilationsMethod = target.javaClass.getMethodOrNull("getCompilations") ?: return null
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return (getCompilationsMethod.invoke(target) as? NamedDomainObjectContainer<Named>)?.asMap?.values ?: emptyList()
|
||||
}
|
||||
|
||||
fun getCompileKotlinTaskName(project: Project, compilation: Named): Task? {
|
||||
val compilationClass = compilation.javaClass
|
||||
val getCompileKotlinTaskName = compilationClass.getMethodOrNull("getCompileKotlinTaskName") ?: return null
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val compileKotlinTaskName = (getCompileKotlinTaskName(compilation) as? String) ?: return null
|
||||
return project.tasks.findByName(compileKotlinTaskName) ?: return null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user