Skip to content

Instantly share code, notes, and snippets.

@seanwentzel
Created June 20, 2019 01:15
Show Gist options
  • Save seanwentzel/a89f994578326ec80e53c6c33ad0e59d to your computer and use it in GitHub Desktop.
Save seanwentzel/a89f994578326ec80e53c6c33ad0e59d to your computer and use it in GitHub Desktop.
scala_rules_annex doesn't work as expected with resources
load("@rules_scala_annex//rules:scala.bzl", "scala_binary", "scala_library")
package(default_visibility = ["//visibility:public"])
scala_library(
name="library",
srcs=["Library.scala"],
resources=["in_library.txt"]
)
scala_binary(
name="binary",
exports=[":library"],
resources = ["in_binary.txt"],
main_class="Library"
)
import scala.io.Source
object Library {
def main(args: Array[String]) {
println("Hello world!")
outputFile("/in_library.txt")
outputFile("/in_binary.txt")
}
def outputFile(path: String) = println {
Source.fromInputStream(getClass.getResourceAsStream(path))
.getLines().mkString("\n")
}
}
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
rules_scala_annex_commit = "651fa6b9dd324cfff14c79b0f73bf817a7bee96e"
rules_scala_annex_sha256 = "f2147df37ad02a6a700cf90c570dfb99ded69c2d140ead05f829a8f5c022e5ce"
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",
remote = "https://github.com/bazelbuild/bazel-skylib.git",
tag = "0.8.0",
)
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",
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment