From fc805afb6090f5f91042b591d63c236a18176a47 Mon Sep 17 00:00:00 2001 From: anna-skrodzka Date: Mon, 28 Oct 2024 18:10:00 +0100 Subject: [PATCH] jar_artifact_callback.bzl deleted --- deps/BUILD | 1 - deps/scala_deps.bzl | 1 - deps/src/BazelExt.scala | 39 +++++++++++++++++++- deps/src/templates/BUILD | 5 --- deps/src/templates/jar_artifact_callback.bzl | 37 ------------------- rules/scala_proto/3rdparty/workspace.bzl | 1 - 6 files changed, 38 insertions(+), 46 deletions(-) delete mode 100644 deps/src/templates/BUILD delete mode 100644 deps/src/templates/jar_artifact_callback.bzl diff --git a/deps/BUILD b/deps/BUILD index 2faad190..69a3c34b 100644 --- a/deps/BUILD +++ b/deps/BUILD @@ -8,7 +8,6 @@ scala_binary( "--scala-version=3.5.2", #TODO ], main_class = "rules_scala3.deps.src.Deps", - resources = ["//deps/src/templates:jar_artifact_callback"], scala = "//scala:bootstrap_3", visibility = ["//visibility:public"], deps = [ diff --git a/deps/scala_deps.bzl b/deps/scala_deps.bzl index 35846dad..a9e83354 100644 --- a/deps/scala_deps.bzl +++ b/deps/scala_deps.bzl @@ -13,7 +13,6 @@ def scala_deps( scala_binary( name = name, main_class = "rules_scala3.deps.src.Deps", - resources = ["@rules_scala3//deps/src/templates:jar_artifact_callback"], scala = "@rules_scala3//scala:bootstrap_3", visibility = ["//visibility:public"], srcs = ["@rules_scala3//deps/src:deps", src], diff --git a/deps/src/BazelExt.scala b/deps/src/BazelExt.scala index 6f11b301..ab827ba4 100644 --- a/deps/src/BazelExt.scala +++ b/deps/src/BazelExt.scala @@ -1,7 +1,44 @@ package rules_scala3.deps.src object BazelExt: - private lazy val jarArtifactCallback = String(getClass.getResourceAsStream("/deps/src/templates/jar_artifact_callback.bzl").readAllBytes()) + private val jarArtifactCallback = + "def _jar_artifact_impl(ctx):\n" + + " jar_name = \"%s.jar\" % ctx.name\n" + + " ctx.download(\n" + + " output = ctx.path(\"jar/%s\" % jar_name),\n" + + " url = ctx.attr.urls,\n" + + " executable = False,\n" + + " )\n" + + " build_file_contents = \"\"\"\n" + + "package(default_visibility = ['//visibility:public'])\n" + + "filegroup(\n" + + " name = 'jar',\n" + + " srcs = ['{jar_name}'],\n" + + " visibility = ['//visibility:public'],\n" + + ")\n" + + "alias(\n" + + " name = \"file\",\n" + + " actual = \":jar\",\n" + + " visibility = [\"//visibility:public\"],\n" + + ")\\n\"\"\".format(artifact = ctx.attr.artifact, jar_name = jar_name)\n" + + " ctx.file(ctx.path(\"jar/BUILD\"), build_file_contents, False)\n" + + " return None\n" + + "\n" + + "jar_artifact = repository_rule(\n" + + " attrs = {\n" + + " \"artifact\": attr.string(mandatory = True),\n" + + " \"urls\": attr.string_list(mandatory = True),\n" + + " },\n" + + " implementation = _jar_artifact_impl,\n" + + ")\n" + + "\n" + + "def jar_artifact_callback(hash):\n" + + " jar_artifact(\n" + + " artifact = hash[\"artifact\"],\n" + + " name = hash[\"name\"],\n" + + " urls = [hash[\"url\"]],\n" + + " )\n" + + " native.bind(name = hash[\"bind\"], actual = hash[\"actual\"])" def apply(targets: Vector[Target]): String = val dependencyLines: String = targets diff --git a/deps/src/templates/BUILD b/deps/src/templates/BUILD deleted file mode 100644 index 2aab196f..00000000 --- a/deps/src/templates/BUILD +++ /dev/null @@ -1,5 +0,0 @@ -filegroup( - name = "jar_artifact_callback", - srcs = ["jar_artifact_callback.bzl"], - visibility = ["//visibility:public"], -) diff --git a/deps/src/templates/jar_artifact_callback.bzl b/deps/src/templates/jar_artifact_callback.bzl deleted file mode 100644 index 93df4cd2..00000000 --- a/deps/src/templates/jar_artifact_callback.bzl +++ /dev/null @@ -1,37 +0,0 @@ -def _jar_artifact_impl(ctx): - jar_name = "%s.jar" % ctx.name - ctx.download( - output = ctx.path("jar/%s" % jar_name), - url = ctx.attr.urls, - executable = False, - ) - build_file_contents = """ -package(default_visibility = ['//visibility:public']) -filegroup( - name = 'jar', - srcs = ['{jar_name}'], - visibility = ['//visibility:public'], -) -alias( - name = "file", - actual = ":jar", - visibility = ["//visibility:public"], -)\n""".format(artifact = ctx.attr.artifact, jar_name = jar_name) - ctx.file(ctx.path("jar/BUILD"), build_file_contents, False) - return None - -jar_artifact = repository_rule( - attrs = { - "artifact": attr.string(mandatory = True), - "urls": attr.string_list(mandatory = True), - }, - implementation = _jar_artifact_impl, -) - -def jar_artifact_callback(hash): - jar_artifact( - artifact = hash["artifact"], - name = hash["name"], - urls = [hash["url"]], - ) - native.bind(name = hash["bind"], actual = hash["actual"]) diff --git a/rules/scala_proto/3rdparty/workspace.bzl b/rules/scala_proto/3rdparty/workspace.bzl index a93ae79e..83f763d6 100644 --- a/rules/scala_proto/3rdparty/workspace.bzl +++ b/rules/scala_proto/3rdparty/workspace.bzl @@ -37,7 +37,6 @@ def jar_artifact_callback(hash): ) native.bind(name = hash["bind"], actual = hash["actual"]) - def list_dependencies(): return [ {"artifact":"com.google.protobuf:protobuf-java:4.28.2","url":"https://oss.sonatype.org/service/local/repositories/releases/content/com/google/protobuf/protobuf-java/4.28.2/protobuf-java-4.28.2.jar","name":"com_google_protobuf_protobuf_java","actual":"@com_google_protobuf_protobuf_java//jar","bind": "jar/com/google/protobuf/protobuf_java"},