-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from xingyutangyuan/master
Add bazel integration
- Loading branch information
Showing
13 changed files
with
302 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
|
||
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
|
||
RULES_JVM_EXTERNAL_TAG = "4.3" | ||
RULES_JVM_EXTERNAL_SHA = "6274687f6fc5783b589f56a2f1ed60de3ce1f99bc4e8f9edef3de43bdf7c6e74" | ||
|
||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") | ||
|
||
# Re-usable building blocks for Bazel build tool | ||
# https://gerrit.googlesource.com/bazlets/ | ||
# https://gerrit.googlesource.com/bazlets/+/968b97fa03a9d2afd760f2e8ede3d5643da390d2 | ||
git_repository( | ||
name = "com_googlesource_gerrit_bazlets", | ||
remote = "https://gerrit.googlesource.com/bazlets", | ||
commit = "968b97fa03a9d2afd760f2e8ede3d5643da390d2", | ||
) | ||
# We cannot use the tar.gz provided over HTTP because it contains timestamps and each download has a | ||
# different hash. | ||
#http_archive( | ||
# name = "com_googlesource_gerrit_bazlets", | ||
# sha256 = "...", | ||
# urls = [ | ||
# "https://gerrit.googlesource.com/bazlets/+archive/968b97fa03a9d2afd760f2e8ede3d5643da390d2.tar.gz", | ||
# ], | ||
#) | ||
# This provides these useful imports: | ||
# load("@com_googlesource_gerrit_bazlets//tools:maven_jar.bzl", "maven_jar") | ||
# load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests") | ||
|
||
|
||
http_archive( | ||
name = "rules_jvm_external", | ||
sha256 = RULES_JVM_EXTERNAL_SHA, | ||
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, | ||
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, | ||
) | ||
|
||
load("@rules_jvm_external//:defs.bzl", "maven_install") | ||
|
||
maven_install( | ||
artifacts = [ | ||
"com.google.errorprone:error_prone_annotation:[2.0,)", | ||
"com.google.errorprone:error_prone_core:[2.0,)", | ||
"com.google.errorprone:error_prone_annotations:[2.0,)", | ||
"com.google.errorprone:error_prone_check_api:[2.0,)", | ||
"com.google.errorprone:error_prone_test_helpers:[2.0,)", | ||
"com.google.guava:guava:[20.0,)", | ||
"com.google.guava:guava-testlib:[30.0,)", | ||
"org.mockito:mockito-core:2.27.0", | ||
"com.google.testparameterinjector:test-parameter-injector:[1.8,)", | ||
"junit:junit:4.13.1", | ||
"org.junit.jupiter:junit-jupiter-api:5.0.0-M3", | ||
"com.google.truth:truth:[1.1,)", | ||
"com.google.truth.extensions:truth-java8-extension:[1.1,)", | ||
"org.checkerframework:checker-qual:3.12.0", | ||
"com.google.auto.service:auto-service-annotations:1.1.1", | ||
"com.google.auto.service:auto-service:1.1.1", | ||
"com.google.protobuf:protobuf-java:[3.0.0,)", | ||
"com.google.protobuf:protobuf-java-util:[3.0.0,)", | ||
"com.google.code.findbugs:jsr305:3.0.2", | ||
], | ||
repositories = [ | ||
"https://repo1.maven.org/maven2", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
java_library( | ||
name = "errorprone", | ||
srcs = glob(["src/main/java/**/*.java"]), | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@maven//:com_google_guava_guava", | ||
"@maven//:com_google_errorprone_error_prone_core", | ||
"@maven//:com_google_errorprone_error_prone_annotation", | ||
"@maven//:com_google_errorprone_error_prone_annotations", | ||
"@maven//:com_google_errorprone_error_prone_check_api", | ||
"@maven//:com_google_auto_service_auto_service_annotations", | ||
"//mug:base", | ||
"//mug-guava", | ||
], | ||
) | ||
|
||
java_plugin( | ||
name = "plugin", | ||
processor_class = "com.google.auto.service.processor.AutoServiceProcessor", | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
":errorprone", | ||
"@maven//:com_google_errorprone_error_prone_core", | ||
"@maven//:com_google_auto_service_auto_service", | ||
], | ||
) | ||
|
||
load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests") | ||
|
||
junit_tests( | ||
name = "AllTests", | ||
srcs = glob(["src/test/java/**/*Test.java"]), | ||
deps = [ | ||
":errorprone", | ||
"//mug:format", | ||
"@maven//:com_google_guava_guava", | ||
"@maven//:com_google_guava_guava_testlib", | ||
"@maven//:com_google_truth_truth", | ||
"@maven//:org_mockito_mockito_core", | ||
"@maven//:com_google_testparameterinjector_test_parameter_injector", | ||
"@maven//:org_junit_jupiter_junit_jupiter_api", | ||
"@maven//:com_google_truth_extensions_truth_java8_extension", | ||
"@maven//:com_google_errorprone_error_prone_annotations", | ||
"@maven//:com_google_errorprone_error_prone_test_helpers", | ||
"@maven//:junit_junit", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests") | ||
|
||
|
||
junit_tests( | ||
name = "AllTests", | ||
srcs = glob(["src/test/java/**/*Test.java"]), | ||
deps = [ | ||
"//mug:base", | ||
"//mug:format", | ||
"//mug-guava", | ||
"@maven//:com_google_guava_guava", | ||
"@maven//:com_google_truth_truth", | ||
"@maven//:com_google_truth_extensions_truth_java8_extension", | ||
"@maven//:com_google_errorprone_error_prone_annotations", | ||
"@maven//:junit_junit", | ||
], | ||
) |
2 changes: 1 addition & 1 deletion
2
...amples/HowToCollectToCustomTypesTest.java → ...amples/HowToCollectToCustomTypesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...va/examples/HowToConcatenateMapsTest.java → ...mu/examples/HowToConcatenateMapsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ToCreateTypeSafeCartesianProductTest.java → ...ToCreateTypeSafeCartesianProductTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...examples/HowToDoGroupingFluentlyTest.java → ...examples/HowToDoGroupingFluentlyTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
mug-examples/src/test/java/com/google/mu/examples/HowToUseStringFormatTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.google.mu.examples; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
import com.google.mu.util.StringFormat; | ||
|
||
@RunWith(JUnit4.class) | ||
public class HowToUseStringFormatTest { | ||
|
||
@Test public void testIt() { | ||
} | ||
|
||
private String badUsage() { | ||
return new StringFormat("{key}:{value}").parseOrThrow("k:v", key -> key); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...xamples/HowToZipPairwiseElementsTest.java → ...xamples/HowToZipPairwiseElementsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
java_library( | ||
name = "mug-guava", | ||
srcs = glob(["src/main/java/**/*.java"]), | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@@maven//:com_google_guava_guava", | ||
"@maven//:org_checkerframework_checker_qual", | ||
"@maven//:com_google_errorprone_error_prone_annotations", | ||
"//mug:base", | ||
], | ||
) | ||
|
||
|
||
load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests") | ||
|
||
|
||
junit_tests( | ||
name = "AllTests", | ||
srcs = glob(["src/test/java/**/*Test.java"]), | ||
deps = [ | ||
":mug-guava", | ||
"//mug:base", | ||
"@maven//:com_google_guava_guava", | ||
"@maven//:com_google_guava_guava_testlib", | ||
"@maven//:com_google_truth_truth", | ||
"@maven//:org_mockito_mockito_core", | ||
"@maven//:com_google_testparameterinjector_test_parameter_injector", | ||
"@maven//:org_junit_jupiter_junit_jupiter_api", | ||
"@maven//:com_google_truth_extensions_truth_java8_extension", | ||
"@maven//:com_google_errorprone_error_prone_annotations", | ||
"@maven//:junit_junit", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
java_library( | ||
name = "mug-protobuf", | ||
srcs = glob(["src/main/java/**/*.java"]), | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"@maven//:com_google_guava_guava", | ||
"@maven//:com_google_code_findbugs_jsr305", | ||
"@maven//:com_google_errorprone_error_prone_annotations", | ||
"@maven//:com_google_protobuf_protobuf_java", | ||
"@maven//:com_google_protobuf_protobuf_java_util", | ||
"//mug:base", | ||
], | ||
) | ||
|
||
load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests") | ||
|
||
|
||
junit_tests( | ||
name = "AllTests", | ||
srcs = glob(["src/test/java/**/*Test.java"]), | ||
deps = [ | ||
":mug-protobuf", | ||
"//mug:base", | ||
"//mug-guava", | ||
"@maven//:com_google_guava_guava", | ||
"@maven//:com_google_guava_guava_testlib", | ||
"@maven//:com_google_protobuf_protobuf_java", | ||
"@maven//:com_google_protobuf_protobuf_java_util", | ||
"@@maven//:com_google_truth_truth", | ||
"@@maven//:org_mockito_mockito_core", | ||
"@maven//:com_google_testparameterinjector_test_parameter_injector", | ||
"@maven//:org_junit_jupiter_junit_jupiter_api", | ||
"@maven//:com_google_truth_extensions_truth_java8_extension", | ||
"@maven//:com_google_errorprone_error_prone_annotations", | ||
"@maven//:junit_junit", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
java_library( | ||
name = "base", | ||
visibility = ["//visibility:public"], | ||
srcs = glob([ | ||
"src/main/java/com/google/mu/util/*.java", | ||
"src/main/java/com/google/mu/util/stream/*.java", | ||
"src/main/java/com/google/mu/function/*.java", | ||
], | ||
exclude = ["src/main/java/com/google/mu/util/StringFormat.java"]), | ||
) | ||
|
||
java_library( | ||
name = "graph", | ||
visibility = ["//visibility:public"], | ||
srcs = glob([ "src/main/java/com/google/mu/util/graph/*.java"]), | ||
deps = [":base"] | ||
) | ||
|
||
java_library( | ||
name = "concurrent", | ||
visibility = ["//visibility:public"], | ||
srcs = glob([ "src/main/java/com/google/mu/util/concurrent/*.java"]), | ||
deps = [":base"] | ||
) | ||
|
||
java_library( | ||
name = "format", | ||
visibility = ["//visibility:public"], | ||
srcs = ["src/main/java/com/google/mu/util/StringFormat.java"], | ||
deps = [":base"], | ||
exported_plugins = ["//mug-errorprone:plugin"], | ||
) | ||
|
||
load("@com_googlesource_gerrit_bazlets//tools:junit.bzl", "junit_tests") | ||
|
||
java_library( | ||
name = "tests", | ||
srcs = glob(["src/test/java/**/*.java"], exclude = glob(["src/test/java/**/*Test.java"])), | ||
deps = [ | ||
":base", | ||
":concurrent", | ||
"@maven//:com_google_guava_guava", | ||
"@maven//:com_google_guava_guava_testlib", | ||
"@maven//:com_google_truth_truth", | ||
"@maven//:org_mockito_mockito_core", | ||
"@maven//:com_google_testparameterinjector_test_parameter_injector", | ||
"@maven//:org_junit_jupiter_junit_jupiter_api", | ||
"@maven//:com_google_truth_extensions_truth_java8_extension", | ||
"@maven//:com_google_errorprone_error_prone_annotations", | ||
"@maven//:junit_junit", | ||
], | ||
) | ||
|
||
|
||
junit_tests( | ||
name = "AllTests", | ||
srcs = glob(["src/test/java/**/*Test.java"]), | ||
deps = [ | ||
":base", | ||
":concurrent", | ||
":format", | ||
":graph", | ||
":tests", | ||
"@maven//:com_google_guava_guava", | ||
"@maven//:com_google_guava_guava_testlib", | ||
"@maven//:com_google_truth_truth", | ||
"@maven//:org_mockito_mockito_core", | ||
"@maven//:com_google_testparameterinjector_test_parameter_injector", | ||
"@maven//:org_junit_jupiter_junit_jupiter_api", | ||
"@maven//:com_google_truth_extensions_truth_java8_extension", | ||
"@maven//:com_google_errorprone_error_prone_annotations", | ||
"@maven//:junit_junit", | ||
], | ||
) |