Move util function closer to its usage and remove empty file

This commit is contained in:
Mikhail Zarechenskiy
2016-09-15 14:14:13 +03:00
parent 8a0107ea5f
commit 2fc8f5d5e2
2 changed files with 11 additions and 30 deletions
@@ -35,6 +35,8 @@ import org.junit.Test
import java.io.File
import java.lang.Exception
import java.lang.reflect.InvocationTargetException
import java.net.URISyntaxException
import java.net.URL
import java.net.URLClassLoader
import java.util.concurrent.Future
import kotlin.reflect.KClass
@@ -258,6 +260,15 @@ class TestKotlinScriptDependenciesResolver : ScriptDependenciesResolver {
?.mapNotNull { it.toFile() }
?.filter { it.path.contains("out") && it.path.contains("test") }
?: emptyList()
private fun URL.toFile() =
try {
File(toURI().schemeSpecificPart)
}
catch (e: URISyntaxException) {
if (protocol != "file") null
else File(file)
}
}
@ScriptTemplateDefinition(