Skip to content
Merged
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
1 change: 1 addition & 0 deletions .bazelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
bzl-examples/
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
build --cxxopt=-std=c++14 --host_cxxopt=-std=c++14
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.3.2
7.6.1
21 changes: 18 additions & 3 deletions .github/workflows/bazel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,38 @@ jobs:
with:
path: "/home/runner/.cache/bazel"
key: bazel
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Install bazelisk
run: |
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.1.0/bazelisk-linux-amd64"
curl -LO "https://github.com/bazelbuild/bazelisk/releases/download/v1.26.0/bazelisk-linux-amd64"
mkdir -p "${GITHUB_WORKSPACE}/bin/"
mv bazelisk-linux-amd64 "${GITHUB_WORKSPACE}/bin/bazel"
chmod +x "${GITHUB_WORKSPACE}/bin/bazel"
- name: Build
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
cd "${GITHUB_WORKSPACE}"
"${GITHUB_WORKSPACE}/bin/bazel" build //...
- name: Test
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
cd "${GITHUB_WORKSPACE}"
"${GITHUB_WORKSPACE}/bin/bazel" test //...
- name: Build
- name: Test bzl-examples/bzlmod
uses: nick-invision/retry@v3
with:
timeout_minutes: 10
max_attempts: 3
command: |
"${GITHUB_WORKSPACE}/bin/bazel" build //...
cd "${GITHUB_WORKSPACE}/bzl-examples/bzlmod"
"${GITHUB_WORKSPACE}/bin/bazel" test //...
9 changes: 5 additions & 4 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
java-version: '11'
cache: 'gradle'

- uses: gradle/gradle-build-action@v3
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3

- name: Test on Mac
if: matrix.os == 'macos-13'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'adopt'
java-version: '11'
cache: 'gradle'
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/gradle-build-action@v3
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3

