Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Maven dependencies resolver #230

Merged
merged 1 commit into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ dependencies {
implKotlin("scripting-compiler-impl-embeddable")
implKotlin("scripting-compiler-embeddable")
implKotlin("scripting-ide-services")
implKotlin("main-kts")
implKotlin("scripting-dependencies-maven")
implKotlin("script-util")
implKotlin("scripting-common")

Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Kotlin kernel for IPython/Jupyter

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

Beta version. Tested with Jupyter Notebook 6.0.3, Jupyter Lab 1.2.6 and Jupyter Console 6.1.0
on Windows, Ubuntu Linux and macOS.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# kotlinVersion=1.5.255-SNAPSHOT
kotlinVersion=1.5.30-dev-454
kotlinVersion=1.5.30-dev-598
stableKotlinVersion=1.5.0
kotlinLanguageLevel=1.5
stableKotlinLanguageLevel=1.5
Expand Down
23 changes: 20 additions & 3 deletions jupyter-lib/lib/src/main/kotlin/jupyter/kotlin/annotations.kt
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
package jupyter.kotlin

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

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

/**
* Describes compilation arguments used for the compilation of this and all following snippets
*
* @property values List of free compiler arguments
*/
@Target(AnnotationTarget.FILE)
@Repeatable
@Retention(AnnotationRetention.SOURCE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@ class RemoteResolverWrapper(private val remoteResolver: ExternalDependenciesReso
val path = "$HOME_PATH/.ivy2/cache"
path.toURLString()
},
)
.map {
"$PREFIX${it.shortcut}" to it
}
.toMap()
).associateBy {
"$PREFIX${it.shortcut}"
}

fun hasRepository(repository: RepositoryCoordinates): Boolean {
return repositories.containsKey(repository.string)
Expand Down
2 changes: 1 addition & 1 deletion libraries/serialization.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "Kotlin multi-format reflection-less serialization",
"properties": {
"v": "1.0.1"
"v": "1.1.0"
},
"link": "https://github.com/Kotlin/kotlinx.serialization",
"dependencies": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.jetbrains.kotlinx.jupyter.dependencies
import jupyter.kotlin.DependsOn
import jupyter.kotlin.Repository
import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.mainKts.impl.IvyResolver
import org.jetbrains.kotlinx.jupyter.config.getLogger
import java.io.File
import kotlin.script.dependencies.ScriptContents
Expand All @@ -18,6 +17,7 @@ import kotlin.script.experimental.dependencies.FileSystemDependenciesResolver
import kotlin.script.experimental.dependencies.RepositoryCoordinates
import kotlin.script.experimental.dependencies.impl.DependenciesResolverOptionsName
import kotlin.script.experimental.dependencies.impl.makeExternalDependenciesResolverOptions
import kotlin.script.experimental.dependencies.maven.MavenDependenciesResolver

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

Expand All @@ -36,7 +36,7 @@ open class JupyterScriptDependenciesResolverImpl(resolverConfig: ResolverConfig?
init {
resolver = CompoundDependenciesResolver(
FileSystemDependenciesResolver(),
RemoteResolverWrapper(IvyResolver())
RemoteResolverWrapper(MavenDependenciesResolver())
)
resolverConfig?.repositories?.forEach { addRepository(it) }
}
Expand Down
2 changes: 0 additions & 2 deletions src/main/kotlin/org/jetbrains/kotlinx/jupyter/repl.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import jupyter.kotlin.KotlinKernelHostProvider
import jupyter.kotlin.Repository
import org.jetbrains.kotlin.config.KotlinCompilerVersion
import org.jetbrains.kotlinx.jupyter.api.Code
import org.jetbrains.kotlinx.jupyter.api.CodePreprocessor
import org.jetbrains.kotlinx.jupyter.api.ExecutionCallback
import org.jetbrains.kotlinx.jupyter.api.KotlinKernelHost
import org.jetbrains.kotlinx.jupyter.api.KotlinKernelVersion
Expand Down Expand Up @@ -59,7 +58,6 @@ import org.jetbrains.kotlinx.jupyter.repl.impl.SharedReplContext
import java.io.File
import java.net.URLClassLoader
import java.util.concurrent.atomic.AtomicReference
import kotlin.jvm.JvmInline
import kotlin.script.experimental.api.ResultWithDiagnostics
import kotlin.script.experimental.api.ScriptCompilationConfiguration
import kotlin.script.experimental.api.ScriptConfigurationRefinementContext
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,8 @@
<root level="DEBUG">
<appender-ref ref="STDERR" />
</root>

<logger name="org.apache" level="ERROR" />
<logger name="httpclient" level="ERROR" />
<logger name="org.eclipse.aether" level="INFO" />
</configuration>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.jetbrains.kotlinx.jupyter.test

import kotlinx.coroutines.runBlocking
import org.jetbrains.kotlin.mainKts.impl.IvyResolver
import org.junit.jupiter.api.Test
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import java.io.File
import kotlin.script.experimental.api.ResultWithDiagnostics
import kotlin.script.experimental.dependencies.ExternalDependenciesResolver
import kotlin.script.experimental.dependencies.maven.MavenDependenciesResolver
import kotlin.test.assertTrue

class ResolverTests {
Expand All @@ -23,7 +23,7 @@ class ResolverTests {

@Test
fun resolveSparkMlLibTest() {
val files = IvyResolver().doResolve("org.apache.spark:spark-mllib_2.11:2.4.4")
val files = MavenDependenciesResolver().doResolve("org.apache.spark:spark-mllib_2.11:2.4.4")
log.debug("Downloaded files: ${files.count()}")
files.forEach {
log.debug(it.toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,7 @@ class ReplTests : AbstractSingleReplTest() {
val newClasspath = res.metadata.newClasspath
assertTrue(newClasspath.size >= 2)

val htmlLibPath = listOf(
"org.jetbrains.kotlinx",
"kotlinx-html-jvm",
"jars",
"kotlinx-html-jvm"
).joinToString(File.separator)
val htmlLibPath = "org/jetbrains/kotlinx/kotlinx-html-jvm/0.7.2/kotlinx-html-jvm".replace('/', File.separatorChar)
assertTrue(newClasspath.any { htmlLibPath in it })
}

Expand Down