Minor. Reformat code in multiplatform project importer
This commit is contained in:
+4
-1
@@ -181,7 +181,10 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val dependencies = if (useModulePerSourceSet()) moduleNode.getDependencies(ideProject) else getDependencyModules(ideModule, gradleModule.project)
|
val dependencies = if (useModulePerSourceSet()) moduleNode.getDependencies(ideProject) else getDependencyModules(
|
||||||
|
ideModule,
|
||||||
|
gradleModule.project
|
||||||
|
)
|
||||||
// queue only those dependencies that haven't been discovered earlier
|
// queue only those dependencies that haven't been discovered earlier
|
||||||
dependencies.filterTo(toProcess, discovered::add)
|
dependencies.filterTo(toProcess, discovered::add)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -687,6 +687,9 @@ open class KotlinMPPGradleProjectResolver : AbstractProjectResolverExtension() {
|
|||||||
getModuleId(resolverCtx, gradleModule) + ":" + kotlinModule.fullName()
|
getModuleId(resolverCtx, gradleModule) + ":" + kotlinModule.fullName()
|
||||||
|
|
||||||
private fun ExternalProject.notImportedCommonSourceSets() =
|
private fun ExternalProject.notImportedCommonSourceSets() =
|
||||||
GradlePropertiesFileFacade.forExternalProject(this).readProperty(KOTLIN_NOT_IMPORTED_COMMON_SOURCE_SETS_SETTING)?.equals("true", ignoreCase = true) ?: false
|
GradlePropertiesFileFacade.forExternalProject(this).readProperty(KOTLIN_NOT_IMPORTED_COMMON_SOURCE_SETS_SETTING)?.equals(
|
||||||
|
"true",
|
||||||
|
ignoreCase = true
|
||||||
|
) ?: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ interface ArgsInfo : Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class ArgsInfoImpl(
|
class ArgsInfoImpl(
|
||||||
override val currentArguments: List<String>,
|
override val currentArguments: List<String>,
|
||||||
override val defaultArguments: List<String>,
|
override val defaultArguments: List<String>,
|
||||||
override val dependencyClasspath: List<String>
|
override val dependencyClasspath: List<String>
|
||||||
) : ArgsInfo
|
) : ArgsInfo
|
||||||
|
|
||||||
typealias CompilerArgumentsBySourceSet = Map<String, ArgsInfo>
|
typealias CompilerArgumentsBySourceSet = Map<String, ArgsInfo>
|
||||||
@@ -52,12 +52,12 @@ interface KotlinGradleModel : Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class KotlinGradleModelImpl(
|
class KotlinGradleModelImpl(
|
||||||
override val hasKotlinPlugin: Boolean,
|
override val hasKotlinPlugin: Boolean,
|
||||||
override val compilerArgumentsBySourceSet: CompilerArgumentsBySourceSet,
|
override val compilerArgumentsBySourceSet: CompilerArgumentsBySourceSet,
|
||||||
override val coroutines: String?,
|
override val coroutines: String?,
|
||||||
override val platformPluginId: String?,
|
override val platformPluginId: String?,
|
||||||
override val implements: List<String>,
|
override val implements: List<String>,
|
||||||
override val kotlinTarget: String? = null
|
override val kotlinTarget: String? = null
|
||||||
) : KotlinGradleModel
|
) : KotlinGradleModel
|
||||||
|
|
||||||
abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
|
abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
|
||||||
@@ -72,8 +72,8 @@ abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
|
|||||||
)
|
)
|
||||||
val platformPluginIds = listOf("kotlin-platform-jvm", "kotlin-platform-js", "kotlin-platform-common")
|
val platformPluginIds = listOf("kotlin-platform-jvm", "kotlin-platform-js", "kotlin-platform-common")
|
||||||
val pluginToPlatform = linkedMapOf(
|
val pluginToPlatform = linkedMapOf(
|
||||||
"kotlin" to "kotlin-platform-jvm",
|
"kotlin" to "kotlin-platform-jvm",
|
||||||
"kotlin2js" to "kotlin-platform-js"
|
"kotlin2js" to "kotlin-platform-js"
|
||||||
)
|
)
|
||||||
val kotlinPluginIds = listOf("kotlin", "kotlin2js", "kotlin-android")
|
val kotlinPluginIds = listOf("kotlin", "kotlin2js", "kotlin-android")
|
||||||
val ABSTRACT_KOTLIN_COMPILE_CLASS = "org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile"
|
val ABSTRACT_KOTLIN_COMPILE_CLASS = "org.jetbrains.kotlin.gradle.tasks.AbstractKotlinCompile"
|
||||||
@@ -81,7 +81,7 @@ abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
|
|||||||
fun Task.getSourceSetName(): String {
|
fun Task.getSourceSetName(): String {
|
||||||
return try {
|
return try {
|
||||||
javaClass.methods.firstOrNull { it.name.startsWith("getSourceSetName") && it.parameterTypes.isEmpty() }?.invoke(this) as? String
|
javaClass.methods.firstOrNull { it.name.startsWith("getSourceSetName") && it.parameterTypes.isEmpty() }?.invoke(this) as? String
|
||||||
} catch (e : InvocationTargetException) {
|
} catch (e: InvocationTargetException) {
|
||||||
null // can be thrown if property is not initialized yet
|
null // can be thrown if property is not initialized yet
|
||||||
} ?: "main"
|
} ?: "main"
|
||||||
}
|
}
|
||||||
@@ -90,16 +90,17 @@ abstract class AbstractKotlinGradleModelBuilder : ModelBuilderService {
|
|||||||
|
|
||||||
class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
|
class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
|
||||||
override fun getErrorMessageBuilder(project: Project, e: Exception): ErrorMessageBuilder {
|
override fun getErrorMessageBuilder(project: Project, e: Exception): ErrorMessageBuilder {
|
||||||
return ErrorMessageBuilder.create(project, e, "Gradle import errors").withDescription("Unable to build Kotlin project configuration")
|
return ErrorMessageBuilder.create(project, e, "Gradle import errors")
|
||||||
|
.withDescription("Unable to build Kotlin project configuration")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun canBuild(modelName: String?): Boolean = modelName == KotlinGradleModel::class.java.name
|
override fun canBuild(modelName: String?): Boolean = modelName == KotlinGradleModel::class.java.name
|
||||||
|
|
||||||
private fun getImplementedProjects(project: Project): List<Project> {
|
private fun getImplementedProjects(project: Project): List<Project> {
|
||||||
return listOf("expectedBy", "implement")
|
return listOf("expectedBy", "implement")
|
||||||
.flatMap { project.configurations.findByName(it)?.dependencies ?: emptySet<Dependency>() }
|
.flatMap { project.configurations.findByName(it)?.dependencies ?: emptySet<Dependency>() }
|
||||||
.filterIsInstance<ProjectDependency>()
|
.filterIsInstance<ProjectDependency>()
|
||||||
.mapNotNull { it.dependencyProject }
|
.mapNotNull { it.dependencyProject }
|
||||||
}
|
}
|
||||||
|
|
||||||
// see GradleProjectResolverUtil.getModuleId() in IDEA codebase
|
// see GradleProjectResolverUtil.getModuleId() in IDEA codebase
|
||||||
@@ -109,8 +110,7 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
|
|||||||
private fun Task.getCompilerArguments(methodName: String): List<String> {
|
private fun Task.getCompilerArguments(methodName: String): List<String> {
|
||||||
return try {
|
return try {
|
||||||
javaClass.getDeclaredMethod(methodName).invoke(this) as List<String>
|
javaClass.getDeclaredMethod(methodName).invoke(this) as List<String>
|
||||||
}
|
} catch (e: Exception) {
|
||||||
catch (e : Exception) {
|
|
||||||
// No argument accessor method is available
|
// No argument accessor method is available
|
||||||
emptyList()
|
emptyList()
|
||||||
}
|
}
|
||||||
@@ -122,14 +122,11 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
|
|||||||
val getCompileClasspath = abstractKotlinCompileClass.getDeclaredMethod("getCompileClasspath").apply { isAccessible = true }
|
val getCompileClasspath = abstractKotlinCompileClass.getDeclaredMethod("getCompileClasspath").apply { isAccessible = true }
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
return (getCompileClasspath.invoke(this) as Collection<File>).map { it.path }
|
return (getCompileClasspath.invoke(this) as Collection<File>).map { it.path }
|
||||||
}
|
} catch (e: ClassNotFoundException) {
|
||||||
catch(e: ClassNotFoundException) {
|
|
||||||
// Leave arguments unchanged
|
// Leave arguments unchanged
|
||||||
}
|
} catch (e: NoSuchMethodException) {
|
||||||
catch (e: NoSuchMethodException) {
|
|
||||||
// Leave arguments unchanged
|
// Leave arguments unchanged
|
||||||
}
|
} catch (e: InvocationTargetException) {
|
||||||
catch (e: InvocationTargetException) {
|
|
||||||
// We can safely ignore this exception here as getCompileClasspath() gets called again at a later time
|
// We can safely ignore this exception here as getCompileClasspath() gets called again at a later time
|
||||||
// Leave arguments unchanged
|
// Leave arguments unchanged
|
||||||
}
|
}
|
||||||
@@ -140,15 +137,13 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
|
|||||||
val kotlinExtension = project.extensions.findByName("kotlin") ?: return null
|
val kotlinExtension = project.extensions.findByName("kotlin") ?: return null
|
||||||
val experimentalExtension = try {
|
val experimentalExtension = try {
|
||||||
kotlinExtension::class.java.getMethod("getExperimental").invoke(kotlinExtension)
|
kotlinExtension::class.java.getMethod("getExperimental").invoke(kotlinExtension)
|
||||||
}
|
} catch (e: NoSuchMethodException) {
|
||||||
catch(e: NoSuchMethodException) {
|
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
experimentalExtension::class.java.getMethod("getCoroutines").invoke(experimentalExtension)?.toString()
|
experimentalExtension::class.java.getMethod("getCoroutines").invoke(experimentalExtension)?.toString()
|
||||||
}
|
} catch (e: NoSuchMethodException) {
|
||||||
catch(e: NoSuchMethodException) {
|
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -173,12 +168,12 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
|
|||||||
val implementedProjects = getImplementedProjects(project)
|
val implementedProjects = getImplementedProjects(project)
|
||||||
|
|
||||||
return KotlinGradleModelImpl(
|
return KotlinGradleModelImpl(
|
||||||
kotlinPluginId != null || platformPluginId != null,
|
kotlinPluginId != null || platformPluginId != null,
|
||||||
compilerArgumentsBySourceSet,
|
compilerArgumentsBySourceSet,
|
||||||
getCoroutines(project),
|
getCoroutines(project),
|
||||||
platform,
|
platform,
|
||||||
implementedProjects.map { it.pathOrName() },
|
implementedProjects.map { it.pathOrName() },
|
||||||
platform ?: kotlinPluginId
|
platform ?: kotlinPluginId
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user