Skip to content

Commit

Permalink
Bazel Build Scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
g-sg-v authored and nvamelichev committed Mar 11, 2024
1 parent db758ff commit 060b9a9
Show file tree
Hide file tree
Showing 26 changed files with 485 additions and 14 deletions.
23 changes: 23 additions & 0 deletions .bazelproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
workspace_type: java

java_language_level: 21

directories:
.
-databind/pom.xml
-repository/pom.xml
-json-jackson-v2/pom.xml
-repository-inmemory/pom.xml
-repository-test/pom.xml
-repository-ydb-common/pom.xml
-repository-ydb-v1/pom.xml
-repository-ydb-v2/pom.xml
-util/pom.xml

test_sources:
databind/src/test
repository/src/test
repository-inmemory/src/test
repository-ydb-v1/src/test
repository-ydb-v2/src/test
util/src/test
14 changes: 14 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
common --enable_bzlmod

# java common flags
common --java_language_version=21
common --java_runtime_version=remotejdk_21
common --tool_java_language_version=21
common --tool_java_runtime_version=remotejdk_21

# java build flags
build --nojava_header_compilation
#build --strict_java_deps error

# Don't depend on a JAVA_HOME pointing at a system JDK, see https://github.com/bazelbuild/rules_jvm_external/issues/445
build --repo_env=JAVA_HOME=../bazel_tools/jdk
10 changes: 10 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
###############################################################################
# Bazel now uses Bzlmod by default to manage external dependencies.
# Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel.
#
# For more details, please check https://github.com/bazelbuild/bazel/issues/18958
###############################################################################
bazel_dep(name = "rules_java", version = "7.4.0")
bazel_dep(name = "contrib_rules_jvm", version = "0.24.0")
bazel_dep(name = "rules_jvm_external", version = "6.0")
bazel_dep(name = "apple_rules_lint", version = "0.3.2")
96 changes: 96 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
load("@rules_jvm_external//:defs.bzl", "maven_install")
load("@rules_jvm_external//:specs.bzl", "maven")

ANNOTATION_API_VERSION = "1.3.2"

ASSERTJ_VERSION = "3.25.1"

COMMONS_TEXT_VERSION = "1.10.0"

ECLIPSE_COLLECTIONS_VERSION = "9.2.0"

FIND_BUGS_VERSION = "3.0.2"

GRPC_VERSION = "1.61.0"

GUAVA_VERSION = "33.0.0-jre"

JACKSON_VERSION = "2.16.1"

JUNIT_JUPITER_VERSION = "5.10.1"

JUNIT_VERSION = "4.13.2"

KOTLIN_VERSION = "1.9.22"

LOG4J_VERSION = "2.22.1"

LOMBOK_VERSION = "1.18.30"

MOCKITO_VERSION = "5.9.0"

PROMETHEUS_VERSION = "1.1.0"

SIMPLECLIENT_VERSION = "0.9.0"

SLF4J_VERSION = "2.0.11"

SNAKEYAML_VERSION = "1.33"

YDB_PROTOAPI_VERSION = "1.6.0"

YDB_SDK_V1_VERSION = "1.14.14"

YDB_SDK_VERSION = "2.1.12"

