Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel builds enabled along with sbt #893

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .bazeliskrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
USE_BAZEL_VERSION=6.4.0
16 changes: 16 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Disable remote cache completely when --config=local is passed
build:local --remote_cache=

# Scala version config flags:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wdyt about moving this to devnotes?

# To build with Scala 2.12, pass "--config scala_2.12" to "bazel build"
# To set a different default Scala version, add the following to
# user.bazelrc:
# common --config scala_2.12
common:scala_2.12 --repo_env=SCALA_VERSION=2.12.18
common:scala_2.13 --repo_env=SCALA_VERSION=2.13.12
# Default scala version to 2.12
common --repo_env=SCALA_VERSION=2.12.18
# Default to Spark 3.2 if no value is specified
build --define=spark_version=3.2

build --javacopt=-Xep:DoubleBraceInitialization:OFF
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ mvn_settings.xml
# Release folder
releases

# bazel
/bazel-*
/user.bazelrc
16 changes: 16 additions & 0 deletions .ijwb/.bazelproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
directories:
# Add the directories you want added as source here
# By default, we've added your entire workspace ('.')
.

# Automatically includes all relevant targets under the 'directories' above
derive_targets_from_directories: true

targets:
# If source code isn't resolving, add additional targets that compile it here

additional_languages:
# Uncomment any additional languages you want supported
python
scala
java
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ Daniel Kristjansson (Stripe)
Piyush Narang (Stripe)
Caio Camatta (Stripe)
Divya Manohar (Stripe)
Krish Narukulla (Roku)
90 changes: 90 additions & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
workspace(name = "chronon")

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# Remove all the remote_java_tools above when upgrading to rules_java 7.5.0 or greater
http_archive(
name = "rules_java",
sha256 = "e81e9deaae0d9d99ef3dd5f6c1b32338447fe16d5564155531ea4eb7ef38854b",
urls = [
"https://github.com/bazelbuild/rules_java/releases/download/7.0.6/rules_java-7.0.6.tar.gz",
],
)

load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")

rules_java_dependencies()

rules_java_toolchains()

load("@rules_java//java:repositories.bzl", "remote_jdk8_repos")

remote_jdk8_repos()

