Skip to content

Commit 4e426fb

Browse files
ittaizIgal Tabachnik
authored and
Igal Tabachnik
committed
Update docs (bazel-contrib#329)
* escape rule names * strict deps documentation
1 parent 9102f23 commit 4e426fb

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ of a series of independent files in a larger target into smaller ones. This lets
395395
and also build the indvidual targets in parallel. Downstream targets should not be aware of its presence.
396396

397397
<a name="scala_test_suite"></a>
398-
## scala_test_suite
398+
## scala\_test_suite
399399

400400
The scala test suite allows you to define a glob or series of targets to generate sub
401401
scala tests for. The outer target defines a native test suite to run all the inner tests. This allows splitting up
@@ -469,7 +469,7 @@ thrift_library(name, srcs, deps, absolute_prefix, absolute_prefixes)
469469
</table>
470470

471471
<a name="scalapb_proto_library"></a>
472-
## scalapb_proto_library
472+
## scalapb\_proto_library
473473

474474
You first need to add the following to your WORKSPACE file:
475475

@@ -543,6 +543,30 @@ generated by the [ScalaPB compiler](https://github.com/scalapb/ScalaPB).
543543
</tbody>
544544
</table>
545545

546+
## [Experimental] Using strict-deps
547+
Bazel pushes towards explicit and minimial dependencies to keep BUILD file higene and allow for targets to refactor their dependencies without fear of downstream breaking.
548+
Currently rules_scala does this at the cost of having cryptic `scalac` errors when one mistakenly depends on a transitive dependency or, as more often the case for some, a transitive dependency is needed to [please scalac](https://github.com/scalacenter/advisoryboard/blob/master/proposals/009-improve-direct-dependency-experience.md) itself.
549+
To learn more about the motivation of strict-deps itself you can visit this Bazel blog [post](https://blog.bazel.build/2017/06/28/sjd-unused_deps.html) on the subject.
550+
551+
To use it just add `--strict_java_deps=WARN|ERROR` to your `bazel` invocation.
552+
In both cases of `WARN` or `ERROR` you will get the following text in the event of a violation:
553+
```
554+
...
555+
Target '//some_package:transitive_dependency' is used but isn't explicitly declared, please add it to the deps.
556+
You can use the following buildozer command:
557+
buildozer 'add deps //some_package:transitive_dependency' //some_other_package:transitive_dependency_user
558+
```
559+
Note that if you have `buildozer` installed you can just run the last line and have it automatically apply the fix for you.
560+
561+
**Caveats:**
562+
<ul>
563+
<li>Extra builds- when strict-deps is on the transitive dependencies are inputs to the compilation action which means you can potentially have more build triggers for changes the cross the ijar boundary </li>
564+
<li>Label propagation- since label of targets are needed for the clear message and since it's not currently supported by JavaInfo from bazel we manually propagate it. This means that the error messages have a significantly lower grade if you don't use one of the scala rules or scala_import (since they don't propagate these labels)</li>
565+
<li>javac outputs incorrect targets due to a problem we're tracing down. Practically we've noticed it's pretty trivial to understand the correct target (i.e. it's almost a formatting problem) </li>
566+
</ul>
567+
568+
Note: Currently strict-deps is protected by a feature toggle but we're strongly considering making it the default behavior as `java_*` rules do.
569+
546570
## Building from source
547571
Test & Build:
548572
```

0 commit comments

Comments
 (0)