Improve classpath calculation for locally-defined script templates
Since at least in gradle-imported projects, the template could be found in several modules, some of them - incomplete (parent/buildscript module) the previous logic of filtering for already processed templates and roots is incorrect, and therefore removed. Also fixes the exception in our project "cannot load script definition"
This commit is contained in:
@@ -60,19 +60,17 @@ class ScriptTemplatesFromDependenciesProvider(private val project: Project) : Sc
|
||||
val processedRoots = hashSetOf<VirtualFile>()
|
||||
|
||||
fun addTemplatesFromRoot(vfile: VirtualFile): Boolean {
|
||||
var newTemplatesFound = false
|
||||
if (!processedRoots.contains(vfile)) {
|
||||
processedRoots.add(vfile)
|
||||
val root = JarFileSystem.getInstance().getJarRootForLocalFile(vfile) ?: vfile
|
||||
if (root.isValid) {
|
||||
root.findFileByRelativePath(templatesPath)?.takeIf { it.isDirectory }?.children?.forEach {
|
||||
if (it.isValid && !it.isDirectory && templates.add(it.name)) {
|
||||
newTemplatesFound = true
|
||||
}
|
||||
var templatesFound = false
|
||||
val root = JarFileSystem.getInstance().getJarRootForLocalFile(vfile) ?: vfile
|
||||
if (root.isValid) {
|
||||
root.findFileByRelativePath(templatesPath)?.takeIf { it.isDirectory }?.children?.forEach {
|
||||
if (it.isValid && !it.isDirectory) {
|
||||
templates.add(it.name)
|
||||
templatesFound = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return newTemplatesFound
|
||||
return templatesFound
|
||||
}
|
||||
|
||||
// processing source roots from the same project first since the resources are copied to the classes roots only on compilation
|
||||
|
||||
Reference in New Issue
Block a user