How can I exclude a transitive dependencies just like Maven exclusions?
In maven, we often use exclusions to exclude them. But I didn't find it in the bazel.
How can I exclude a transitive dependencies just like Maven exclusions?
In maven, we often use exclusions to exclude them. But I didn't find it in the bazel.
Copyright © 2021 Jogjafile Inc.
If you wanted optional dependencies in your tree, you would need to model them into the tree using
select()to shape said tree at build time. E.g. instead of:You the
intermediatetarget would looks like:To not include the dependency on
libBwhen config setting or constraint value:conditiona1is matched in the current config. The whole reading on configurable attributes is in the docs.If you wanted to extricate transitive dependency already hard-wired into the tree (e.g. pre-canned 3rd party dep you must take as is and have no control over)... and your specific rule used does not implement such behavior (note: "built-in" things like
cc_binary,py_binary, ... generally do not), you could write a custom rule that could go through values (dependencies) passed through an attribute and process the list incl. disregarding some labels therein as perhaps passed through another attribute.