rules_java icon indicating copy to clipboard operation
rules_java copied to clipboard

How can I get the special version?

Open daohu527 opened this issue 3 years ago • 2 comments

I'm having a problem with downloading the rules java package from github, do I use a proxy to download the package and copy it into the machine.

The question is how can I get the special version. For example 981f06c3d2bd10225e85209904090eb7b5fb26bd and how can I get the sha256, then I can use below config to load it.

        http_archive(
            name = "rules_java",
            sha256 = "f5a3e477e579231fca27bf202bb0e8fbe4fc6339d63b38ccb87c2760b533d1c3",
            strip_prefix = "rules_java-981f06c3d2bd10225e85209904090eb7b5fb26bd",
            urls = ["file:///tmp/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz"],
        )

daohu527 avatar Feb 15 '22 07:02 daohu527

@daohu527 if you are trying to reference a local repository then you want to use https://docs.bazel.build/versions/main/be/workspace.html#local_repository otherwise urls needs to be an actual URL that http_archive can download from. Ex:

        http_archive(
            name = "rules_java",
            sha256 = "f5a3e477e579231fca27bf202bb0e8fbe4fc6339d63b38ccb87c2760b533d1c3",
            strip_prefix = "rules_java-981f06c3d2bd10225e85209904090eb7b5fb26bd",
            urls = ["https://github.com/bazelbuild/rules_java/archive/981f06c3d2bd10225e85209904090eb7b5fb26bd.tar.gz"],
        )

Bencodes avatar Feb 16 '22 16:02 Bencodes

Thx, it is better to use local_repository, http_archive is also feasible at present (use file:///).

My question is, how is the intermediate version determined?

daohu527 avatar Feb 17 '22 00:02 daohu527

My question is, how is the intermediate version determined?

That version is just the hash of some commit in this repo. You can download the archive from the github UI at a at chosen commit or construct the URL (like mentioned in https://github.com/bazelbuild/rules_java/issues/49#issuecomment-1041856106).

Computing the hash is simple, just run sha256sum <hash>.tar.gz

hvadehra avatar May 17 '24 06:05 hvadehra