Skip to content

Commit

Permalink
Add java formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jordansimsmith committed Jul 12, 2024
1 parent 586221a commit 49cc856
Show file tree
Hide file tree
Showing 6 changed files with 681 additions and 417 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
name: Build

on:
push:
branches:
- master

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v4

- name: Setup bazel
uses: bazelbuild/setup-bazelisk@v3

- name: Mount bazel cache
uses: actions/cache@v4
with:
path: ~/.cache/bazel
key: bazel

- name: Bazel build
run: bazel build //...

- name: Bazel test
run: bazel test //...
run: bazel test //...
21 changes: 21 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")

java_binary(
name = "java-format",
jvm_flags = [
"--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
],
main_class = "com.google.googlejavaformat.java.Main",
runtime_deps = [
"@google_java_format//jar",
],
)

format_multirun(
name = "format",
java = ":java-format",
)
8 changes: 8 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ oci.pull(
tag = "2.5.2",
)
use_repo(oci, "dynamodb", "dynamodb_linux_amd64", "dynamodb_linux_arm64")

bazel_dep(name = "aspect_rules_lint", version = "0.21.0")
http_jar = use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl", "http_jar")
http_jar(
name = "google_java_format",
url = "https://github.com/google/google-java-format/releases/download/v1.17.0/google-java-format-1.17.0-all-deps.jar",
sha256 = "33068bbbdce1099982ec1171f5e202898eb35f2919cf486141e439fc6e3a4203",
)
Loading

0 comments on commit 49cc856

Please sign in to comment.