forked from bazelbuild/codelabs
-
Notifications
You must be signed in to change notification settings - Fork 7
/
generate_build_files.sh
executable file
·85 lines (68 loc) · 1.84 KB
/
generate_build_files.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# This file is used for Bazel CI to write the BUILD files for the project.
# You can use it to see the final solutions but note that it will delete your existing
# BUILD files if you started working.
# generate java BUILD file
cat > java/src/main/java/bazel/bootcamp/BUILD <<EOF
java_binary(
name = "HelloBazelBootcamp",
srcs = ["HelloBazelBootcamp.java"],
)
java_library(
name = "JavaLoggingClientLibrary",
srcs = ["JavaLoggingClientLibrary.java"],
deps = [
"//proto/logger:logger_java_proto",
"//proto/logger:logger_java_grpc",
"@io_grpc_grpc_java//core",
"@io_grpc_grpc_java//netty",
]
)
java_binary(
name = "JavaLoggingClient",
srcs = ["JavaLoggingClient.java"],
deps = [":JavaLoggingClientLibrary"],
visibility = ["//visibility:public"]
)
java_test(
name = "JavaLoggingClientLibraryTest",
srcs = ["JavaLoggingClientLibraryTest.java"],
deps = [":JavaLoggingClientLibrary"]
)
java_test(
name = "JavaLoggingClientTest",
srcs = ["JavaLoggingClientTest.java"],
deps = [":JavaLoggingClient"]
)
EOF
# generate proto BUILD file
cat > proto/logger/BUILD <<EOF
package(default_visibility = ["//visibility:public"])
load("@io_grpc_grpc_java//:java_grpc_library.bzl", "java_grpc_library")
proto_library(
name = "logger_proto",
srcs = ["logger.proto"]
)
java_proto_library(
name = "logger_java_proto",
deps = [":logger_proto"]
)
java_grpc_library(
name = "logger_java_grpc",
srcs = [":logger_proto"],
deps = [":logger_java_proto"],
)
EOF
# write shell test
cat > tests/BUILD <<EOF
sh_test(
name = "integration_test",
srcs = ["integrationtest.sh"],
data = [
"//go/cmd/server",
"//java/src/main/java/bazel/bootcamp:JavaLoggingClient",
],
)
EOF
# write WORKSPACE file
${SHELL} ./generate_workspace.sh
bazel run //:gazelle