pubref / rules_maven

Transitive maven dependencies with Bazel.
Other
33 stars 7 forks source link

Repositories not working? #20

Closed pierreis closed 5 years ago

pierreis commented 5 years ago

I'm trying to add a dependency on Ktor, with the following definition:

maven_repository(
    name = "ktor",
    repositories = {
        "https://dl.bintray.com/kotlin/ktor": [
            "io.ktor:ktor-server-netty:1.0.0-beta-3",
        ],
    },
)

However, the rule doesn't seem to do anything: no dependency is fetched, and no closed configuration is generated.

Is this behavior expected?

--

The behavior for deps fetched from Maven Central is correct.

WORKSPACE is as follows:

rules_maven_version = "a9e2e9ad465dfe6eed230567d8283ddc563c435c"

http_archive(
    name = "org_pubref_rules_maven",
    urls = ["https://github.com/pubref/rules_maven/archive/%s.zip" % rules_maven_version],
    type = "zip",
    strip_prefix = "rules_maven-%s" % rules_maven_version
)

load("@org_pubref_rules_maven//maven:rules.bzl", "maven_repositories")
maven_repositories()
Globegitter commented 5 years ago

Ha funny, I literally just tried to do the exact same thing (i.e. get started with ktor in bazel) and that seems to start downloading something for me:

maven_repository(
    name = "ktor",
    repositories = {
        "https://dl.bintray.com/kotlin/ktor": [
            "io.ktor:ktor-server-netty",
            "io.ktor:ktor-server-host-common",
            "io.ktor:ktor-server-core",
            "io.ktor:ktor-utils-jvm",
            "io.ktor:ktor-utils",
            "io.ktor:ktor-http-jvm",
            "io.ktor:ktor-http",
            "io.ktor:ktor-http-cio",
            "io.ktor:ktor-network",
        ],
        "http://dl.bintray.com/kotlin/kotlinx": [
            "org.jetbrains.kotlinx:kotlinx-io-jvm",
            "org.jetbrains.kotlinx:kotlinx-io",
            "org.jetbrains.kotlinx:kotlinx-coroutines-io-jvm",
            "org.jetbrains.kotlinx:kotlinx-coroutines-io",
        ]
    },
    deps = [
        "io.ktor:ktor-server-netty:1.0.0-beta-3",
    ],
)

It is a bit cumbersome though to have to specify each package that should be downloaded from a separate repository. Would it be possible to just add a list of additional repositories and these rules would try to download every dependency from every repository in order until the first successful download?

Globegitter commented 5 years ago

As a side note @pierreis are you trying to get this to run with rules_kotlin? That is what I am trying and I have been failing for the last few hours. So if you do get it done and you could link an example repo or gist or something that would be much appreciated.

pierreis commented 5 years ago

And I see on the other side that you also have more or less the same error as me when trying to use Kotlin 1.3. Interesting :) Couldn't make it work either, but your snipped helped a lot for the dependencies.

Would help not having to mention the origin of all dependencies though.

Globegitter commented 5 years ago

ah cool, yeah a little of topic but I have given up for now with kotr, as either I get issues with not having 1.3 or when trying to use 0.9.5 I start getting errors like

Caused by: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: Couldn't inline method call '...' into
... the app code snippet ...
Cause: Not generated
Cause: Couldn't obtain compiled function body for ....
File being compiled at position: (34,39) in ...
The root cause was thrown at: InlineCodegen.kt:515
...

Not sure if you have run into a similar issue like that.

pierreis commented 5 years ago

Actually, it seems that this error comes from the fact that all dependencies are imported by rules_maven, including Kotlin itself, which causes a conflict.

Excluding it from the maven rule works:

maven_repository(
    name = "ktor",
    repositories = {
        "https://dl.bintray.com/kotlin/ktor": [
            "io.ktor:ktor-server-netty",
            "io.ktor:ktor-server-host-common",
            "io.ktor:ktor-server-core",
            "io.ktor:ktor-utils-jvm",
            "io.ktor:ktor-utils",
            "io.ktor:ktor-http-jvm",
            "io.ktor:ktor-http",
            "io.ktor:ktor-http-cio",
            "io.ktor:ktor-network",
        ],
        "http://dl.bintray.com/kotlin/kotlinx": [
            "org.jetbrains.kotlinx:kotlinx-io-jvm",
            "org.jetbrains.kotlinx:kotlinx-io",
            "org.jetbrains.kotlinx:kotlinx-coroutines-io-jvm",
            "org.jetbrains.kotlinx:kotlinx-coroutines-io",
        ]
    },
    deps = [
        "io.ktor:ktor-server-netty:1.0.0-beta-3",
    ],
    omit = [
        "org.jetbrains.kotlin:"
    ]
)
pcj commented 5 years ago

Closing this as it appears no action item.