maven_install(
name = "java_contribs_stable",
artifacts = [
"com.fasterxml.jackson.core:jackson-databind:" + JACKSON_VERSION,
"com.fasterxml.jackson.datatype:jackson-datatype-jdk8:" + JACKSON_VERSION,
"com.fasterxml.jackson.datatype:jackson-datatype-jsr310:" + JACKSON_VERSION,
"com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:" + JACKSON_VERSION,
"com.google.code.findbugs:jsr305:" + FIND_BUGS_VERSION,
"com.google.guava:guava:" + GUAVA_VERSION,
"com.yandex.ydb:ydb-sdk-core:" + YDB_SDK_V1_VERSION,
"com.yandex.ydb:ydb-sdk-proto:" + YDB_SDK_V1_VERSION,
"com.yandex.ydb:ydb-sdk-table:" + YDB_SDK_V1_VERSION,
"io.grpc:grpc-bom:" + GRPC_VERSION,
"io.grpc:grpc-netty-shaded:" + GRPC_VERSION,
"io.grpc:grpc-netty:" + GRPC_VERSION,
"io.prometheus:simpleclient:" + SIMPLECLIENT_VERSION,
"javax.annotation:javax.annotation-api:" + ANNOTATION_API_VERSION,
"junit:junit:" + JUNIT_VERSION,
"org.apache.commons:commons-text:" + COMMONS_TEXT_VERSION,
"org.yaml:snakeyaml:" + SNAKEYAML_VERSION,
"org.apache.logging.log4j:log4j-api:" + LOG4J_VERSION,
"org.apache.logging.log4j:log4j-slf4j2-impl:" + LOG4J_VERSION,
"org.assertj:assertj-core:" + ASSERTJ_VERSION,
"org.eclipse.collections:eclipse-collections-api:" + ECLIPSE_COLLECTIONS_VERSION,
"org.eclipse.collections:eclipse-collections:" + ECLIPSE_COLLECTIONS_VERSION,
"org.jetbrains.kotlin:kotlin-reflect:" + KOTLIN_VERSION,
"org.mockito:mockito-core:" + MOCKITO_VERSION,
"org.projectlombok:lombok:" + LOMBOK_VERSION,
"org.slf4j:slf4j-api:" + SLF4J_VERSION,
"tech.ydb:ydb-proto-api:" + YDB_PROTOAPI_VERSION,
"tech.ydb:ydb-sdk-bom:" + YDB_SDK_VERSION,
"tech.ydb:ydb-sdk-topic:" + YDB_SDK_VERSION,
"tech.ydb:ydb-sdk-core:" + YDB_SDK_VERSION,
"tech.ydb:ydb-sdk-table:" + YDB_SDK_VERSION,
"tech.ydb:ydb-sdk-scheme:" + YDB_SDK_VERSION,
"tech.ydb.test:ydb-junit4-support:" + YDB_SDK_VERSION,
maven.artifact(
artifact = "grpc-core",
exclusions = [
"io.grpc:grpc-util",
],
group = "io.grpc",
version = GRPC_VERSION,
),
],
fetch_sources = True,
generate_compat_repositories = True,
repositories = [
"https://repo1.maven.org/maven2",
],
)
20 changes: 20 additions & 0 deletions bom/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("@contrib_rules_jvm//java:defs.bzl", "java_library")

java_plugin(
name = "lombok_plugin",
generates_api = True,
processor_class = "lombok.launch.AnnotationProcessorHider$AnnotationProcessor",
deps = ["@java_contribs_stable//:org_projectlombok_lombok"],
)

java_library(
name = "lombok",
data = ["lombok.config"],
exported_plugins = [":lombok_plugin"],
neverlink = True,
visibility = ["//visibility:public"],
exports = [
"@java_contribs_stable//:org_projectlombok_lombok",
"@java_contribs_stable//:org_slf4j_slf4j_api",
],
)
31 changes: 31 additions & 0 deletions databind/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@contrib_rules_jvm//java:defs.bzl", "java_library", "java_test_suite")

