MPP: Support configurations with metadata
This commit is contained in:
+1
-1
@@ -628,7 +628,7 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun KotlinModule.fullName(simpleName: String = name) = when (this) {
|
private fun KotlinModule.fullName(simpleName: String = name) = when (this) {
|
||||||
is KotlinCompilation -> target.disambiguationClassifier?.let { it + simpleName.capitalize() } ?: simpleName
|
is KotlinCompilation -> compilationFullName(simpleName, target.disambiguationClassifier)
|
||||||
else -> simpleName
|
else -> simpleName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -164,7 +164,9 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val gradleCompilations =
|
val gradleCompilations =
|
||||||
(getCompilations.invoke(gradleTarget) as? NamedDomainObjectContainer<Named>)?.asMap?.values ?: emptyList<Named>()
|
(getCompilations.invoke(gradleTarget) as? NamedDomainObjectContainer<Named>)?.asMap?.values ?: emptyList<Named>()
|
||||||
val compilations = gradleCompilations.mapNotNull { buildCompilation(it, sourceSetMap, dependencyResolver, project) }
|
val compilations = gradleCompilations.mapNotNull {
|
||||||
|
buildCompilation(it, disambiguationClassifier, sourceSetMap, dependencyResolver, project)
|
||||||
|
}
|
||||||
val jar = buildTargetJar(gradleTarget, project)
|
val jar = buildTargetJar(gradleTarget, project)
|
||||||
val target = KotlinTargetImpl(gradleTarget.name, disambiguationClassifier, platform, compilations, jar)
|
val target = KotlinTargetImpl(gradleTarget.name, disambiguationClassifier, platform, compilations, jar)
|
||||||
compilations.forEach { it.target = target }
|
compilations.forEach { it.target = target }
|
||||||
@@ -184,6 +186,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
|
|
||||||
private fun buildCompilation(
|
private fun buildCompilation(
|
||||||
gradleCompilation: Named,
|
gradleCompilation: Named,
|
||||||
|
classifier: String?,
|
||||||
sourceSetMap: Map<String, KotlinSourceSet>,
|
sourceSetMap: Map<String, KotlinSourceSet>,
|
||||||
dependencyResolver: DependencyResolver,
|
dependencyResolver: DependencyResolver,
|
||||||
project: Project
|
project: Project
|
||||||
@@ -200,12 +203,14 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
val output = buildCompilationOutput(gradleCompilation, compileKotlinTask) ?: return null
|
val output = buildCompilationOutput(gradleCompilation, compileKotlinTask) ?: return null
|
||||||
val arguments = buildCompilationArguments(compileKotlinTask) ?: return null
|
val arguments = buildCompilationArguments(compileKotlinTask) ?: return null
|
||||||
val dependencyClasspath = buildDependencyClasspath(compileKotlinTask)
|
val dependencyClasspath = buildDependencyClasspath(compileKotlinTask)
|
||||||
val dependencies = buildCompilationDependencies(gradleCompilation, dependencyResolver, project)
|
val dependencies = buildCompilationDependencies(gradleCompilation, classifier, sourceSetMap, dependencyResolver, project)
|
||||||
return KotlinCompilationImpl(gradleCompilation.name, kotlinSourceSets, dependencies, output, arguments, dependencyClasspath)
|
return KotlinCompilationImpl(gradleCompilation.name, kotlinSourceSets, dependencies, output, arguments, dependencyClasspath)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildCompilationDependencies(
|
private fun buildCompilationDependencies(
|
||||||
gradleCompilation: Named,
|
gradleCompilation: Named,
|
||||||
|
classifier: String?,
|
||||||
|
sourceSetMap: Map<String, KotlinSourceSet>,
|
||||||
dependencyResolver: DependencyResolver,
|
dependencyResolver: DependencyResolver,
|
||||||
project: Project
|
project: Project
|
||||||
): Set<KotlinDependency> {
|
): Set<KotlinDependency> {
|
||||||
@@ -216,6 +221,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
this += buildDependencies(
|
this += buildDependencies(
|
||||||
gradleCompilation, dependencyResolver, "getRuntimeDependencyConfigurationName", "RUNTIME", project
|
gradleCompilation, dependencyResolver, "getRuntimeDependencyConfigurationName", "RUNTIME", project
|
||||||
)
|
)
|
||||||
|
this += sourceSetMap[compilationFullName(gradleCompilation.name, classifier)]?.dependencies ?: emptySet()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,16 +232,16 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
): Set<KotlinDependency> {
|
): Set<KotlinDependency> {
|
||||||
return LinkedHashSet<KotlinDependency>().apply {
|
return LinkedHashSet<KotlinDependency>().apply {
|
||||||
this += buildDependencies(
|
this += buildDependencies(
|
||||||
gradleSourceSet, dependencyResolver, "getApiConfigurationName", "COMPILE", project
|
gradleSourceSet, dependencyResolver, "getApiMetadataConfigurationName", "COMPILE", project
|
||||||
)
|
)
|
||||||
this += buildDependencies(
|
this += buildDependencies(
|
||||||
gradleSourceSet, dependencyResolver, "getImplementationConfigurationName", "COMPILE", project
|
gradleSourceSet, dependencyResolver, "getImplementationMetadataConfigurationName", "COMPILE", project
|
||||||
)
|
)
|
||||||
this += buildDependencies(
|
this += buildDependencies(
|
||||||
gradleSourceSet, dependencyResolver, "getCompileOnlyConfigurationName", "COMPILE", project
|
gradleSourceSet, dependencyResolver, "getCompileOnlyMetadataConfigurationName", "COMPILE", project
|
||||||
)
|
)
|
||||||
this += buildDependencies(
|
this += buildDependencies(
|
||||||
gradleSourceSet, dependencyResolver, "getRuntimeOnlyConfigurationName", "RUNTIME", project
|
gradleSourceSet, dependencyResolver, "getRuntimeOnlyMetadataConfigurationName", "RUNTIME", project
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -164,7 +164,9 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
val gradleCompilations =
|
val gradleCompilations =
|
||||||
(getCompilations.invoke(gradleTarget) as? NamedDomainObjectContainer<Named>)?.asMap?.values ?: emptyList<Named>()
|
(getCompilations.invoke(gradleTarget) as? NamedDomainObjectContainer<Named>)?.asMap?.values ?: emptyList<Named>()
|
||||||
val compilations = gradleCompilations.mapNotNull { buildCompilation(it, sourceSetMap, dependencyResolver, project) }
|
val compilations = gradleCompilations.mapNotNull {
|
||||||
|
buildCompilation(it, disambiguationClassifier, sourceSetMap, dependencyResolver, project)
|
||||||
|
}
|
||||||
val jar = buildTargetJar(gradleTarget, project)
|
val jar = buildTargetJar(gradleTarget, project)
|
||||||
val target = KotlinTargetImpl(gradleTarget.name, disambiguationClassifier, platform, compilations, jar)
|
val target = KotlinTargetImpl(gradleTarget.name, disambiguationClassifier, platform, compilations, jar)
|
||||||
compilations.forEach { it.target = target }
|
compilations.forEach { it.target = target }
|
||||||
@@ -184,6 +186,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
|
|
||||||
private fun buildCompilation(
|
private fun buildCompilation(
|
||||||
gradleCompilation: Named,
|
gradleCompilation: Named,
|
||||||
|
classifier: String?,
|
||||||
sourceSetMap: Map<String, KotlinSourceSet>,
|
sourceSetMap: Map<String, KotlinSourceSet>,
|
||||||
dependencyResolver: DependencyResolver,
|
dependencyResolver: DependencyResolver,
|
||||||
project: Project
|
project: Project
|
||||||
@@ -200,12 +203,14 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
val output = buildCompilationOutput(gradleCompilation, compileKotlinTask) ?: return null
|
val output = buildCompilationOutput(gradleCompilation, compileKotlinTask) ?: return null
|
||||||
val arguments = buildCompilationArguments(compileKotlinTask) ?: return null
|
val arguments = buildCompilationArguments(compileKotlinTask) ?: return null
|
||||||
val dependencyClasspath = buildDependencyClasspath(compileKotlinTask)
|
val dependencyClasspath = buildDependencyClasspath(compileKotlinTask)
|
||||||
val dependencies = buildCompilationDependencies(gradleCompilation, dependencyResolver, project)
|
val dependencies = buildCompilationDependencies(gradleCompilation, classifier, sourceSetMap, dependencyResolver, project)
|
||||||
return KotlinCompilationImpl(gradleCompilation.name, kotlinSourceSets, dependencies, output, arguments, dependencyClasspath)
|
return KotlinCompilationImpl(gradleCompilation.name, kotlinSourceSets, dependencies, output, arguments, dependencyClasspath)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun buildCompilationDependencies(
|
private fun buildCompilationDependencies(
|
||||||
gradleCompilation: Named,
|
gradleCompilation: Named,
|
||||||
|
classifier: String?,
|
||||||
|
sourceSetMap: Map<String, KotlinSourceSet>,
|
||||||
dependencyResolver: DependencyResolver,
|
dependencyResolver: DependencyResolver,
|
||||||
project: Project
|
project: Project
|
||||||
): Set<KotlinDependency> {
|
): Set<KotlinDependency> {
|
||||||
@@ -216,6 +221,7 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
this += buildDependencies(
|
this += buildDependencies(
|
||||||
gradleCompilation, dependencyResolver, "getRuntimeDependencyConfigurationName", "RUNTIME", project
|
gradleCompilation, dependencyResolver, "getRuntimeDependencyConfigurationName", "RUNTIME", project
|
||||||
)
|
)
|
||||||
|
this += sourceSetMap[compilationFullName(gradleCompilation.name, classifier)]?.dependencies ?: emptySet()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,16 +232,16 @@ class KotlinMPPGradleModelBuilder : ModelBuilderService {
|
|||||||
): Set<KotlinDependency> {
|
): Set<KotlinDependency> {
|
||||||
return LinkedHashSet<KotlinDependency>().apply {
|
return LinkedHashSet<KotlinDependency>().apply {
|
||||||
this += buildDependencies(
|
this += buildDependencies(
|
||||||
gradleSourceSet, dependencyResolver, "getApiConfigurationName", "COMPILE", project
|
gradleSourceSet, dependencyResolver, "getApiMetadataConfigurationName", "COMPILE", project
|
||||||
)
|
)
|
||||||
this += buildDependencies(
|
this += buildDependencies(
|
||||||
gradleSourceSet, dependencyResolver, "getImplementationConfigurationName", "COMPILE", project
|
gradleSourceSet, dependencyResolver, "getImplementationMetadataConfigurationName", "COMPILE", project
|
||||||
)
|
)
|
||||||
this += buildDependencies(
|
this += buildDependencies(
|
||||||
gradleSourceSet, dependencyResolver, "getCompileOnlyConfigurationName", "COMPILE", project
|
gradleSourceSet, dependencyResolver, "getCompileOnlyMetadataConfigurationName", "COMPILE", project
|
||||||
)
|
)
|
||||||
this += buildDependencies(
|
this += buildDependencies(
|
||||||
gradleSourceSet, dependencyResolver, "getRuntimeOnlyConfigurationName", "RUNTIME", project
|
gradleSourceSet, dependencyResolver, "getRuntimeOnlyMetadataConfigurationName", "RUNTIME", project
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,4 +17,7 @@ fun Class<*>.getDeclaredMethodOrNull(name: String, vararg parameterTypes: Class<
|
|||||||
getDeclaredMethod(name, *parameterTypes)?.also { it.isAccessible = true }
|
getDeclaredMethod(name, *parameterTypes)?.also { it.isAccessible = true }
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun compilationFullName(simpleName: String, classifier: String?) =
|
||||||
|
if (classifier != null) classifier + simpleName.capitalize() else simpleName
|
||||||
Reference in New Issue
Block a user