@@ -19,6 +19,13 @@ Track the feature request for target diffing in Bazel [here](https://github.com/
1919
2020This approach was inspired by the [ following BazelConf talk] ( https://www.youtube.com/watch?v=9Dk7mtIm7_A ) by Benjamin Peterson.
2121
22+ > There are simpler and faster ways to approximate the affected set of targets.
23+ > However an incorrect solution can result in a system you can't trust,
24+ > because tests could be broken at a commit where you didn't select to run them.
25+ > Then you can't rely on green-to-red (or red-to-green) transitions and
26+ > lose much of the value from your CI system as breakages can be discovered
27+ > later on unrelated commits.
28+
2229## Prerequisites
2330
2431* Git
@@ -156,16 +163,43 @@ workspace.
156163
157164## Installing
158165
159- ### Run from Source
166+ ### Integrate into your project (recommended)
160167
161- After cloning down the repo, you are good to go, Bazel will handle the rest
168+ Add to your ` WORKSPACE ` file:
162169
163- To run the project
170+ ``` bazel
171+ load(" @bazel_tools//tools/build_defs/repo:http.bzl" , " http_jar" )
172+
173+ http_jar(
174+ name = " bazel_diff" ,
175+ urls = [
176+ " https://github.com/Tinder/bazel-diff/releases/download/2.0.0/bazel-diff_deploy.jar" ,
177+ ],
178+ sha256 = " c16296d2c770365a410253c8f6dc88061f412ca94cc1cbe4328705e4eed50378" ,
179+ )
180+ ```
181+
182+ and then in your root ` BUILD.bazel ` file:
183+
184+ ``` bazel
185+ load(" @rules_java//java:defs.bzl" , " java_binary" )
186+
187+ java_binary(
188+ name = " bazel-diff" ,
189+ main_class = " com.bazel_diff.BazelDiff" ,
190+ runtime_deps = [" @bazel_diff//jar" ],
191+ )
192+ ```
193+
194+ now run the tool with
164195
165196``` terminal
166- bazel run :bazel-diff -- bazel-diff -h
197+ bazel run // :bazel-diff
167198```
168199
200+
201+ > Note, in releases prior to 2.0.0 the value for the ` main_class ` attribute is just ` BazelDiff `
202+
169203#### Debugging
170204
171205To run ` bazel-diff ` with debug logging, run your commands with the ` verbose ` config like so:
@@ -181,14 +215,24 @@ curl -LO bazel-diff.jar GITHUB_RELEASE_JAR_URL
181215java -jar bazel-diff.jar -h
182216```
183217
218+ ### Build from Source
219+
220+ After cloning down the repo, you are good to go, Bazel will handle the rest
221+
222+ To run the project
223+
224+ ``` terminal
225+ bazel run :bazel-diff -- bazel-diff -h
226+ ```
227+
184228### Build your own deployable JAR
185229
186230``` terminal
187231bazel build //src/main/java/com/bazel_diff:bazel-diff_deploy.jar
188232java -jar bazel-bin/src/main/java/com/bazel_diff/bazel-diff_deploy.jar # This JAR can be run anywhere
189233```
190234
191- ### Integrate directly into your Bazel Project
235+ ### Build from sources in your Bazel Project
192236
193237Add the following to your ` WORKSPACE ` file to add the external repositories, replacing the ` RELEASE_ARCHIVE_URL ` with the archive url of the bazel-diff release you wish to depend on:
194238
0 commit comments