3 date: 2019-06-16T18:23:45+02:00
13 [bazel](https://bazel.build/) users can use the [yosql-tooling-cli](../cli/) in their builds by following these steps:
15 1. Download the `yosql-tooling-cli` zip file from the [latest release](https://github.com/metio/yosql/releases/latest) (or any prior version).
16 2. Use a [java_import](https://bazel.build/reference/be/java#java_import) rule to capture all `.jar` files used by `yosql-tooling-cli`
20 name = "yosql_tooling_cli",
22 "lib/yosql-tooling-cli-x.y.z.jar",
23 "lib/yosql-codegen-x.y.z.jar",
24 "lib/yosql-models-immutables-x.y.z.jar",
25 ... every other jar file from the 'lib' folder
30 3. Use a [java_binary](https://bazel.build/reference/be/java#java_binary) rule to create a runnable binary for bazel
38 main_class = "wtf.metio.yosql.tooling.cli.YoSQL",
42 4. Write .sql files in a directory of your choice (e.g. `persistence`)
54 └── createItemTable.sql
57 5. Declare a [filegroup](https://bazel.build/reference/be/general#filegroup) that contains all of your SQL files:
61 name = "your-sql-files",
62 srcs = glob(["persistence/**/*.sql"]),
66 6. Generate Java code by calling the previously defined `java_binary`:
70 name = "your-repositories",
71 srcs = [":your-sql-files"],
73 "com/example/persistence/UserRepository.java",
74 "com/example/persistence/ItemRepository.java",
75 ... all of your generated code
78 $(location :yosql) generate
84 7. Depend on the generated sources by using the target name of the generated code in the `srcs` of another rule.