Pill: Fix resource roots importing
This commit is contained in:
@@ -15,6 +15,9 @@ import org.gradle.kotlin.dsl.configure
|
|||||||
import org.gradle.plugins.ide.idea.IdeaPlugin
|
import org.gradle.plugins.ide.idea.IdeaPlugin
|
||||||
import org.gradle.api.file.SourceDirectorySet
|
import org.gradle.api.file.SourceDirectorySet
|
||||||
import org.gradle.api.internal.HasConvention
|
import org.gradle.api.internal.HasConvention
|
||||||
|
import org.gradle.api.internal.file.copy.CopySpecInternal
|
||||||
|
import org.gradle.api.internal.file.copy.SingleParentCopySpec
|
||||||
|
import org.gradle.language.jvm.tasks.ProcessResources
|
||||||
import org.jetbrains.kotlin.pill.POrderRoot.*
|
import org.jetbrains.kotlin.pill.POrderRoot.*
|
||||||
import org.jetbrains.kotlin.pill.PSourceRoot.*
|
import org.jetbrains.kotlin.pill.PSourceRoot.*
|
||||||
import org.jetbrains.kotlin.pill.PillExtension.*
|
import org.jetbrains.kotlin.pill.PillExtension.*
|
||||||
@@ -281,11 +284,40 @@ private fun parseSourceRoots(project: Project): List<PSourceRoot> {
|
|||||||
for (directory in directories) {
|
for (directory in directories) {
|
||||||
sourceRoots += PSourceRoot(directory, kind, kotlinOptions)
|
sourceRoots += PSourceRoot(directory, kind, kotlinOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (root in parseResourceRootsProcessedByProcessResourcesTask(project, sourceSet)) {
|
||||||
|
if (sourceRoots.none { it.path == root.path }) {
|
||||||
|
sourceRoots += root
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return sourceRoots
|
return sourceRoots
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun parseResourceRootsProcessedByProcessResourcesTask(project: Project, sourceSet: SourceSet): List<PSourceRoot> {
|
||||||
|
val isMainSourceSet = sourceSet.name == SourceSet.MAIN_SOURCE_SET_NAME
|
||||||
|
val isTestSourceSet = sourceSet.name == SourceSet.TEST_SOURCE_SET_NAME
|
||||||
|
|
||||||
|
val resourceRootKind = if (isTestSourceSet) PSourceRoot.Kind.TEST_RESOURCES else PSourceRoot.Kind.RESOURCES
|
||||||
|
val taskNameBase = "processResources"
|
||||||
|
val taskName = if (isMainSourceSet) taskNameBase else sourceSet.name + taskNameBase.capitalize()
|
||||||
|
val task = project.tasks.findByName(taskName) as? ProcessResources ?: return emptyList()
|
||||||
|
|
||||||
|
val roots = mutableListOf<File>()
|
||||||
|
fun collectRoots(spec: CopySpecInternal) {
|
||||||
|
if (spec is SingleParentCopySpec && spec.children.none()) {
|
||||||
|
roots += spec.sourcePaths.map { File(project.projectDir, it.toString()) }.filter { it.exists() }
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
spec.children.forEach(::collectRoots)
|
||||||
|
}
|
||||||
|
collectRoots(task.rootSpec)
|
||||||
|
|
||||||
|
return roots.map { PSourceRoot(it, resourceRootKind, null) }
|
||||||
|
}
|
||||||
|
|
||||||
private fun getKotlinOptions(kotlinCompileTask: Any): PSourceRootKotlinOptions? {
|
private fun getKotlinOptions(kotlinCompileTask: Any): PSourceRootKotlinOptions? {
|
||||||
val compileArguments = kotlinCompileTask.invokeInternal("getSerializedCompilerArguments") as List<String>
|
val compileArguments = kotlinCompileTask.invokeInternal("getSerializedCompilerArguments") as List<String>
|
||||||
fun parseBoolean(name: String) = compileArguments.contains("-$name")
|
fun parseBoolean(name: String) = compileArguments.contains("-$name")
|
||||||
|
|||||||
Reference in New Issue
Block a user