Skip to content

Commit

Permalink
jar_artifact_callback.bzl deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
anna-skrodzka committed Oct 28, 2024
1 parent 4c23373 commit fc805af
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 46 deletions.
1 change: 0 additions & 1 deletion deps/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 0 additions & 1 deletion deps/scala_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
39 changes: 38 additions & 1 deletion deps/src/BazelExt.scala
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 0 additions & 5 deletions deps/src/templates/BUILD

This file was deleted.

37 changes: 0 additions & 37 deletions deps/src/templates/jar_artifact_callback.bzl

This file was deleted.

1 change: 0 additions & 1 deletion rules/scala_proto/3rdparty/workspace.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down

0 comments on commit fc805af

Please sign in to comment.