java_library(
name = "databind",
srcs = glob(["src/main/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//bom:lombok",
"@java_contribs_stable//:com_google_code_findbugs_jsr305",
"@java_contribs_stable//:com_google_guava_guava",
"@java_contribs_stable//:javax_annotation_javax_annotation_api",
"@java_contribs_stable//:org_jetbrains_annotations",
"@java_contribs_stable//:org_jetbrains_kotlin_kotlin_reflect",
"@java_contribs_stable//:org_jetbrains_kotlin_kotlin_stdlib",
"@java_contribs_stable//:org_slf4j_slf4j_api",
],
)

java_test_suite(
name = "databind-tests",
srcs = glob(["src/test/java/**/*.java"]),
package_prefixes = [".tech"],
resources = glob(["src/test/resources/**"]),
runner = "junit4",
deps = [
":databind",
"//bom:lombok",
"@java_contribs_stable//:javax_annotation_javax_annotation_api",
"@java_contribs_stable//:org_assertj_assertj_core",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.junit.Test;
import tech.ydb.yoj.databind.schema.Schema;

public class AnnotationFirstNamingStrategyTest extends BaseNamingStrategyTest {
public class AnnotationFirstNamingStrategyTest extends BaseNamingStrategyTestBase {
@Test
public void testEntityTableName() {
verifyTableName(TestEntity.class, "TestEntity");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public abstract class BaseNamingStrategyTest {
public abstract class BaseNamingStrategyTestBase {
protected abstract <T> Schema<T> getSchema(Class<T> entityType);

protected <T> void verifyTableName(Class<T> entityType, String tableName) {
Expand Down
18 changes: 18 additions & 0 deletions json-jackson-v2/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@contrib_rules_jvm//java:defs.bzl", "java_library", "java_test_suite")

java_library(
name = "json-jackson-v2",
srcs = glob(["src/main/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//bom:lombok",
"//repository",
"@java_contribs_stable//:com_fasterxml_jackson_core_jackson_annotations",
"@java_contribs_stable//:com_fasterxml_jackson_core_jackson_databind",
"@java_contribs_stable//:com_fasterxml_jackson_datatype_jackson_datatype_jdk8",
"@java_contribs_stable//:com_fasterxml_jackson_datatype_jackson_datatype_jsr310",
"@java_contribs_stable//:com_google_code_findbugs_jsr305",
"@java_contribs_stable//:com_google_guava_guava",
"@java_contribs_stable//:javax_annotation_javax_annotation_api",
],
)
33 changes: 33 additions & 0 deletions repository-inmemory/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
load("@contrib_rules_jvm//java:defs.bzl", "java_library", "java_test_suite")

java_library(
name = "repository-inmemory",
srcs = glob(["src/main/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//bom:lombok",
"//databind",
"//repository",
"//util",
"@java_contribs_stable//:com_google_code_findbugs_jsr305",
"@java_contribs_stable//:com_google_guava_guava",
"@java_contribs_stable//:javax_annotation_javax_annotation_api",
"@java_contribs_stable//:org_eclipse_collections_eclipse_collections",
"@java_contribs_stable//:org_eclipse_collections_eclipse_collections_api",
],
)

java_test_suite(
name = "repository-inmemory-tests",
srcs = glob(["src/test/java/**/*.java"]),
package_prefixes = [".tech"],
resources = glob(["src/test/resources/**"]),
runner = "junit4",
deps = [
"repository-inmemory",
"//bom:lombok",
"//json-jackson-v2",
"//repository",
"//repository-test",
],
)
22 changes: 22 additions & 0 deletions repository-test/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
load("@contrib_rules_jvm//java:defs.bzl", "java_library", "java_test_suite")

java_library(
name = "repository-test",
srcs = glob(["src/main/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//bom:lombok",
"//databind",
"//repository",
"//util",
"@java_contribs_stable//:com_fasterxml_jackson_core_jackson_annotations",
"@java_contribs_stable//:com_fasterxml_jackson_core_jackson_core",
"@java_contribs_stable//:com_fasterxml_jackson_core_jackson_databind",
"@java_contribs_stable//:com_fasterxml_jackson_datatype_jackson_datatype_jdk8",
"@java_contribs_stable//:com_fasterxml_jackson_datatype_jackson_datatype_jsr310",
"@java_contribs_stable//:com_google_guava_guava",
"@java_contribs_stable//:javax_annotation_javax_annotation_api",
"@java_contribs_stable//:junit_junit",
"@java_contribs_stable//:org_assertj_assertj_core",
],
)
14 changes: 14 additions & 0 deletions repository-ydb-common/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@contrib_rules_jvm//java:defs.bzl", "java_library", "java_test_suite")

java_library(
name = "repository-ydb-common",
srcs = glob(["src/main/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//bom:lombok",
"//databind",
"//repository",
"//util",
"@java_contribs_stable//:io_prometheus_simpleclient",
],
)
57 changes: 57 additions & 0 deletions repository-ydb-v1/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
load("@contrib_rules_jvm//java:defs.bzl", "java_library", "java_test_suite")

java_library(
name = "repository-ydb-v1",
srcs = glob(["src/main/**/*.java"]),
visibility = ["//visibility:public"],
deps = [
"//bom:lombok",
"//databind",
"//repository",
"//repository-ydb-common",
"//util",
"@java_contribs_stable//:com_google_code_findbugs_jsr305",
"@java_contribs_stable//:com_google_guava_guava",
"@java_contribs_stable//:com_google_protobuf_protobuf_java",
"@java_contribs_stable//:com_yandex_ydb_ydb_sdk_core",
"@java_contribs_stable//:com_yandex_ydb_ydb_sdk_proto",
"@java_contribs_stable//:com_yandex_ydb_ydb_sdk_table",
"@java_contribs_stable//:io_grpc_grpc_api",
"@java_contribs_stable//:io_grpc_grpc_netty",
"@java_contribs_stable//:javax_annotation_javax_annotation_api",
"@java_contribs_stable//:org_apache_commons_commons_text",
],
)

java_test_suite(
name = "repository-ydb-v1-tests",
srcs = glob(["src/test/java/**/*.java"]),
package_prefixes = [".tech"],
resources = glob(["src/test/resources/**"]),
runner = "junit4",
test_suffixes_excludes = ["IntegrationTest.java"],
deps = [
"repository-ydb-v1",
"//bom:lombok",
"//databind",
"//json-jackson-v2",
"//repository",
"//repository-test",
"//repository-ydb-common",
"@java_contribs_stable//:com_fasterxml_jackson_core_jackson_core",
"@java_contribs_stable//:com_fasterxml_jackson_core_jackson_databind",
"@java_contribs_stable//:com_google_guava_guava",
"@java_contribs_stable//:com_google_protobuf_protobuf_java",
"@java_contribs_stable//:com_yandex_ydb_ydb_sdk_core",
"@java_contribs_stable//:com_yandex_ydb_ydb_sdk_proto",
"@java_contribs_stable//:com_yandex_ydb_ydb_sdk_table",
"@java_contribs_stable//:io_grpc_grpc_api",
"@java_contribs_stable//:io_grpc_grpc_netty",
"@java_contribs_stable//:io_grpc_grpc_stub",
"@java_contribs_stable//:io_netty_netty_handler",
"@java_contribs_stable//:javax_annotation_javax_annotation_api",
"@java_contribs_stable//:junit_junit",
"@java_contribs_stable//:org_assertj_assertj_core",
"@java_contribs_stable//:org_mockito_mockito_core",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import tech.ydb.yoj.repository.ydb.YdbRepository;
import tech.ydb.yoj.repository.ydb.YdbRepositoryTransaction;

public abstract class AbstractMultipleVarsYqlStatementTest extends RepositoryTestSupport {
public abstract class AbstractMultipleVarsYqlStatementTestBase extends RepositoryTestSupport {

protected static final TestEntity ENTITY_1 = new TestEntity(TestEntity.Id.of("a"), "foo");
protected static final TestEntity ENTITY_1_1 = new TestEntity(TestEntity.Id.of("a"), "fuu");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class DeleteByIdStatementIntegrationTest extends AbstractMultipleVarsYqlStatementTest {
public class DeleteByIdStatementIntegrationTest extends AbstractMultipleVarsYqlStatementTestBase {

@Test
public void testDelete() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import static org.assertj.core.api.Assertions.assertThat;

public class InsertYqlStatementIntegrationTest extends AbstractMultipleVarsYqlStatementTest {
public class InsertYqlStatementIntegrationTest extends AbstractMultipleVarsYqlStatementTestBase {

@Test
public void testInsert() {
Expand Down
Loading

0 comments on commit 060b9a9

Please sign in to comment.