Move util function closer to its usage and remove empty file
This commit is contained in:
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.scripts
|
|
||||||
|
|
||||||
import java.io.File
|
|
||||||
import java.net.URL
|
|
||||||
import java.net.URLClassLoader
|
|
||||||
|
|
||||||
fun URL.toFile() =
|
|
||||||
try {
|
|
||||||
File(toURI().schemeSpecificPart)
|
|
||||||
}
|
|
||||||
catch (e: java.net.URISyntaxException) {
|
|
||||||
if (protocol != "file") null
|
|
||||||
else File(file)
|
|
||||||
}
|
|
||||||
@@ -35,6 +35,8 @@ import org.junit.Test
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
import java.lang.Exception
|
import java.lang.Exception
|
||||||
import java.lang.reflect.InvocationTargetException
|
import java.lang.reflect.InvocationTargetException
|
||||||
|
import java.net.URISyntaxException
|
||||||
|
import java.net.URL
|
||||||
import java.net.URLClassLoader
|
import java.net.URLClassLoader
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
import kotlin.reflect.KClass
|
import kotlin.reflect.KClass
|
||||||
@@ -258,6 +260,15 @@ class TestKotlinScriptDependenciesResolver : ScriptDependenciesResolver {
|
|||||||
?.mapNotNull { it.toFile() }
|
?.mapNotNull { it.toFile() }
|
||||||
?.filter { it.path.contains("out") && it.path.contains("test") }
|
?.filter { it.path.contains("out") && it.path.contains("test") }
|
||||||
?: emptyList()
|
?: emptyList()
|
||||||
|
|
||||||
|
private fun URL.toFile() =
|
||||||
|
try {
|
||||||
|
File(toURI().schemeSpecificPart)
|
||||||
|
}
|
||||||
|
catch (e: URISyntaxException) {
|
||||||
|
if (protocol != "file") null
|
||||||
|
else File(file)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ScriptTemplateDefinition(
|
@ScriptTemplateDefinition(
|
||||||
|
|||||||
Reference in New Issue
Block a user