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

vaticle and bazel #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .ijwb/.bazelproject
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
directories:
.

derive_targets_from_directories: false
22 changes: 16 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,20 @@ http_archive(
url = "https://github.com/bazelbuild/bazel-skylib/releases/download/{}/bazel-skylib.{}.tar.gz".format(skylib_version, skylib_version),
)

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

google_protobuf()

load("@mavenpublish//central-sync:dependencies.bzl", "rules_jvm_external", "vaticle_bazel_distribution")

RULES_JVM_EXTERNAL_TAG = "2.5"
rules_jvm_external()

RULES_JVM_EXTERNAL_SHA = "249e8129914be6d987ca57754516be35a14ea866c616041ff0cd32ea94d2f3a1"
vaticle_bazel_distribution()
load("@vaticle_bazel_distribution//maven:deps.bzl", "maven_artifacts_with_versions")

RULES_JVM_EXTERNAL_TAG = "3.1"

RULES_JVM_EXTERNAL_SHA = "e246373de2353f3d34d35814947aa8b7d0dd1a58c2f7a6c41cfeaff3007c2d14"

http_archive(
name = "rules_jvm_external",
Expand All @@ -34,7 +43,8 @@ maven_install(
],
fetch_sources = True,
repositories = [
"http://uk.maven.org/maven2",
"https://jcenter.bintray.com/",
"https://repo.maven.apache.org/maven2/",
"https://mvnrepository.com/artifact",
"https://maven-central.storage.googleapis.com",
],
)
)
1 change: 1 addition & 0 deletions bazel-MavenPublish
1 change: 1 addition & 0 deletions bazel-bin
1 change: 1 addition & 0 deletions bazel-out
1 change: 1 addition & 0 deletions bazel-testlogs
5 changes: 5 additions & 0 deletions central-sync/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exports_files([
"VERSION",
"deployment.properties",
"workspace_refs.json",
])
1 change: 1 addition & 0 deletions central-sync/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.3.1
17 changes: 17 additions & 0 deletions central-sync/dependencies.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

def vaticle_bazel_distribution():
git_repository(
name = "vaticle_bazel_distribution",
remote = "https://github.com/vaticle/bazel-distribution",
commit = "149f581bf41305563b9f15f4186293644215b622",
)

def rules_jvm_external():
http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-3.2",
sha256 = "82262ff4223c5fda6fb7ff8bd63db8131b51b413d26eb49e3131037e79e324af",
url = "https://github.com/bazelbuild/rules_jvm_external/archive/3.2.zip",
)
12 changes: 12 additions & 0 deletions central-sync/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

#make sure you have a secret gpg key: gpg --list-secret-keys
#Set version in VERSION file
#export DEPLOY_MAVEN_USERNAME=YYY
#export DEPLOY_MAVEN_PASSWORD=XXX
bazel run //core:deploy-maven -- release --gpg
bazel run //core:deploy-maven-testkit -- release --gpg
bazel run //future-interop:deploy-maven -- release --gpg
bazel run //java-interop:deploy-maven-java-core -- release --gpg
bazel run //java-interop:deploy-maven -- release --gpg
#go to https://oss.sonatype.org/#stagingRepositories, close then release
4 changes: 4 additions & 0 deletions central-sync/deployment.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
repo.maven.snapshot=https://oss.sonatype.org/content/repositories/snapshots
repo.maven.release=https://oss.sonatype.org/service/local/staging/deploy/maven2/

maven.packages=api,client-java,common,concept,console,daemon,grammar,grpc,java,,server
1 change: 1 addition & 0 deletions central-sync/workspace_refs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"commits": {}, "tags": {}}
4 changes: 4 additions & 0 deletions dependencies/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exports_files([
"BUILD.binary",
"BUILD.proxy",
])
28 changes: 28 additions & 0 deletions dependencies/BUILD.binary
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])

filegroup(
name = "protoc",
srcs = ["bin/protoc"],
)

_WELL_KNOWN_PROTO_MAP = {
"any": ("google/protobuf/any.proto", []),
"api": ("google/protobuf/api.proto", ["source_context", "type"]),
"compiler_plugin": ("google/protobuf/compiler/plugin.proto", ["descriptor"]),
"descriptor": ("google/protobuf/descriptor.proto", []),
"duration": ("google/protobuf/duration.proto", []),
"empty": ("google/protobuf/empty.proto", []),
"field_mask": ("google/protobuf/field_mask.proto", []),
"source_context": ("google/protobuf/source_context.proto", []),
"struct": ("google/protobuf/struct.proto", []),
"timestamp": ("google/protobuf/timestamp.proto", []),
"type": ("google/protobuf/type.proto", ["any", "source_context"]),
"wrappers": ("google/protobuf/wrappers.proto", []),
}

[proto_library(
name = name + "_proto",
srcs = ["include/" + proto[0]],
strip_import_prefix = "include",
deps = [dep + "_proto" for dep in proto[1]],
) for name, proto in _WELL_KNOWN_PROTO_MAP.items()]
80 changes: 80 additions & 0 deletions dependencies/BUILD.proxy
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package(default_visibility = ["//visibility:public"])

load("@rules_proto//proto:defs.bzl", "proto_lang_toolchain")

[
alias(
name = target,
actual = select({
":linux-x86_64": "@com_google_protobuf_protoc_linux_x86_64//:" + target,
":macos-x86_64": "@com_google_protobuf_protoc_macos_x86_64//:" + target,
":macos-arm64": "@com_google_protobuf_protoc_macos_arm64//:" + target,
}),
)
for target in [
"protoc",
"any_proto",
"api_proto",
"compiler_plugin_proto",
"descriptor_proto",
"duration_proto",
"empty_proto",
"field_mask_proto",
"source_context_proto",
"struct_proto",
"timestamp_proto",
"type_proto",
"wrappers_proto",
]
]

