|
| 1 | +"""Module extensions for local and remote java repositories""" |
| 2 | + |
| 3 | +load(":local_java_repository.bzl", "local_java_repository") |
| 4 | +load(":remote_java_repository.bzl", "remote_java_repository") |
| 5 | + |
| 6 | +visibility(["//java"]) |
| 7 | + |
| 8 | +def _java_repository_impl(mctx): |
| 9 | + for mod in mctx.modules: |
| 10 | + for local in mod.tags.local: |
| 11 | + local_java_repository( |
| 12 | + local.name, |
| 13 | + java_home = local.java_home, |
| 14 | + version = local.version, |
| 15 | + build_file = local.build_file, |
| 16 | + build_file_content = local.build_file_content, |
| 17 | + ) |
| 18 | + for remote in mod.tags.remote: |
| 19 | + remote_java_repository( |
| 20 | + remote.name, |
| 21 | + remote.version, |
| 22 | + target_compatible_with = remote.target_compatible_with, |
| 23 | + prefix = remote.prefix, |
| 24 | + sha256 = remote.sha256, |
| 25 | + strip_prefix = remote.strip_prefix, |
| 26 | + urls = remote.urls, |
| 27 | + ) |
| 28 | + |
| 29 | +_local = tag_class(attrs = { |
| 30 | + "name": attr.string(mandatory = True), |
| 31 | + "build_file": attr.label(default = None), |
| 32 | + "build_file_content": attr.string(default = ""), |
| 33 | + "java_home": attr.string(default = ""), |
| 34 | + "version": attr.string(default = ""), |
| 35 | +}) |
| 36 | + |
| 37 | +_remote = tag_class(attrs = { |
| 38 | + "name": attr.string(mandatory = True), |
| 39 | + "version": attr.string(mandatory = True), |
| 40 | + "urls": attr.string_list(mandatory = True), |
| 41 | + "prefix": attr.string(default = ""), |
| 42 | + "sha256": attr.string(default = ""), |
| 43 | + "strip_prefix": attr.string(default = ""), |
| 44 | + "target_compatible_with": attr.label_list(default = []), |
| 45 | +}) |
| 46 | + |
| 47 | +java_repository = module_extension( |
| 48 | + _java_repository_impl, |
| 49 | + tag_classes = { |
| 50 | + "local": _local, |
| 51 | + "remote": _remote, |
| 52 | + }, |
| 53 | +) |
0 commit comments