rules_scala icon indicating copy to clipboard operation
rules_scala copied to clipboard

Is bazel_skylib needed?

Open olib963 opened this issue 4 years ago • 5 comments

There is a section in the README that states we should add

skylib_version = "1.0.3"
http_archive(
    name = "bazel_skylib",
    sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
    type = "tar.gz",
    url = "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib-{}.tar.gz".format(skylib_version, skylib_version),
)

to our WORKSPACE file. I am just wondering if this is left over documentation? There seems to be no negative effect from not including this archive explicitly and since it is used in the rules not client code I am not sure it is necessary.

Could someone please let me know if there is any reason to add this to our own WORKSPACE?

olib963 avatar Jan 04 '21 12:01 olib963

It depends on which rules are you using. Eg.: https://github.com/bazelbuild/rules_scala/blob/master/scala/private/rules/scala_binary.bzl#L3

liucijus avatar Jan 04 '21 13:01 liucijus

I seem to still be able to build and run a scala_binary even without skylib. Given that you have the dependency here is that not what the scala rules would use?

olib963 avatar Jan 04 '21 13:01 olib963

You may be getting skylib from another dependency like rules_proto, which has its own setup macro https://github.com/bazelbuild/rules_proto/blob/master/proto/private/dependencies.bzl#L18.

We keep skylib at the top of the WORKSPACE to make sure, that we control the version of the library in use.

liucijus avatar Jan 04 '21 13:01 liucijus

Ah OK, perhaps I just don't understand how all of the archives and rules hook together. I don't see us installing rules proto or skylib anywhere manually so if it is being pulled in, it's being done so implicitly from other rules we use such as rules docker. That would raise the question for me though as to why rules scala wouldn't be doing that.

I am happy to close this issue if you are confident that the documentation is accurate and go through the documentation for bazel to understand how this works.

olib963 avatar Jan 04 '21 14:01 olib963

Let's leave this open - it would be great to add explanatory comment in the readme

liucijus avatar Jan 07 '21 08:01 liucijus