Skip to content

Commit ffca3ab

Browse files
author
Alex Eagle
committed
README: give shorter install instruction with http_jar
Re-order the installation methods in order of how likely we think they are to be right for more use cases. Also give a bit more motivating explanation for why correct affectedness calculation matters
1 parent 0f9f17d commit ffca3ab

File tree

1 file changed

+48
-5
lines changed

1 file changed

+48
-5
lines changed

README.md

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ Track the feature request for target diffing in Bazel [here](https://github.com/
1919

2020
This 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,31 +163,67 @@ 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+
> Note, in releases prior to 2.0.0 the value for the `main_class` attribute is just `BazelDiff`
201+
169202
### Run Via JAR Release
170203

171204
```terminal
172205
curl -LO bazel-diff.jar GITHUB_RELEASE_JAR_URL
173206
java -jar bazel-diff.jar -h
174207
```
175208

209+
### Build from Source
210+
211+
After cloning down the repo, you are good to go, Bazel will handle the rest
212+
213+
To run the project
214+
215+
```terminal
216+
bazel run :bazel-diff -- bazel-diff -h
217+
```
218+
176219
### Build your own deployable JAR
177220

178221
```terminal
179222
bazel build //src/main/java/com/bazel_diff:bazel-diff_deploy.jar
180223
java -jar bazel-bin/src/main/java/com/bazel_diff/bazel-diff_deploy.jar # This JAR can be run anywhere
181224
```
182225

183-
### Integrate directly into your Bazel Project
226+
### Build from sources in your Bazel Project
184227

185228
Add 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:
186229

0 commit comments

Comments
 (0)