Work-around for importing intermediate android source sets
Fixed failure on import fully actualized intermediate source sets with K2Metadata compiler arguments (Android plugin expects compiler arguments of another type)
This commit is contained in:
+2
-2
@@ -557,7 +557,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
||||
}
|
||||
val closedSourceSetGraph = Graphs.transitiveClosure(sourceSetGraph)
|
||||
for (sourceSet in closedSourceSetGraph.nodes()) {
|
||||
val isAndroid = sourceSet.actualPlatforms.supports(KotlinPlatform.ANDROID)
|
||||
val isAndroid = sourceSet.actualPlatforms.platforms.singleOrNull() == KotlinPlatform.ANDROID
|
||||
val fromDataNode = if (isAndroid) {
|
||||
ideModule
|
||||
} else {
|
||||
@@ -577,7 +577,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
||||
sourceSetInfo.addSourceSets(dependeeSourceSets, selfName, gradleModule, resolverCtx)
|
||||
}
|
||||
}
|
||||
if (sourceSet.actualPlatforms.supports(KotlinPlatform.ANDROID)) continue
|
||||
if (sourceSet.actualPlatforms.platforms.singleOrNull() == KotlinPlatform.ANDROID) continue
|
||||
for (dependeeSourceSet in dependeeSourceSets) {
|
||||
val toDataNode = getSiblingKotlinModuleData(dependeeSourceSet, gradleModule, ideModule, resolverCtx) ?: continue
|
||||
addDependency(fromDataNode, toDataNode, dependeeSourceSet.isTestModule)
|
||||
|
||||
@@ -332,7 +332,12 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
||||
|
||||
val gradleCompilations = getCompilations(gradleTarget) ?: return null
|
||||
val compilations = gradleCompilations.mapNotNull {
|
||||
buildCompilation(it, disambiguationClassifier, sourceSetMap, dependencyResolver, project, dependencyMapper)
|
||||
val compilation = buildCompilation(it, disambiguationClassifier, sourceSetMap, dependencyResolver, project, dependencyMapper)
|
||||
if (compilation == null || platform != KotlinPlatform.ANDROID) {
|
||||
compilation
|
||||
} else {
|
||||
compilation.addDependsOnSourceSetsToCompilation(sourceSetMap)
|
||||
}
|
||||
}
|
||||
val jar = buildTargetJar(gradleTarget, project)
|
||||
val testTasks = buildTestTasks(project, gradleTarget)
|
||||
@@ -354,6 +359,11 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
||||
return target
|
||||
}
|
||||
|
||||
private fun KotlinCompilationImpl.addDependsOnSourceSetsToCompilation(sourceSetMap: Map<String, KotlinSourceSet>): KotlinCompilationImpl {
|
||||
val closedSourceSets = this.sourceSets.union(this.sourceSets.flatMap { it.dependsOnSourceSets }.mapNotNull { sourceSetMap[it] })
|
||||
return KotlinCompilationImpl(this.name, closedSourceSets, this.dependencies, this.output, this.arguments, this.dependencyClasspath, this.kotlinTaskProperties, this.nativeExtensions)
|
||||
}
|
||||
|
||||
private fun buildTestTasks(project: Project, gradleTarget: Named): Collection<KotlinTestTask> {
|
||||
val getTestRunsMethod = gradleTarget.javaClass.getMethodOrNull("getTestRuns")
|
||||
if (getTestRunsMethod != null) {
|
||||
|
||||
@@ -337,7 +337,13 @@ fun applyCompilerArgumentsToFacet(
|
||||
val oldPluginOptions = compilerArguments.pluginOptions
|
||||
|
||||
val emptyArgs = compilerArguments::class.java.newInstance()
|
||||
copyBeanTo(arguments, compilerArguments) { property, value -> value != property.get(emptyArgs) }
|
||||
|
||||
// Ad-hoc work-around for android compilations: middle source sets could be actualized up to
|
||||
// Android target, meanwhile compiler arguments are of type K2Metadata
|
||||
// TODO(auskov): merge classpath once compiler arguments are removed from KotlinFacetSettings
|
||||
if (arguments.javaClass == compilerArguments.javaClass) {
|
||||
copyBeanTo(arguments, compilerArguments) { property, value -> value != property.get(emptyArgs) }
|
||||
}
|
||||
compilerArguments.pluginOptions = joinPluginOptions(oldPluginOptions, arguments.pluginOptions)
|
||||
|
||||
compilerArguments.convertPathsToSystemIndependent()
|
||||
|
||||
Reference in New Issue
Block a user