Fix import of compiler arguments in IDEA if source set dependencies

could not be resolved (e.g. due to misspelling in artifact name).
Fix works only in case when both new IDEA and gradle plugins are
used
#KT-28627 Fixed
This commit is contained in:
Andrey Uskov
2019-03-29 18:02:01 +03:00
parent ed0dfaec36
commit a6ae1f2ba6
8 changed files with 38 additions and 19 deletions
@@ -123,12 +123,12 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
private fun Project.pathOrName() = if (path == ":") name else path
@Suppress("UNCHECKED_CAST")
private fun Task.getCompilerArguments(methodName: String): List<String> {
private fun Task.getCompilerArguments(methodName: String): List<String>? {
return try {
javaClass.getDeclaredMethod(methodName).invoke(this) as List<String>
} catch (e: Exception) {
// No argument accessor method is available
emptyList()
null
}
}
@@ -175,7 +175,8 @@ class KotlinGradleModelBuilder : AbstractKotlinGradleModelBuilder() {
val sourceSetName = compileTask.getSourceSetName()
val currentArguments = compileTask.getCompilerArguments("getSerializedCompilerArguments")
val defaultArguments = compileTask.getCompilerArguments("getDefaultSerializedCompilerArguments")
?: compileTask.getCompilerArguments("getSerializedCompilerArgumentsIgnoreClasspathIssues") ?: emptyList()
val defaultArguments = compileTask.getCompilerArguments("getDefaultSerializedCompilerArguments").orEmpty()
val dependencyClasspath = compileTask.getDependencyClasspath()
compilerArgumentsBySourceSet[sourceSetName] = ArgsInfoImpl(currentArguments, defaultArguments, dependencyClasspath)
}