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

Support bazel 2.0 #4

Closed
marplesoft opened this issue Mar 8, 2020 · 6 comments
Closed

Support bazel 2.0 #4

marplesoft opened this issue Mar 8, 2020 · 6 comments

Comments

@marplesoft
Copy link
Contributor

marplesoft commented Mar 8, 2020

Currently under bazel 2.0 I get the following:

ERROR: /private/var/tmp/_bazel_[username]/1f8310a13b66369d223611f315edd44f/external/rules_clojure/runtime.bzl:2:5: Traceback (most recent call last):
	File "/Users/[username]/Dev/v1monorepo/WORKSPACE", line 145
		clojure_runtime()
	File "/private/var/tmp/_bazel_[username]/1f8310a13b66369d223611f315edd44f/external/rules_clojure/runtime.bzl", line 2, in clojure_runtime
		native.maven_jar
no native function or rule 'maven_jar'

See: bazelbuild/bazel#6799

@marplesoft
Copy link
Contributor Author

Happy to try to get this working and send a PR if you're interested.

I modified the use of native.maven_jar to use jvm_maven_import_external from @bazel_tools//tools/build_defs/repo:jvm.bzl which worked. Thought not sure if this breaks use in bazel 1.x.

Then I had other issues with importing rules.bzl into my workspace because it used labels not qualified with the repo name. This thread explained why you have to qualify all labels with @rules_clojure: https://groups.google.com/forum/#!topic/bazel-discuss/qNuyIu-akq8
Not sure if this later issue was also a bazel 2.0 change or not.

@simuons
Copy link
Owner

simuons commented Mar 20, 2020

Oh sorry I've missed that one. If you could send a PR that would be great. If not I'll take care of this on weekend.

@simuons
Copy link
Owner

simuons commented Mar 20, 2020

I felt guilty for not responding in timely manner so I changed maven_jar myself. I'll take a look to label qualifiers. Thanks for reporting.

@marplesoft
Copy link
Contributor Author

Great, thanks. I have a hacked-up local copy that mostly works and happy to work on a PR. Regarding label qualifiers, what I did, and what appears to be the recommended solution, is to qualify all non-relative labels with @rules_clojure, so like here would become

toolchains = ["@rules_clojure//rules:toolchain_type"],

@marplesoft
Copy link
Contributor Author

Another issue, which isn't this problem of this project, is that org.clojure:clojure and org.clojure:spec.alpha and org.clojure:core.specs.alpha have circular dependencies between them that bazel rejects. I've resolved this in an ugly way by doing this:

load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@rules_jvm_external//:specs.bzl", "maven")

maven_install(
    artifacts = [
        "com.amazonaws:amazon-kinesis-client:1.8.4", // for example
        ...
        maven.artifact(
            "org.clojure",
            "clojure",
            "1.10.1",
            exclusions = [
                "org.clojure:core.specs.alpha",
                "org.clojure:spec.alpha",
            ]
        ),
        maven.artifact(
            "org.clojure",
            "spec.alpha",
            "0.2.176",
            exclusions = [
                "org.clojure:clojure"
            ]
        ),
        maven.artifact(
            "org.clojure",
            "core.specs.alpha",
            "0.2.44",
            exclusions = [
                "org.clojure:clojure"
            ]
        )
    ],
    repositories = [
        "https://repo1.maven.org/maven2",
        "https://repo.clojars.org"
    ],
)

Just mentioning here in case it helps others.

marplesoft added a commit to marplesoft/rules_clojure that referenced this issue Mar 21, 2020
This should allow these rules to be imported into a user workspace. See simuons#4 for background.
simuons pushed a commit that referenced this issue Mar 23, 2020
This should allow these rules to be imported into a user workspace. See #4 for background.
@simuons
Copy link
Owner

simuons commented Jul 28, 2020

Repo now has ci which build and test against bazel 3.4.1
Probably toolchain needs to be improved to accept clojure deps from different loaders.
I home I'll make this change some time in near future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants