Private maven repositories in Kotlin notebooks?

Hi,

I’m trying to use Kotlin in Datalore, and I’d like to be able to add a private Maven repository for some dependencies that are not publicly available. I have username/token for https basic authentication, but I can’t seem to figure out what is the right syntax for declaring a @Repository with authentication?

Thanks,
Carter

Hi, Carter!

Kotlin Jupyter kernel uses Kotlin script resolver for Maven dependencies. Thus, it requires a support for private Maven repos in Kotlin scripts, which is currently non-implemented. You can track the progress of that feature here and as soon as it is done, we will ask Kotlin Jupyter team to support it in the kernel.

P.S. Sorry for the late answer!

2 Likes

If I set up a Jupyter notebook on my desktop with the Kotlin kernel, I can load dependencies from mavenLocal.

Is it feasible to upload a maven local repo to Datalore as an alternative? Is there any good guidance on getting that set up with the correct paths?

Basically, there are two ways:

  1. If you have built jars you can just upload them to the Attached Files and just depend on the jars directly:
    @file:DependsOn("<relative_path_to_jar>")
  2. If you want to stick to the approach with local Maven, you can upload the needed packages as they are in your local Maven repository (preserving file structure) to the Attached Files and use:
    @file:Repository("file:<repository_root_folder>")
    And then depend on the packages the usual way by providing Maven coordinates.
1 Like

Thank you for the suggestions and help, I really appreciate it. I’ll be giving these a try and will let you know if I have any other questions. But I think this will unblock me for now.

Thanks,
Carter

2 Likes

Hi,

I was able to get this working with a fat JAR. It was a bit of a pain to set up, although I thought I’d share the solution in case it helps others.

I created a new gradle module to pull in my dependencies and relies on the Shadow plugin to merge everything together. The trick was excluding transitive dependencies, so they don’t get included in the JAR. The build.gradle.kts looks something like this:

plugins {
    id("java")
    id("com.github.johnrengelman.shadow")
}
configurations {
    "implementation" {
        // exclude things available within the Kotlin notebook environment
        exclude("org.jetbrains.kotlin")
        exclude("org.jetbrains.kotlinx")
        exclude("org.jetbrains.exposed")
        ...
    }
}
dependencies {
    implementation(project(":myModuleOne"))
    implementation(project(":myModuleTwo"))
    ...
}

Thanks,
Carter

1 Like