Switch to File instead of String for classpaths in script dependencies

This commit is contained in:
Ilya Chernikov
2016-06-14 19:00:12 +02:00
committed by Pavel V. Talanov
parent 5e3ba36cc1
commit 64bb47ed37
12 changed files with 43 additions and 41 deletions
@@ -69,11 +69,11 @@ class KotlinScriptConfigurationManager(
return allScriptsClasspathCache!!
}
private fun String.classpathEntryToVfs(): VirtualFile =
if (File(this).isDirectory)
StandardFileSystems.local()?.findFileByPath(this) ?: throw FileNotFoundException("Classpath entry points to a non-existent location: ${this}")
private fun File.classpathEntryToVfs(): VirtualFile =
if (isDirectory)
StandardFileSystems.local()?.findFileByPath(this.canonicalPath) ?: throw FileNotFoundException("Classpath entry points to a non-existent location: ${this}")
else
StandardFileSystems.jar()?.findFileByPath(this + URLUtil.JAR_SEPARATOR) ?: throw FileNotFoundException("Classpath entry points to a file that is not a JAR archive: ${this}")
StandardFileSystems.jar()?.findFileByPath(this.canonicalPath + URLUtil.JAR_SEPARATOR) ?: throw FileNotFoundException("Classpath entry points to a file that is not a JAR archive: ${this}")
fun getAllScriptsClasspathScope(): GlobalSearchScope? {
return getAllScriptsClasspath().let { cp ->
@@ -33,7 +33,7 @@ class GradleScriptTemplateProvider(project: Project, gim: GradleInstallationMana
override val templateClass: String = "org.gradle.script.lang.kotlin.KotlinBuildScript"
override val dependenciesClasspath: Iterable<String> =
gradleLibsPath?.listFiles { file -> file.extension == "jar" && depLibsPrefixes.any { file.name.startsWith(it) } }
?.map { it.absolutePath }
?.map { it.canonicalPath }
?: emptyList()
override val context: Any? = gradleHome