- name: release
env:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ build
local.properties
*.iml
/bazel-*
MODULE.bazel.lock
*/bin/*
34 changes: 34 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module(
name = "grpc_kotlin",
version = "2.1.0",
)

bazel_dep(name = "protobuf", repo_name = "com_google_protobuf", version = "30.2")
bazel_dep(name = "rules_kotlin", repo_name = "io_bazel_rules_kotlin", version = "2.1.3")
bazel_dep(name = "rules_java", version = "8.11.0")
bazel_dep(name = "rules_jvm_external", version = "6.7")
bazel_dep(name = "grpc-java", repo_name = "io_grpc_grpc_java", version = "1.71.0")

grpc_kotlin_maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
grpc_kotlin_maven.install(
name = "grpc_kotlin_maven",
# Rerun whenever adding new artifacts.
# $ REPIN=1 bazelisk run @grpc_kotlin_maven//:pin
artifacts = [
"com.google.jimfs:jimfs:1.3.0",
"com.google.truth:truth:1.4.2",
"com.google.truth.extensions:truth-proto-extension:1.4.2",
"com.google.protobuf:protobuf-java:4.30.2",
"com.google.protobuf:protobuf-kotlin:4.30.2",
"com.google.guava:guava:33.3.1-android",
"com.squareup:kotlinpoet:1.14.2",
"junit:junit:4.13.2",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1",
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.10.1",
],
fetch_sources = False,
lock_file = "//:grpc_kotlin_maven_install.json",
generate_compat_repositories = True,
strict_visibility = True,
)
use_repo(grpc_kotlin_maven, "grpc_kotlin_maven")
70 changes: 0 additions & 70 deletions WORKSPACE

This file was deleted.

6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ subprojects {
version = rootProject.version

tasks.withType<JavaCompile> {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
}

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = JavaVersion.VERSION_1_8.toString()
jvmTarget = JavaVersion.VERSION_17.toString()
}
}

Expand Down
1 change: 1 addition & 0 deletions bzl-examples/bzlmod/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
1 change: 1 addition & 0 deletions bzl-examples/bzlmod/.bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7.6.1
2 changes: 2 additions & 0 deletions bzl-examples/bzlmod/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bazel-*
MODULE.bazel.lock
16 changes: 16 additions & 0 deletions bzl-examples/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@aspect_rules_lint//format:defs.bzl", "format_multirun")
load("@rules_java//java:defs.bzl", "java_binary")

java_binary(
name = "ktfmt",
main_class = "com.facebook.ktfmt.cli.Main",
runtime_deps = ["@ktfmt//jar"],
)

format_multirun(
name = "format",
kotlin = ":ktfmt",
protocol_buffer = "@rules_buf_toolchains//:buf",
starlark = "@buildifier_prebuilt//:buildifier",
visibility = ["//visibility:public"],
)
41 changes: 41 additions & 0 deletions bzl-examples/bzlmod/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
module(
name = "bzlmod",
version = "1.0",
)

bazel_dep(name = "protobuf", version = "30.2")
bazel_dep(name = "rules_kotlin", version = "2.1.3")
bazel_dep(name = "grpc_kotlin", version = "0.0.0")
bazel_dep(name = "rules_jvm_external", version = "6.7")
bazel_dep(name = "aspect_rules_lint", version = "1.3.4")
bazel_dep(name = "rules_java", version = "8.11.0")
bazel_dep(name = "buildifier_prebuilt", version = "8.0.3")
bazel_dep(name = "rules_buf", version = "0.3.0")

local_path_override(
module_name = "grpc_kotlin",
path = "../../",
)

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
# Rerun whenever adding new artifacts.
# $ REPIN=1 bazelisk run @maven//:pin
artifacts = [
"com.google.truth:truth:1.4.2",
"junit:junit:4.13.2",
"com.google.truth.extensions:truth-proto-extension:1.4.4",
"io.grpc:grpc-testing:1.71.0",
],
fetch_sources = False,
generate_compat_repositories = True,
lock_file = "//:maven_install.json",
strict_visibility = True,
)
use_repo(maven, "grpc_kotlin_maven", "maven")

install_ktfmt = use_extension("//:extensions.bzl", "install_ktfmt")
use_repo(install_ktfmt, "ktfmt")

buf = use_extension("@rules_buf//buf:extensions.bzl", "buf")
use_repo(buf, "rules_buf_toolchains")
6 changes: 6 additions & 0 deletions bzl-examples/bzlmod/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
load("@aspect_rules_lint//format:repositories.bzl", "fetch_ktfmt")

def _install_ktfmt_impl(module_ctx):
fetch_ktfmt()

install_ktfmt = module_extension(_install_ktfmt_impl)
31 changes: 31 additions & 0 deletions bzl-examples/bzlmod/java/io/grpc/examples/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@grpc_kotlin//:kt_jvm_grpc.bzl", "kt_jvm_grpc_library", "kt_jvm_proto_library")
load("@protobuf//bazel:proto_library.bzl", "proto_library")
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")

package(default_visibility = ["//javatests/io/grpc/examples/bzlmod:__subpackages__"])

proto_library(
name = "fibonacci_proto",
srcs = ["fibonacci.proto"],
deps = [],
)

kt_jvm_proto_library(
name = "fibonacci_kt_proto",
deps = [":fibonacci_proto"],
)

kt_jvm_grpc_library(
name = "fibonacci_kt_grpc",
srcs = [":fibonacci_proto"],
deps = [":fibonacci_kt_proto"],
)

kt_jvm_library(
name = "fibonacci",
srcs = ["Fibonacci.kt"],
deps = [
":fibonacci_kt_grpc",
":fibonacci_kt_proto",
],
)
19 changes: 19 additions & 0 deletions bzl-examples/bzlmod/java/io/grpc/examples/bzlmod/Fibonacci.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.grpc.examples.bzlmod

/** A simple implementation of a Fibonacci service. */
class Fibonacci : FibonacciServiceGrpcKt.FibonacciServiceCoroutineImplBase() {
override suspend fun query(request: QueryRequest): QueryResponse {
if (request.nth <= 1) {
return queryResponse { nthFibonacci = request.nth }
}
var prv = 0L
var cur = 1L
var nxt = 1L
for (i in 2..request.nth) {
prv = cur
cur = nxt
nxt = (prv + cur) % request.mod
}
return queryResponse { nthFibonacci = cur }
}
}
20 changes: 20 additions & 0 deletions bzl-examples/bzlmod/java/io/grpc/examples/bzlmod/fibonacci.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
syntax = "proto3";

package io.grpc.examples.bzlmod;

option java_multiple_files = true;
option java_outer_classname = "FibonacciProtos";
option java_package = "io.grpc.examples.bzlmod";

message QueryRequest {
int64 nth = 1;
int64 mod = 2;
}

message QueryResponse {
int64 nth_fibonacci = 1;
}

service FibonacciService {
rpc Query(QueryRequest) returns (QueryResponse);
}
16 changes: 16 additions & 0 deletions bzl-examples/bzlmod/javatests/io/grpc/examples/bzlmod/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
load("@rules_jvm_external//:defs.bzl", "artifact")
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test")

kt_jvm_test(
name = "FibonacciTest",
srcs = ["FibonacciTest.kt"],
deps = [
"//java/io/grpc/examples/bzlmod:fibonacci",
"//java/io/grpc/examples/bzlmod:fibonacci_kt_grpc",
"//java/io/grpc/examples/bzlmod:fibonacci_kt_proto",
artifact("com.google.truth:truth"),
artifact("com.google.truth.extensions:truth-proto-extension"),
artifact("junit:junit"),
artifact("io.grpc:grpc-testing"),
],
)
Loading
Loading