How to get Bazel workspace rule attributes using aspects

I am writing a post-build tool that synthesizes maven pom files after bazel builds. I use aspects to collect relevant information for various purposes.

One of the functions includes adding jar external dependencies to the corresponding pom files.

Suppose our workspace contains the following goal:

maven_jar(
 name = "com_google_guava_guava",
 artifact = "com.google.guava:guava:19.0",
)

and one of our BUILD files contains a target that has guava as a dependency

scala_library(

name = "somename",
srcs = glob(["*.scala"]) + glob(["*.java"]),
deps = [
    "@com_google_guava_guava//jar:file" , 
],

In terms of this goal, how can you get the maven_jar attributes, in particular the artifact ?

(The closest I was able to get:

[InputFileConfiguredTarget(@com_google_guava_guava//jar:guava-19.0.jar)]

Use ctx.rule.attr.srcs)

, ,

, . ?

+4

Source: https://habr.com/ru/post/1678167/


All Articles