Created
July 13, 2019 05:59
-
-
Save SeaJaredCode/0004b206aaa5650d83ccc09c10716589 to your computer and use it in GitHub Desktop.
Resource jars not included example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load("@rules_scala_annex//rules:scala.bzl", "scala_binary") | |
| # Binary with resources works as expected | |
| scala_binary( | |
| name = "bin_res", | |
| srcs = glob(["*.scala"]), | |
| resources = ["some_resource.txt"], | |
| main_class = "SomeClass", | |
| ) | |
| # Externally defined resource jar | |
| java_library( | |
| name = "some_resources", | |
| resources = ["some_resource.txt"], | |
| ) | |
| # Does not include resource jar in output (unless _deploy.jar) | |
| scala_binary( | |
| name = "bin_missing_res", | |
| srcs = glob(["*.scala"]), | |
| resource_jars = [ | |
| ":some_resources", | |
| ], | |
| main_class = "SomeClass", | |
| ) | |
| # Correctly includes the resource jar, but unnecessarily redundant | |
| scala_binary( | |
| name = "bin_includes_res", | |
| srcs = glob(["*.scala"]), | |
| resource_jars = [ | |
| ":some_resources", | |
| ], | |
| deps = [ | |
| ":some_resources", | |
| ], | |
| deps_used_whitelist = [ | |
| ":some_resources", | |
| ], | |
| main_class = "SomeClass", | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| hello world |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SomeClass { | |
| def main(args: Array[String]): Unit = println("Hello Cleveland!") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | |
| load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | |
| # Load rules scala annex | |
| # Load rules scala annex | |
| rules_scala_annex_commit = "0a8fb17406addde7925a64d80895e248920af178" | |
| rules_scala_annex_sha256 = "4624fe69d78d46a8b912e91168c7102ad24ec3896cca6f0518db89f414c1caa7" | |
| http_archive( | |
| name = "rules_scala_annex", | |
| sha256 = rules_scala_annex_sha256, | |
| strip_prefix = "rules_scala-{}".format(rules_scala_annex_commit), | |
| url = "https://github.com/higherkindness/rules_scala/archive/{}.zip".format(rules_scala_annex_commit), | |
| ) | |
| http_archive( | |
| name = "rules_jvm_external", | |
| sha256 = "515ee5265387b88e4547b34a57393d2bcb1101314bcc5360ec7a482792556f42", | |
| strip_prefix = "rules_jvm_external-2.1", | |
| url = "https://github.com/bazelbuild/rules_jvm_external/archive/2.1.zip", | |
| ) | |
| load("@rules_scala_annex//rules/scala:workspace.bzl", "scala_register_toolchains", "scala_repositories") | |
| scala_repositories() | |
| scala_register_toolchains() | |
| # Load bazel skylib and google protobuf | |
| git_repository( | |
| name = "bazel_skylib", | |
| # tag = "0.8.0", | |
| commit = "3721d32c14d3639ff94320c780a60a6e658fb033", | |
| remote = "https://github.com/bazelbuild/bazel-skylib.git", | |
| shallow_since = "1553102012 +0100", | |
| ) | |
| http_archive( | |
| name = "com_google_protobuf", | |
| sha256 = "0963c6ae20340ce41f225a99cacbcba8422cebe4f82937f3d9fa3f5dd7ae7342", | |
| strip_prefix = "protobuf-9f604ac5043e9ab127b99420e957504f2149adbe", | |
| urls = ["https://github.com/google/protobuf/archive/9f604ac5043e9ab127b99420e957504f2149adbe.zip"], | |
| ) | |
| load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") | |
| protobuf_deps() | |
| # Specify the scala compiler we wish to use; in this case, we'll use the default one specified in rules_scala_annex | |
| bind( | |
| name = "default_scala", | |
| actual = "@rules_scala_annex//src/main/scala:zinc_2_12_8", | |
| ) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note I would usually use a scala_library for any source, but aimed for a minimal example. The same results in both cases.