Move ivy resolver to the main-kts to avoid classloading issues...
e.g. when main-kts is loaded in IDEA #KT-26828 fixed
This commit is contained in:
@@ -37,6 +37,7 @@ dependencies {
|
||||
fatJarContents(project(it)) { isTransitive = false }
|
||||
testCompile(project(it))
|
||||
}
|
||||
compileOnly("org.apache.ivy:ivy:2.4.0")
|
||||
runtime(project(":kotlin-compiler"))
|
||||
runtime(project(":kotlin-reflect"))
|
||||
fatJarContents("org.apache.ivy:ivy:2.4.0")
|
||||
|
||||
+17
-2
@@ -3,7 +3,7 @@
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.script.util.resolvers
|
||||
package org.jetbrains.kotlin.mainKts.impl
|
||||
|
||||
import org.apache.ivy.Ivy
|
||||
import org.apache.ivy.core.LogOptions
|
||||
@@ -18,8 +18,13 @@ import org.apache.ivy.plugins.resolver.URLResolver
|
||||
import org.apache.ivy.util.DefaultMessageLogger
|
||||
import org.apache.ivy.util.Message
|
||||
import org.jetbrains.kotlin.script.util.DependsOn
|
||||
import org.jetbrains.kotlin.script.util.KotlinAnnotatedScriptDependenciesResolver
|
||||
import org.jetbrains.kotlin.script.util.Repository
|
||||
import org.jetbrains.kotlin.script.util.resolvers.DirectResolver
|
||||
import org.jetbrains.kotlin.script.util.resolvers.Resolver
|
||||
import java.io.File
|
||||
import java.net.MalformedURLException
|
||||
import java.net.URL
|
||||
|
||||
class IvyResolver : Resolver {
|
||||
|
||||
@@ -116,4 +121,14 @@ class IvyResolver : Resolver {
|
||||
Message.setDefaultLogger(DefaultMessageLogger(1))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun String.toRepositoryUrlOrNull(): URL? =
|
||||
try {
|
||||
URL(this)
|
||||
} catch (_: MalformedURLException) {
|
||||
null
|
||||
}
|
||||
|
||||
class FilesAndIvyResolver :
|
||||
KotlinAnnotatedScriptDependenciesResolver(emptyList(), arrayListOf(DirectResolver(), IvyResolver()).asIterable())
|
||||
@@ -5,8 +5,8 @@
|
||||
|
||||
package org.jetbrains.kotlin.mainKts
|
||||
|
||||
import org.jetbrains.kotlin.mainKts.impl.FilesAndIvyResolver
|
||||
import org.jetbrains.kotlin.script.util.DependsOn
|
||||
import org.jetbrains.kotlin.script.util.FilesAndIvyResolver
|
||||
import org.jetbrains.kotlin.script.util.Repository
|
||||
import java.io.File
|
||||
import kotlin.script.dependencies.ScriptContents
|
||||
@@ -17,7 +17,6 @@ import kotlin.script.experimental.jvm.JvmDependency
|
||||
import kotlin.script.experimental.jvm.compat.mapLegacyDiagnosticSeverity
|
||||
import kotlin.script.experimental.jvm.compat.mapLegacyScriptPosition
|
||||
import kotlin.script.experimental.jvm.dependenciesFromClassContext
|
||||
import kotlin.script.experimental.jvm.dependenciesFromCurrentContext
|
||||
import kotlin.script.experimental.jvm.jvm
|
||||
|
||||
@Suppress("unused")
|
||||
|
||||
@@ -16,7 +16,6 @@ dependencies {
|
||||
compileOnly("com.jcabi:jcabi-aether:0.10.1")
|
||||
compileOnly("org.sonatype.aether:aether-api:1.13.1")
|
||||
compileOnly("org.apache.maven:maven-core:3.0.3")
|
||||
compileOnly("org.apache.ivy:ivy:2.4.0")
|
||||
testCompileOnly(project(":compiler:cli"))
|
||||
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
||||
testRuntime(project(":kotlin-reflect"))
|
||||
@@ -25,7 +24,6 @@ dependencies {
|
||||
testRuntime("com.jcabi:jcabi-aether:0.10.1")
|
||||
testRuntime("org.sonatype.aether:aether-api:1.13.1")
|
||||
testRuntime("org.apache.maven:maven-core:3.0.3")
|
||||
testRuntime("org.apache.ivy:ivy:2.4.0")
|
||||
compileOnly(intellijDep()) { includeJars("openapi", "util") }
|
||||
testCompile(intellijDep()) { includeJars("openapi", "platform-api", "util") }
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ dependencies {
|
||||
compileOnly("com.jcabi:jcabi-aether:0.10.1")
|
||||
compileOnly("org.sonatype.aether:aether-api:1.13.1")
|
||||
compileOnly("org.apache.maven:maven-core:3.0.3")
|
||||
compileOnly("org.apache.ivy:ivy:2.4.0")
|
||||
testCompileOnly(project(":compiler:cli"))
|
||||
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
||||
testRuntime(project(":kotlin-reflect"))
|
||||
@@ -25,7 +24,6 @@ dependencies {
|
||||
testRuntime("com.jcabi:jcabi-aether:0.10.1")
|
||||
testRuntime("org.sonatype.aether:aether-api:1.13.1")
|
||||
testRuntime("org.apache.maven:maven-core:3.0.3")
|
||||
testRuntime("org.apache.ivy:ivy:2.4.0")
|
||||
compileOnly(intellijDep()) { includeJars("openapi", "util") }
|
||||
testCompile(intellijDep()) { includeJars("openapi", "util") }
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ dependencies {
|
||||
compileOnly("com.jcabi:jcabi-aether:0.10.1")
|
||||
compileOnly("org.sonatype.aether:aether-api:1.13.1")
|
||||
compileOnly("org.apache.maven:maven-core:3.0.3")
|
||||
compileOnly("org.apache.ivy:ivy:2.4.0")
|
||||
testCompileOnly(project(":compiler:cli"))
|
||||
testCompile(project(":kotlin-test:kotlin-test-junit"))
|
||||
testRuntime(project(":kotlin-reflect"))
|
||||
@@ -25,7 +24,6 @@ dependencies {
|
||||
testRuntime("com.jcabi:jcabi-aether:0.10.1")
|
||||
testRuntime("org.sonatype.aether:aether-api:1.13.1")
|
||||
testRuntime("org.apache.maven:maven-core:3.0.3")
|
||||
testRuntime("org.apache.ivy:ivy:2.4.0")
|
||||
compileOnly(intellijDep()) { includeJars("openapi", "util") }
|
||||
testCompile(intellijDep()) { includeJars("openapi", "platform-api", "util") }
|
||||
}
|
||||
|
||||
-2
@@ -78,5 +78,3 @@ class LocalFilesResolver :
|
||||
class FilesAndMavenResolver :
|
||||
KotlinAnnotatedScriptDependenciesResolver(emptyList(), arrayListOf(DirectResolver(), MavenResolver()))
|
||||
|
||||
class FilesAndIvyResolver :
|
||||
KotlinAnnotatedScriptDependenciesResolver(emptyList(), arrayListOf(DirectResolver(), IvyResolver()))
|
||||
|
||||
-4
@@ -18,7 +18,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.script.util.templates
|
||||
|
||||
import org.jetbrains.kotlin.script.util.FilesAndIvyResolver
|
||||
import org.jetbrains.kotlin.script.util.FilesAndMavenResolver
|
||||
import org.jetbrains.kotlin.script.util.LocalFilesResolver
|
||||
import kotlin.script.templates.ScriptTemplateDefinition
|
||||
@@ -29,9 +28,6 @@ abstract class StandardArgsScriptTemplateWithLocalResolving(val args: Array<Stri
|
||||
@ScriptTemplateDefinition(resolver = FilesAndMavenResolver::class, scriptFilePattern = ".*\\.kts")
|
||||
abstract class StandardArgsScriptTemplateWithMavenResolving(val args: Array<String>)
|
||||
|
||||
@ScriptTemplateDefinition(resolver = FilesAndIvyResolver::class, scriptFilePattern = ".*\\.kts")
|
||||
abstract class StandardArgsScriptTemplateWithIvyResolving(val args: Array<String>)
|
||||
|
||||
@ScriptTemplateDefinition(resolver = LocalFilesResolver::class, scriptFilePattern = ".*\\.kts")
|
||||
abstract class BindingsScriptTemplateWithLocalResolving(val bindings: Map<String, Any?>)
|
||||
|
||||
|
||||
-12
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.config.JVMConfigurationKeys
|
||||
import org.jetbrains.kotlin.script.KotlinScriptDefinition
|
||||
import org.jetbrains.kotlin.script.KotlinScriptDefinitionFromAnnotatedTemplate
|
||||
import org.jetbrains.kotlin.script.util.templates.BindingsScriptTemplateWithLocalResolving
|
||||
import org.jetbrains.kotlin.script.util.templates.StandardArgsScriptTemplateWithIvyResolving
|
||||
import org.jetbrains.kotlin.script.util.templates.StandardArgsScriptTemplateWithLocalResolving
|
||||
import org.jetbrains.kotlin.script.util.templates.StandardArgsScriptTemplateWithMavenResolving
|
||||
import org.jetbrains.kotlin.utils.PathUtil.getResourcePathForClass
|
||||
@@ -106,17 +105,6 @@ done
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testIvyResolveStdJUnitHelloWorld() {
|
||||
val scriptClass = compileScript("args-junit-hello-world.kts", StandardArgsScriptTemplateWithIvyResolving::class)
|
||||
Assert.assertNotNull(scriptClass)
|
||||
captureOut {
|
||||
scriptClass!!.getConstructor(Array<String>::class.java)!!.newInstance(arrayOf("a1"))
|
||||
}.let {
|
||||
Assert.assertEquals(argsHelloWorldOutput.linesSplitTrim(), it.linesSplitTrim())
|
||||
}
|
||||
}
|
||||
|
||||
private fun compileScript(
|
||||
scriptFileName: String,
|
||||
scriptTemplate: KClass<out Any>,
|
||||
|
||||
Reference in New Issue
Block a user