Skip to content

Instantly share code, notes, and snippets.

@izzyleung

izzyleung/BUILD Secret

Last active September 12, 2018 21:54
Show Gist options
  • Save izzyleung/df49c388d87e1647638926fc1ca3d79b to your computer and use it in GitHub Desktop.
Save izzyleung/df49c388d87e1647638926fc1ca3d79b to your computer and use it in GitHub Desktop.
Extract Resource file from Jar file in a Bazel repo

Build & Run

bazel run program
py_binary(
name = "program",
srcs = ["program.py"],
data = ["@auto_value//:autovalue.vm"],
)
with open('../auto_value/autovalue.vm') as vm:
print(vm.read())
new_http_archive(
name = "auto_value",
url = "http://central.maven.org/maven2/com/google/auto/value/auto-value/1.6.2/auto-value-1.6.2.jar",
build_file_content = """\
genrule(
name = "auto_value_template",
srcs = ["com/google/auto/value/processor/autovalue.vm"],
outs = ["autovalue.vm"],
visibility = ["//visibility:public"],
cmd = "cp $< $@"
)
""",
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment