Skip to content

Commit 6299f42

Browse files
committed
Switch to Maven dependencies resolver
1 parent 6257af8 commit 6299f42

File tree

11 files changed

+36
-24
lines changed

11 files changed

+36
-24
lines changed

build.gradle.kts

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ dependencies {
103103
implKotlin("scripting-compiler-impl-embeddable")
104104
implKotlin("scripting-compiler-embeddable")
105105
implKotlin("scripting-ide-services")
106-
implKotlin("main-kts")
106+
implKotlin("scripting-dependencies-maven")
107107
implKotlin("script-util")
108108
implKotlin("scripting-common")
109109

docs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
# Kotlin kernel for IPython/Jupyter
1010

11-
[Kotlin](https://kotlinlang.org/) (1.5.30-dev-454) kernel for [Jupyter](https://jupyter.org).
11+
[Kotlin](https://kotlinlang.org/) (1.5.30-dev-598) kernel for [Jupyter](https://jupyter.org).
1212

1313
Beta version. Tested with Jupyter Notebook 6.0.3, Jupyter Lab 1.2.6 and Jupyter Console 6.1.0
1414
on Windows, Ubuntu Linux and macOS.

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# kotlinVersion=1.5.255-SNAPSHOT
2-
kotlinVersion=1.5.30-dev-454
2+
kotlinVersion=1.5.30-dev-598
33
stableKotlinVersion=1.5.0
44
kotlinLanguageLevel=1.5
55
stableKotlinLanguageLevel=1.5

jupyter-lib/lib/src/main/kotlin/jupyter/kotlin/annotations.kt

+20-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,35 @@
11
package jupyter.kotlin
22

3-
// in case of flat or direct resolvers the value should be a direct path or file name of a jar respectively
4-
// in case of maven resolver the maven coordinates string is accepted
3+
/**
4+
* Describes the dependency
5+
*
6+
* @property value Can be one of the following:
7+
* - Maven artifact coordinates in the following form:
8+
* `<groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>}`
9+
* - Path to the JAR file (absolute or relative to the directory specified in [Repository])
10+
*/
511
@Target(AnnotationTarget.FILE)
612
@Repeatable
713
@Retention(AnnotationRetention.SOURCE)
814
annotation class DependsOn(val value: String = "")
915

10-
// only flat directory repositories are supported now, so value should be a path to a directory with jars
16+
/**
17+
* Describes the repository which is used for dependency resolution
18+
*
19+
* @property value Can be one of the following:
20+
* - Maven repository URL
21+
* - Local directory in which JARs are stored
22+
*/
1123
@Target(AnnotationTarget.FILE)
1224
@Repeatable
1325
@Retention(AnnotationRetention.SOURCE)
1426
annotation class Repository(val value: String = "")
1527

28+
/**
29+
* Describes compilation arguments used for the compilation of this and all following snippets
30+
*
31+
* @property values List of free compiler arguments
32+
*/
1633
@Target(AnnotationTarget.FILE)
1734
@Repeatable
1835
@Retention(AnnotationRetention.SOURCE)

jupyter-lib/shared-compiler/src/main/kotlin/org/jetbrains/kotlinx/jupyter/dependencies/RemoteResolverWrapper.kt

+3-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,9 @@ class RemoteResolverWrapper(private val remoteResolver: ExternalDependenciesReso
3838
val path = "$HOME_PATH/.ivy2/cache"
3939
path.toURLString()
4040
},
41-
)
42-
.map {
43-
"$PREFIX${it.shortcut}" to it
44-
}
45-
.toMap()
41+
).associateBy {
42+
"$PREFIX${it.shortcut}"
43+
}
4644

4745
fun hasRepository(repository: RepositoryCoordinates): Boolean {
4846
return repositories.containsKey(repository.string)

libraries/serialization.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"description": "Kotlin multi-format reflection-less serialization",
33
"properties": {
4-
"v": "1.0.1"
4+
"v": "1.1.0"
55
},
66
"link": "https://github.com/Kotlin/kotlinx.serialization",
77
"dependencies": [

src/main/kotlin/org/jetbrains/kotlinx/jupyter/dependencies/JupyterScriptDependenciesResolverImpl.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.jetbrains.kotlinx.jupyter.dependencies
33
import jupyter.kotlin.DependsOn
44
import jupyter.kotlin.Repository
55
import kotlinx.coroutines.runBlocking
6-
import org.jetbrains.kotlin.mainKts.impl.IvyResolver
76
import org.jetbrains.kotlinx.jupyter.config.getLogger
87
import java.io.File
98
import kotlin.script.dependencies.ScriptContents
@@ -18,6 +17,7 @@ import kotlin.script.experimental.dependencies.FileSystemDependenciesResolver
1817
import kotlin.script.experimental.dependencies.RepositoryCoordinates
1918
import kotlin.script.experimental.dependencies.impl.DependenciesResolverOptionsName
2019
import kotlin.script.experimental.dependencies.impl.makeExternalDependenciesResolverOptions
20+
import kotlin.script.experimental.dependencies.maven.MavenDependenciesResolver
2121

2222
open class JupyterScriptDependenciesResolverImpl(resolverConfig: ResolverConfig?) : JupyterScriptDependenciesResolver {
2323

@@ -36,7 +36,7 @@ open class JupyterScriptDependenciesResolverImpl(resolverConfig: ResolverConfig?
3636
init {
3737
resolver = CompoundDependenciesResolver(
3838
FileSystemDependenciesResolver(),
39-
RemoteResolverWrapper(IvyResolver())
39+
RemoteResolverWrapper(MavenDependenciesResolver())
4040
)
4141
resolverConfig?.repositories?.forEach { addRepository(it) }
4242
}

src/main/kotlin/org/jetbrains/kotlinx/jupyter/repl.kt

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import jupyter.kotlin.KotlinKernelHostProvider
77
import jupyter.kotlin.Repository
88
import org.jetbrains.kotlin.config.KotlinCompilerVersion
99
import org.jetbrains.kotlinx.jupyter.api.Code
10-
import org.jetbrains.kotlinx.jupyter.api.CodePreprocessor
1110
import org.jetbrains.kotlinx.jupyter.api.ExecutionCallback
1211
import org.jetbrains.kotlinx.jupyter.api.KotlinKernelHost
1312
import org.jetbrains.kotlinx.jupyter.api.KotlinKernelVersion
@@ -59,7 +58,6 @@ import org.jetbrains.kotlinx.jupyter.repl.impl.SharedReplContext
5958
import java.io.File
6059
import java.net.URLClassLoader
6160
import java.util.concurrent.atomic.AtomicReference
62-
import kotlin.jvm.JvmInline
6361
import kotlin.script.experimental.api.ResultWithDiagnostics
6462
import kotlin.script.experimental.api.ScriptCompilationConfiguration
6563
import kotlin.script.experimental.api.ScriptConfigurationRefinementContext

src/main/resources/logback.xml

+4
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,8 @@
1111
<root level="DEBUG">
1212
<appender-ref ref="STDERR" />
1313
</root>
14+
15+
<logger name="org.apache" level="ERROR" />
16+
<logger name="httpclient" level="ERROR" />
17+
<logger name="org.eclipse.aether" level="INFO" />
1418
</configuration>

src/test/kotlin/org/jetbrains/kotlinx/jupyter/test/ResolverTests.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package org.jetbrains.kotlinx.jupyter.test
22

33
import kotlinx.coroutines.runBlocking
4-
import org.jetbrains.kotlin.mainKts.impl.IvyResolver
54
import org.junit.jupiter.api.Test
65
import org.slf4j.Logger
76
import org.slf4j.LoggerFactory
87
import java.io.File
98
import kotlin.script.experimental.api.ResultWithDiagnostics
109
import kotlin.script.experimental.dependencies.ExternalDependenciesResolver
10+
import kotlin.script.experimental.dependencies.maven.MavenDependenciesResolver
1111
import kotlin.test.assertTrue
1212

1313
class ResolverTests {
@@ -23,7 +23,7 @@ class ResolverTests {
2323

2424
@Test
2525
fun resolveSparkMlLibTest() {
26-
val files = IvyResolver().doResolve("org.apache.spark:spark-mllib_2.11:2.4.4")
26+
val files = MavenDependenciesResolver().doResolve("org.apache.spark:spark-mllib_2.11:2.4.4")
2727
log.debug("Downloaded files: ${files.count()}")
2828
files.forEach {
2929
log.debug(it.toString())

src/test/kotlin/org/jetbrains/kotlinx/jupyter/test/repl/ReplTests.kt

+1-6
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,7 @@ class ReplTests : AbstractSingleReplTest() {
148148
val newClasspath = res.metadata.newClasspath
149149
assertTrue(newClasspath.size >= 2)
150150

151-
val htmlLibPath = listOf(
152-
"org.jetbrains.kotlinx",
153-
"kotlinx-html-jvm",
154-
"jars",
155-
"kotlinx-html-jvm"
156-
).joinToString(File.separator)
151+
val htmlLibPath = "org/jetbrains/kotlinx/kotlinx-html-jvm/0.7.2/kotlinx-html-jvm".replace('/', File.separatorChar)
157152
assertTrue(newClasspath.any { htmlLibPath in it })
158153
}
159154

0 commit comments

Comments
 (0)