Skip to content

Commit

Permalink
Use rules_kotlin >= 1.5.0 format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
minkuan88 committed May 10, 2022
1 parent 9e0b918 commit f7bf9f0
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 36 deletions.
2 changes: 1 addition & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "define_kt_toolchain", "kt_javac_options", "kt_kotlinc_options")
load("@io_bazel_rules_kotlin//kotlin:core.bzl", "define_kt_toolchain", "kt_javac_options", "kt_kotlinc_options")

kt_kotlinc_options(
name = "kt_kotlinc_options",
Expand Down
24 changes: 9 additions & 15 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,24 @@ load("@maven//:defs.bzl", "pinned_maven_install")

pinned_maven_install()

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

git_repository(
http_archive(
name = "io_bazel_rules_kotlin",
commit = "eae21653baad4b403fee9e8a706c9d4fbd0c27c6",
remote = "https://github.com/bazelbuild/rules_kotlin.git",
sha256 = "f1a4053eae0ea381147f5056bb51e396c5c494c7f8d50d0dee4cc2f9d5c701b0",
url = "https://github.com/bazelbuild/rules_kotlin/releases/download/1.6.0-RC-1/rules_kotlin_release.tgz",
)

load("@io_bazel_rules_kotlin//kotlin:dependencies.bzl", "kt_download_local_dev_dependencies")

kt_download_local_dev_dependencies()

KOTLIN_VERSION = "1.4.21"

KOTLINC_RELEASE_SHA = "46720991a716e90bfc0cf3f2c81b2bd735c14f4ea6a5064c488e04fd76e6b6c7"

KOTLINC_RELEASE = {
"urls": [
"https://github.com/JetBrains/kotlin/releases/download/v{v}/kotlin-compiler-{v}.zip".format(v = KOTLIN_VERSION),
],
"sha256": KOTLINC_RELEASE_SHA,
}
load("@io_bazel_rules_kotlin//kotlin:repositories.bzl", "kotlin_repositories", "kotlinc_version")

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories")
KOTLINC_RELEASE = kotlinc_version(
release = KOTLIN_VERSION,
sha256 = KOTLINC_RELEASE_SHA,
)

kotlin_repositories(compiler_release = KOTLINC_RELEASE)

Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ grazel {
)
}
kotlin {
gitRepository {
commit = "eae21653baad4b403fee9e8a706c9d4fbd0c27c6"
remote = "https://github.com/bazelbuild/rules_kotlin.git"
httpArchiveRepository {
url = "https://github.com/bazelbuild/rules_kotlin/releases/download/1.6.0-RC-1/rules_kotlin_release.tgz"
sha256 = "f1a4053eae0ea381147f5056bb51e396c5c494c7f8d50d0dee4cc2f9d5c701b0"
}
compiler {
version = "1.4.20"
Expand Down Expand Up @@ -166,4 +166,4 @@ idea {
file("bazel-testlogs"),
]
}
}
}
2 changes: 1 addition & 1 deletion constants.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// TODO migrate to version catalogs
ext {
groupId = "com.grab.grazel"
versionName = "0.4.0-alpha06"
versionName = "0.4.0-alpha07"

kotlinVersion = "1.4.32"
agpVersion = "7.1.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,18 @@ fun StatementsBuilder.kotlinCompiler(
KOTLINC_RELEASE_SHA eq kotlinCompilerReleaseSha.quote()
newLine()

KOTLINC_RELEASE eq obj {
"urls".quote() eq array(
""""https://github.com/JetBrains/kotlin/releases/download/v{v}/kotlin-compiler-{v}.zip".format(v = $KOTLIN_VERSION)"""
)
"sha256".quote() eq KOTLINC_RELEASE_SHA
}
load(
"@io_bazel_rules_kotlin//kotlin:repositories.bzl",
"kotlin_repositories",
"kotlinc_version"
)

KOTLINC_RELEASE eq """kotlinc_version(
release = $KOTLIN_VERSION,
sha256 = $KOTLINC_RELEASE_SHA
)
""".trimIndent()

load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories")
add("""kotlin_repositories(compiler_release = $KOTLINC_RELEASE)""")
}

Expand Down Expand Up @@ -99,7 +103,7 @@ fun StatementsBuilder.rootKotlinSetup(
val kotlinCTarget = "kt_kotlinc_options"
val javaTarget = "kt_javac_options"
load(
"@io_bazel_rules_kotlin//kotlin:kotlin.bzl",
"@io_bazel_rules_kotlin//kotlin:core.bzl",
javaTarget,
kotlinCTarget,
"define_kt_toolchain"
Expand Down Expand Up @@ -138,7 +142,7 @@ fun StatementsBuilder.loadKtRules(
"kt_db_android_library"
)
isAndroid -> load("@$GRAB_BAZEL_COMMON//tools/kotlin:android.bzl", "kt_android_library")
isJvm -> load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")
isJvm -> load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import groovy.lang.Closure

internal const val RULE_KOTLIN_NAME = "io_bazel_rules_kotlin"
internal const val RULES_KOTLIN_SHA =
"da0e6e1543fcc79e93d4d93c3333378f3bd5d29e82c1bc2518de0dbe048e6598"
internal const val RULES_KOTLIN_VERSION = "legacy-1.4.0-rc3"
"12d22a3d9cbcf00f2e2d8f0683ba87d3823cb8c7f6837568dd7e48846e023307"
internal const val RULES_KOTLIN_VERSION = "v1.5.0"

/**
* Options for Kotlin Compiler.
Expand Down Expand Up @@ -62,7 +62,7 @@ class KotlinToolChain(
internal val KOTLIN_REPOSITORY = HttpArchiveRule(
name = RULE_KOTLIN_NAME,
sha256 = RULES_KOTLIN_SHA,
url = """https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz % $RULES_KOTLIN_VERSION"""
url = """https://github.com/bazelbuild/rules_kotlin/releases/download/$RULES_KOTLIN_VERSION/rules_kotlin_release.tgz"""
)

data class KotlinCompiler(
Expand Down
2 changes: 1 addition & 1 deletion sample-kotlin-lib/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")

kt_jvm_library(
name = "sample-kotlin-lib",
Expand Down
2 changes: 1 addition & 1 deletion sample-lib-flavor1/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")

kt_jvm_library(
name = "sample-lib-flavor1",
Expand Down
2 changes: 1 addition & 1 deletion sample-lib-flavor2/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kt_jvm_library")
load("@io_bazel_rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")

kt_jvm_library(
name = "sample-lib-flavor2",
Expand Down

0 comments on commit f7bf9f0

Please sign in to comment.