Skip to content

Commit 4464332

Browse files
authored
feat(java): add dotprompt implementation (#389)
1 parent f87a1b7 commit 4464332

22 files changed

+3133
-102
lines changed

bazel/java/defs.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def java_spec_test(name, spec_file):
4141
deps = [
4242
"//java/com/google/dotprompt:dotprompt",
4343
"//java/com/google/dotprompt/models",
44+
"//java/com/google/dotprompt/resolvers",
4445
"@maven//:com_fasterxml_jackson_core_jackson_databind",
4546
"@maven//:com_fasterxml_jackson_dataformat_jackson_dataformat_yaml",
4647
"@maven//:com_google_guava_guava",

docs/contributing/coding_guidelines.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ You are an expert Python developer contributing to the Google Dotprompt project.
2323
- **Javadoc**: Write comprehensive Javadoc for all public classes and methods.
2424
- **Doc Sync**: Keep Javadoc comments in sync with the code. When modifying method signatures, parameters, or return types, update the corresponding Javadoc.
2525
- **Method Chaining**: Fluent builder methods should return `this` for chaining.
26+
- Please don't add section marker comments.
2627

2728
## 2. Typing & Style
2829
- **Type Unions**: Use the pipe operator `|` (PEP 604) for union types (e.g., `int | str`) instead of `typing.Union`. Use `| None` for optional types.

java/com/google/dotprompt/BUILD.bazel

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,123 @@
1313
# limitations under the License.
1414
#
1515
# SPDX-License-Identifier: Apache-2.0
16+
17+
load("@rules_java//java:defs.bzl", "java_library", "java_test")
18+
load("@rules_jvm_external//:defs.bzl", "java_export")
19+
load("//bazel/java:defs.bzl", "java_spec_test")
20+
21+
java_library(
22+
name = "dotprompt",
23+
srcs = [
24+
"Dotprompt.java",
25+
"DotpromptOptions.java",
26+
"package-info.java",
27+
],
28+
visibility = ["//visibility:public"],
29+
deps = [
30+
"//java/com/google/dotprompt/helpers",
31+
"//java/com/google/dotprompt/models",
32+
"//java/com/google/dotprompt/parser",
33+
"//java/com/google/dotprompt/resolvers",
34+
"//java/com/google/dotprompt/store",
35+
"@maven//:com_fasterxml_jackson_core_jackson_annotations",
36+
"@maven//:com_fasterxml_jackson_core_jackson_core",
37+
"@maven//:com_fasterxml_jackson_core_jackson_databind",
38+
"@maven//:com_fasterxml_jackson_dataformat_jackson_dataformat_yaml",
39+
"@maven//:com_github_jknack_handlebars",
40+
"@maven//:com_google_guava_guava",
41+
],
42+
)
43+
44+
java_export(
45+
name = "dotprompt_pkg",
46+
# x-release-please-start-version
47+
maven_coordinates = "com.google.dotprompt:dotprompt:0.1.0",
48+
# x-release-please-end
49+
pom_template = "pom_template.xml",
50+
visibility = ["//visibility:public"],
51+
runtime_deps = [":dotprompt"],
52+
)
53+
54+
java_test(
55+
name = "DotpromptTest",
56+
srcs = ["DotpromptTest.java"],
57+
test_class = "com.google.dotprompt.DotpromptTest",
58+
deps = [
59+
":dotprompt",
60+
"//java/com/google/dotprompt/models",
61+
"@maven//:com_github_jknack_handlebars",
62+
"@maven//:com_google_guava_guava",
63+
"@maven//:com_google_truth_truth",
64+
"@maven//:junit_junit",
65+
],
66+
)
67+
68+
java_test(
69+
name = "DotpromptOptionsTest",
70+
srcs = ["DotpromptOptionsTest.java"],
71+
test_class = "com.google.dotprompt.DotpromptOptionsTest",
72+
deps = [
73+
":dotprompt",
74+
"//java/com/google/dotprompt/models",
75+
"@maven//:com_github_jknack_handlebars",
76+
"@maven//:com_google_truth_truth",
77+
"@maven//:junit_junit",
78+
],
79+
)
80+
81+
# Individual spec tests for each YAML file
82+
java_spec_test(
83+
name = "SpecTest_metadata",
84+
spec_file = "//spec:metadata.yaml",
85+
)
86+
87+
java_spec_test(
88+
name = "SpecTest_partials",
89+
spec_file = "//spec:partials.yaml",
90+
)
91+
92+
java_spec_test(
93+
name = "SpecTest_picoschema",
94+
spec_file = "//spec:picoschema.yaml",
95+
)
96+
97+
java_spec_test(
98+
name = "SpecTest_variables",
99+
spec_file = "//spec:variables.yaml",
100+
)
101+
102+
java_spec_test(
103+
name = "SpecTest_history",
104+
spec_file = "//spec:helpers/history.yaml",
105+
)
106+
107+
java_spec_test(
108+
name = "SpecTest_ifEquals",
109+
spec_file = "//spec:helpers/ifEquals.yaml",
110+
)
111+
112+
java_spec_test(
113+
name = "SpecTest_json",
114+
spec_file = "//spec:helpers/json.yaml",
115+
)
116+
117+
java_spec_test(
118+
name = "SpecTest_media",
119+
spec_file = "//spec:helpers/media.yaml",
120+
)
121+
122+
java_spec_test(
123+
name = "SpecTest_role",
124+
spec_file = "//spec:helpers/role.yaml",
125+
)
126+
127+
java_spec_test(
128+
name = "SpecTest_section",
129+
spec_file = "//spec:helpers/section.yaml",
130+
)
131+
132+
java_spec_test(
133+
name = "SpecTest_unlessEquals",
134+
spec_file = "//spec:helpers/unlessEquals.yaml",
135+
)

0 commit comments

Comments
 (0)