3 date: 2019-06-16T18:23:45+02:00
13 [bazel](https://bazel.build/) users can use the `yosql-cli` in their builds by following the steps. Replace placeholders with values from the actual release notes.
15 1. Add git repository to your `WORKSPACE`:
20 remote = "https://github.com/metio/yosql.git",
25 2. Write .sql files in a directory of your choice (e.g. `persistence`)
37 └── createItemTable.sql
40 3. Declare a `filegroup` that contains all of your SQL files:
44 name = "your-sql-files",
45 srcs = glob(["persistence/**/*.sql"]),
49 4. Generate utilities first since they dont change that often:
53 name = "your-utilities",
54 srcs = [":your-sql-files"],
56 "com/example/persistence/util/ResultRow.java",
57 "com/example/persistence/util/ResultState.java",
58 "com/example/persistence/util/FlowState.java",
61 $(location @yosql//yosql-cli) generate utilities
63 tools = ["@yosql//yosql-cli"],
67 5. Generate converters next, in order to connect user code to repositories
72 name = "your-converters",
73 srcs = [":your-sql-files"],
75 "com/example/persistence/converter/ToResultRowConverter.java",
78 $(location @yosql//yosql-cli) generate converters
80 tools = ["@yosql//yosql-cli"],
85 6. Generate repositories last, since they'll change everytime a SQL file changes as well:
89 name = "your-repositories",
90 srcs = [":your-sql-files"],
92 "com/example/persistence/UserRepository.java",
93 "com/example/persistence/ItemRepository.java",
96 $(location @yosql//yosql-cli) generate repositories
98 tools = ["@yosql//yosql-cli"],
102 8. Depend on the generated sources by using the target name of the generated code in the `srcs` of another rule.