alias(
name = "protobuf_java",
actual = "@com_google_protobuf_protobuf_java//jar",
)

alias(
name = "protobuf_java_util",
actual = "@com_google_protobuf_protobuf_java_util//jar",
)

alias(
name = "protobuf_javalite",
actual = "@com_google_protobuf_protobuf_javalite//jar",
)

proto_lang_toolchain(
name = "java_toolchain",
command_line = "--java_out=$(OUT)",
runtime = ":protobuf_java",
)

proto_lang_toolchain(
name = "javalite_toolchain",
command_line = "--java_out=lite:$(OUT)",
runtime = ":protobuf_javalite",
)

config_setting(
name = "linux-x86_64",
constraint_values = [
"@platforms//os:linux",
"@platforms//cpu:x86_64",
],
)

config_setting(
name = "macos-x86_64",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:x86_64",
],
)

config_setting(
name = "macos-arm64",
constraint_values = [
"@platforms//os:macos",
"@platforms//cpu:arm64",
],
)
56 changes: 56 additions & 0 deletions dependencies/google_protobuf.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")

_PROTOC_BINARIES = {
"com_google_protobuf_protoc_linux_x86_64": {
"sha256": "0d13805474b85611c74f00c738a85ad00a25828dbf6e501de29d7f56b3dbcc03",
"url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.10/protoc-21.10-linux-x86_64.zip",
},
"com_google_protobuf_protoc_macos_x86_64": {
"sha256": "96126be6f421b2417e54cd4cf79afeea98a4ca035fa39fa2bd7bf29e6c5afe0b",
"url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.10/protoc-21.10-osx-x86_64.zip",
},
"com_google_protobuf_protoc_macos_arm64": {
"sha256": "dfa3e0a72f7eeec8c0a52de82aa4846ec06a784975c91849e264891f279fdddf",
"url": "https://github.com/protocolbuffers/protobuf/releases/download/v21.10/protoc-21.10-osx-aarch_64.zip",
},
}

def google_protobuf():
"""
Defines a @com_google_protobuf repository which points to precompiled protoc.
Repository acts as a proxy (contains only aliases) to platform specific binary in com_google_protobuf_protoc_OS_CPU.
Correct binary repository is selected by host/execution platform.
Rationale of this is to reduce dependencies brought by @rules_proto as it tries to target languages we don't need.
"""

for name, args in _PROTOC_BINARIES.items():
http_archive(
name = name,
build_file = "//dependencies/google_protobuf:BUILD.binary",
**args
)

_protoc_proxy(name = "com_google_protobuf")

# Care should be taken when updating this dependency as it uses own BUILD files.
# Current version contains only proto_library and java_proto_library definitions.
# Later versions adds cc_proto_library, py_proto_library and so on.
# It might introduce unexpected dependencies to the build graph.
maybe(
repo_rule = http_archive,
name = "google_api_protos",
urls = ["https://github.com/googleapis/googleapis/archive/c911062bb7a1c41a208957bed923b8750f3b6f28.zip"],
strip_prefix = "googleapis-c911062bb7a1c41a208957bed923b8750f3b6f28",
sha256 = "9ecae675e5f169f93bf07d8ff80b51444c8eb57b10beba2e0657a317bdf378a4",
)

def _protoc_proxy_impl(ctx):
ctx.symlink(ctx.attr._build, "BUILD")

_protoc_proxy = repository_rule(
implementation = _protoc_proxy_impl,
attrs = {
"_build": attr.label(default = "//dependencies/google_protobuf:BUILD.proxy"),
},
)
2 changes: 1 addition & 1 deletion mainclass/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</dependencies>


<name>maven publish main project by yesha</name>
<name>mainclass</name>
<url>https://github.com/yeshamavani/mavenpublish</url>
<description>A trial monorepo for publish</description>

Expand Down
34 changes: 33 additions & 1 deletion sharedlibrary/BUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
package(default_visibility = ["//visibility:public"])

load("@vaticle_bazel_distribution//maven:rules.bzl", "assemble_maven", "deploy_maven")

java_library(
name = "sharedlibrary",
srcs = glob(["src/main/java/com/github/yeshamavani/*.java"]),
visibility = ["//visibility:public"]
visibility = ["//visibility:public"],
tags = [
"manual",
"maven_coordinates=io.github.yeshamavani:sharedlibrary:{pom_version}"
],
)

assemble_maven(
name = "sharedlibrary",
developers = {
"1" : ["name=Yesha Mavani",
"email=nyesha.mavani@sourcefuse.com",
"organization=io.github.yeshamavani",]
},
license = "mit",
project_description = "MavenPublish - sharedlibrary",
project_name = "sharedlibrary",
project_url = "https://github.com/yeshamavani/mavenpublish",
scm_url = "https://github.com/yeshamavani/mavenpublish.git",
tags = ["manual"],
target = "//sharedlibrary:sharedlibrary",
version_file = "//central-sync:VERSION",
workspace_refs = "//central-sync:workspace_refs.json",
)

deploy_maven(
name = "deploy-sharedlibrary",
release = "https://oss.sonatype.org/service/local/staging/deploy/maven2/",
snapshot = "https://oss.sonatype.org/content/repositories/snapshots",
tags = ["manual"],
target = ":sharedlibrary",
)
2 changes: 1 addition & 1 deletion sharedlibrary/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</snapshotRepository>
</distributionManagement>

<name>maven publish shared project by yesha</name>
<name>msharedlibrary</name>
<url>https://github.com/yeshamavani/mavenpublish</url>
<description>A trial monorepo for publish</description>

Expand Down