Skip to content

Commit cd592a8

Browse files
Merge pull request #31 from alexeagle/master
README: give shorter install instruction with http_jar
2 parents 3fec4c9 + 9f2f1a2 commit cd592a8

File tree

1 file changed

+49
-5
lines changed

1 file changed

+49
-5
lines changed

README.md

Lines changed: 49 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,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

171205
To 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
181215
java -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
187231
bazel build //src/main/java/com/bazel_diff:bazel-diff_deploy.jar
188232
java -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

193237
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:
194238

0 commit comments

Comments
 (0)