Use this tag for questions concerning the use of Bazel aspects, including whether or not an aspect is the right tool for a task.
Questions tagged [bazel-aspect]
31 questions
8
votes
1 answer
Get dependency tree for a bazel target
I am trying to migrate my maven Integration Tests to bazel. There in runtime I am facing some issues. To debug that I want to compare maven dependency:tree to bazel's dependency tree. So as to avoid any extra dependencies OR to detect if I am…

rishi007bansod
- 1,283
- 2
- 19
- 45
5
votes
1 answer
Bazel- How to get all transitive sources of a target
I have a need to write a rule which zips up all transitive config files (*.foo) of an executable (can be custom rule, java_binary and docker container_image).
The config files can appear on the srcs attribute of any attribute of the executable…

Ittai
- 5,625
- 14
- 60
- 97
4
votes
1 answer
How to retrieve the attributes of a Bazel workspace rule using aspects
I'm writing a post-build tool that synthesizes maven pom files after a bazel build. I'm using aspects to gather relevant information on the various targets.
One of the features involves adding external jar dependencies to the relevant pom…

Natan
- 1,944
- 1
- 11
- 16
3
votes
0 answers
Bazel genrule Check if location expression expands to no files
I am writing a genrule in Bazel. I have a file withing a folder that may or may not exist. I want to reference it if it does but ignore it if it does not. How do i do an conditional check in the cmd part of the genrule before doing $(location…

flexxxit
- 2,440
- 5
- 42
- 69
2
votes
2 answers
Running bazel build with an aspect on test targets does not yield test output jars
running bazel build //... \
--aspects some-aspect.bzl%some_aspect \
--output_groups=some_new_output,default
does not create test jars outputs.
on the other hand running bazel test does create the test jar outputs:
bazel test //... \
--aspects…

Natan
- 1,944
- 1
- 11
- 16
2
votes
2 answers
Recommended strategy to accumulate data in bazel aspects output files
I'm writing a post-build tool that needs the location of a list of target's jar files.
For these locations I have an aspect that runs on a list of targets (separately for each target using --aspects) and fetch the jar file path for each of…

Natan
- 1,944
- 1
- 11
- 16
1
vote
0 answers
bazel unable to build typescript locally on windows
I have created a projectB to experiment ts build with bazel.
Here is my BUILD file
load("@aspect_rules_ts//ts:defs.bzl", "ts_project")
ts_project(
name = "ts",
srcs = ["say-hello.ts"],
)
I have pass Windows 10 to dev mode as required (it…

Charles HETIER
- 1,934
- 16
- 28
1
vote
0 answers
Using `rules_scala` + Bazel, how to bundle transitive JARs that are exported as part of a `scala_library` target, without going full `_deploy.jar`?
Let's say I have a library such as:
scala_library(
name = "my_favorite_scala_library",
srcs = glob(["*.scala"]),
exports = [
"A",
"B",
],
deps = [
"A",
"B",
"C",
"D",
…

Frank P.
- 503
- 5
- 21
1
vote
1 answer
Can I add static analysis to a py_binary or py_library rule?
I have a repo which uses bazel to build a bunch of Python code. I would like to introduce various flavors of static analysis into the build and have the build fail if these static analyses throw errors. What is the best way to do this?
For example,…

throwaway_20000
- 11
- 1
1
vote
1 answer
Question about environment variable in toolchain
I am trying to develop a toolchain for wllvm (whole program LLVM) on bazel 3.7 following the tutorial (link to the tutorial). A problem I have is I have to pass an environment variable (LLVM_COMPILER) to wllvm. Can you possibly provide more details…

Ziwen Wan
- 21
- 1
1
vote
0 answers
In implementation of a bazel aspect, is there a way to get the absolute filesystem path of workspace root?
I am trying to implement the generation of clang compilation database in bazel aspect. It appears that the "directory" field of this clang file must be specified as absolute path. Now when I try to generate this file with bazel aspect, all…

xiay
- 855
- 8
- 19
1
vote
1 answer
How to debug java_library rule in a bazel build?
I dug around option and source code but still unsure how to debug a bazel build, java specifically.
Also anyone know how I can change bazel, build it locally and use it on builds to verify. I found bazel invocation:
exec -a "$0" "${BAZEL_REAL}"…

HoaPhan
- 1,714
- 1
- 13
- 35
1
vote
1 answer
error while reading extension file 'intellij_info_bundled.bzl'
we are trying to create a Scala project which uses Spark also but we are facing issue Encountered error while reading extension file 'intellij_info_bundled.bzl': no such package '@intellij_aspect//': No WORKSPACE file found in…

Sandhya
- 51
- 1
- 3
1
vote
1 answer
Bazel build is not working on from Maven project
I'm new to Bazel and learning its build work, currently I am trying to do with bazel build from a Maven project, please advise me how to make it working, thanks.
Here is the WORKSPACE file I am trying to define:
maven_jar(
name = "junit",
…

Jamesjin
- 371
- 2
- 6
- 15
1
vote
1 answer
How to combine bazel aspects and cc_library
I want to build a rule that is very similar to cc_proto_library. The key features are that it would apply an aspect to all the transitive proto_library dependencies and generate .cc and .h files for all of the dependencies. In addition it would…

Eric Dobson
- 343
- 2
- 8