#############################
# Protobuf #
#############################
http_archive(
name = "rules_proto",
krisnaru marked this conversation as resolved.
Show resolved Hide resolved
sha256 = "dc3fb206a2cb3441b485eb1e423165b231235a1ea9b031b4433cf7bc1fa460dd",
strip_prefix = "rules_proto-5.3.0-21.7",
urls = [
"https://github.com/bazelbuild/rules_proto/archive/refs/tags/5.3.0-21.7.tar.gz",
],
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

# Scala support
http_archive(
name = "io_bazel_rules_scala",
sha256 = "e734eef95cf26c0171566bdc24d83bd82bdaf8ca7873bec6ce9b0d524bdaf05d",
strip_prefix = "rules_scala-6.6.0",
url = "https://github.com/bazelbuild/rules_scala/releases/download/v6.6.0/rules_scala-v6.6.0.tar.gz",
)

# Maven rules
RULES_JVM_EXTERNAL_TAG = "4.5"

RULES_JVM_EXTERNAL_SHA = "b17d7388feb9bfa7f2fa09031b32707df529f26c91ab9e5d909eb1676badd9a6"

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//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

load("@io_bazel_rules_scala//:scala_config.bzl", "scala_config")

scala_config(scala_version = "2.12.12")

load("@io_bazel_rules_scala//scala:scala.bzl", "scala_repositories")

scala_repositories()

load("@io_bazel_rules_scala//scala:toolchains.bzl", "scala_register_toolchains")

scala_register_toolchains()

load("@io_bazel_rules_scala//testing:scalatest.bzl", "scalatest_repositories", "scalatest_toolchain")

scalatest_repositories()

scalatest_toolchain()

load("//jvm:mirrors.bzl", "load_deps")

load_deps()
87 changes: 87 additions & 0 deletions aggregator/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
load("@io_bazel_rules_scala//scala:scala_cross_version_select.bzl", "select_for_scala_version")

scala_library(
name = "aggregator",
srcs = glob(["src/main/scala/ai/chronon/aggregator/**/*.scala"]),
visibility = ["//visibility:public"],
deps = [
"//api:api-lib",
"//api:api-models",
maven_artifact("com.fasterxml.jackson.core:jackson-core"),
maven_artifact("com.fasterxml.jackson.core:jackson-databind"),
maven_artifact("com.google.code.gson:gson"),
maven_artifact("com.yahoo.datasketches:sketches-core"),
maven_artifact("com.yahoo.datasketches:memory"),
maven_artifact("org.apache.commons:commons-lang3"),
maven_artifact("org.apache.thrift:libthrift"),
maven_artifact("org.slf4j:slf4j-api"),
maven_artifact("org.slf4j:slf4j-log4j12"),
] + select_for_scala_version(
before_2_13 = [
scala_artifact("org.scala-lang.modules:scala-collection-compat"),
scala_artifact("com.fasterxml.jackson.module:jackson-module-scala"),
],
since_2_13 = [
scala_artifact("org.scala-lang.modules:scala-parallel-collections"),
],
),
)

scala_library(
name = "test-lib",
srcs = glob(["src/test/scala/ai/chronon/aggregator/test/*.scala"]),
visibility = ["//visibility:public"],
deps = [
":aggregator",
"//api:api-lib",
"//api:api-models",
maven_artifact("junit:junit"),
maven_artifact("com.novocode:junit-interface"),
maven_artifact("org.slf4j:slf4j-api"),
maven_artifact("org.slf4j:slf4j-log4j12"),
maven_artifact("com.google.code.gson:gson"),
maven_artifact("org.apache.thrift:libthrift"),
maven_artifact("org.apache.commons:commons-lang3"),
maven_artifact("org.apache.commons:commons-math3"),
maven_artifact("com.yahoo.datasketches:sketches-core"),
maven_artifact("com.yahoo.datasketches:memory"),
] + select_for_scala_version(
before_2_12 = [],
) + select_for_scala_version(before_2_13 = [
maven_artifact("org.scala-lang.modules:scala-collection-compat_2.12"),
maven_artifact("com.fasterxml.jackson.module:jackson-module-scala_2.12"),
]) +
select_for_scala_version(after_2_12 = [
maven_artifact("org.scala-lang.modules:scala-parallel-collections_2.13"),
]),
)

scala_test_suite(
name = "test",
srcs = glob(["src/test/scala/ai/chronon/aggregator/test/*.scala"]),
visibility = ["//visibility:public"],
deps = [
":aggregator",
":test-lib",
"//api:api-lib",
"//api:api-models",
maven_artifact("junit:junit"),
maven_artifact("com.novocode:junit-interface"),
maven_artifact("org.slf4j:slf4j-api"),
maven_artifact("org.slf4j:slf4j-log4j12"),
maven_artifact("org.apache.thrift:libthrift"),
maven_artifact("com.yahoo.datasketches:sketches-core"),
maven_artifact("com.google.code.gson:gson"),
maven_artifact("com.yahoo.datasketches:memory"),
maven_artifact("org.apache.commons:commons-lang3"),
maven_artifact("org.apache.commons:commons-math3"),
] + select_for_scala_version(
before_2_12 = [],
) + select_for_scala_version(before_2_13 = [
maven_artifact("org.scala-lang.modules:scala-collection-compat_2.12"),
maven_artifact("com.fasterxml.jackson.module:jackson-module-scala_2.12"),
]) +
select_for_scala_version(after_2_12 = [
maven_artifact("org.scala-lang.modules:scala-parallel-collections_2.13"),
]),
)
74 changes: 74 additions & 0 deletions api/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
load("@io_bazel_rules_scala//scala:scala_cross_version_select.bzl", "select_for_scala_version")
load("//tools/build_rules/thrift:thrift.bzl", "thrift_java_library")

scala_library(
name = "api-lib",
srcs = glob(["src/main/scala/ai/chronon/api/*.scala"]) +
select_for_scala_version(
between_2_12_and_2_13 = [
"//api/src/main/scala-2.12/scala/util:ScalaVersionSpecificCollectionsConverter.scala",
],
since_2_13 = [
"//api/src/main/scala-2.13/scala/util:ScalaVersionSpecificCollectionsConverter.scala",
],
),
visibility = ["//visibility:public"],
deps = [
":api-models",
"//third_party/java/spark:spark-exec",
maven_artifact("com.fasterxml.jackson.core:jackson-core"),
maven_artifact("com.fasterxml.jackson.core:jackson-databind"),
maven_artifact("org.apache.thrift:libthrift"),
maven_artifact("org.slf4j:slf4j-api"),
maven_artifact("org.slf4j:slf4j-log4j12"),
] + select_for_scala_version(
before_2_13 = [
scala_artifact("org.scala-lang.modules:scala-collection-compat"),
],
since_2_13 = [
scala_artifact("org.scala-lang.modules:scala-parallel-collections"),
],
),
)

scala_test_suite(
name = "test",
srcs = glob(["src/test/scala/ai/chronon/api/test/*.scala"]),
visibility = ["//visibility:public"],
deps = [
":api-models",
":api-lib",
"//third_party/java/spark:spark-exec",
maven_artifact("com.fasterxml.jackson.core:jackson-core"),
maven_artifact("com.fasterxml.jackson.core:jackson-databind"),
maven_artifact("org.apache.thrift:libthrift"),
maven_artifact("org.slf4j:slf4j-api"),
maven_artifact("org.slf4j:slf4j-log4j12"),
maven_artifact("junit:junit"),
maven_artifact("com.novocode:junit-interface"),
scala_artifact("org.scalatestplus:mockito-3-4"),
maven_artifact("org.mockito:mockito-core"),
scala_artifact(
"org.scala-lang.modules:scala-collection-compat",
),
] + select_for_scala_version(
since_2_13 = [
maven_artifact("org.scala-lang.modules:scala-parallel-collections_2.13"),
],
),
)

thrift_java_library(
name = "api-models-java",
srcs = ["thrift/api.thrift"],
)

java_library(
name = "api-models",
srcs = [":api-models-java"],
visibility = ["//visibility:public"],
deps = [
maven_artifact("javax.annotation:javax.annotation.api"),
maven_artifact("org.apache.thrift:libthrift"),
],
)
5 changes: 5 additions & 0 deletions api/py/ai/chronon/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
py_library(
name = "chronon_lib",
srcs = glob(["*.py"]),
srcs_version = "PY3",
)
5 changes: 5 additions & 0 deletions api/src/main/scala-2.12/scala/util/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exports_files(
[
"ScalaVersionSpecificCollectionsConverter.scala",
],
)
5 changes: 5 additions & 0 deletions api/src/main/scala-2.13/scala/util/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exports_files(
[
"ScalaVersionSpecificCollectionsConverter.scala",
],
)
Loading