Skip to content

Commit

Permalink
Fix #2431: Upgrade kotlin to 1.4 (#2439)
Browse files Browse the repository at this point in the history
* Upgrade kotlin in gradle build, update moshi dependency in data module

* Change bazel kotlin rules to 1.5.0

* Use 1.5.0 alpha 2 and add SHA

* Add rules_java http_archive

* Add rules_proto to migrate from native to Starlark proto rules

* Go back to kotlin 1.3 to check rules_proto

* Revert "Go back to kotlin 1.3 to check rules_proto"

This reverts commit 6f2c498.

* Add kt_download_local_dev_dependencies() in WORKSPACE

* Address review comments

* Remove rules_java import

* Fix comment

* Address review comments

* Import rules_java for java_lite_proto_library

* Go back to gradle 3.6

* Alphabetize

* Use Kotlin 1.3.61?

* Revert "Use Kotlin 1.3.61?"

This reverts commit 611eb41.

* Use gradle 6.8, Kotlin 1.4, plugin 3.6

* Use Kotlin 1.3 and compatibility with Gradle and plugin

* Kotlin 1.4, gradle 3.6, wrapper 6.8
  • Loading branch information
jcqli authored Jan 14, 2021
1 parent d2e6c86 commit a7c8b63
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 10 deletions.
30 changes: 24 additions & 6 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,14 @@ http_archive(
)

# Add support for Kotlin: https://github.com/bazelbuild/rules_kotlin.
RULES_KOTLIN_VERSION = "legacy-1.4.0-rcx-oppia-exclusive-rc01"
RULES_KOTLIN_VERSION = "v1.5.0-alpha-2"

RULES_KOTLIN_SHA = "600f3d916eda5531dd70614ec96dc92b4ac24da0e1d815eb94559976e9bea8aa"
RULES_KOTLIN_SHA = "6194a864280e1989b6d8118a4aee03bb50edeeae4076e5bc30eef8a98dcd4f07"

http_archive(
name = "io_bazel_rules_kotlin",
sha256 = RULES_KOTLIN_SHA,
strip_prefix = "rules_kotlin-%s" % RULES_KOTLIN_VERSION,
type = "zip",
urls = ["https://github.com/oppia/rules_kotlin/archive/%s.zip" % RULES_KOTLIN_VERSION],
urls = ["https://github.com/bazelbuild/rules_kotlin/releases/download/%s/rules_kotlin_release.tgz" % RULES_KOTLIN_VERSION],
)

# TODO(#1535): Remove once rules_kotlin is released because these lines become unnecessary
Expand All @@ -56,7 +54,6 @@ module while helping us avoid the unnecessary compilation of protoc. Referecence
- https://github.com/google/startup-os/blob/5f30a62/WORKSPACE#L179-L187
- https://github.com/bazelbuild/bazel/issues/7095
"""

bind(
name = "proto_compiler",
actual = "//tools:protoc",
Expand All @@ -67,12 +64,33 @@ bind(
actual = "//tools:java_toolchain",
)

# The rules_java contains the java_lite_proto_library rule used in the model module.
http_archive(
name = "rules_java",
sha256 = "220b87d8cfabd22d1c6d8e3cdb4249abd4c93dcc152e0667db061fb1b957ee68",
url = "https://github.com/bazelbuild/rules_java/releases/download/0.1.1/rules_java-0.1.1.tar.gz",
)

load("@rules_java//java:repositories.bzl", "rules_java_dependencies", "rules_java_toolchains")

rules_java_dependencies()

rules_java_toolchains()

# The rules_proto contains the proto_library rule used in the gitmodel module.
http_archive(
name = "rules_proto",
sha256 = "602e7161d9195e50246177e7c55b2f39950a9cf7366f74ed5f22fd45750cd208",
strip_prefix = "rules_proto-97d8af4dc474595af3900dd85cb3a29ad28cc313",
urls = ["https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz"],
)

load("@rules_proto//proto:repositories.bzl", "rules_proto_dependencies", "rules_proto_toolchains")

rules_proto_dependencies()

rules_proto_toolchains()

# Add support for Dagger
DAGGER_TAG = "2.28.1"

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.41'
ext.kotlin_version = '1.4.20'
ext.fragment_version = '1.2.0-rc01'
repositories {
google()
Expand Down
4 changes: 2 additions & 2 deletions data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ dependencies {
'com.android.support:multidex:1.0.3',
'com.google.dagger:dagger:2.24',
'com.google.protobuf:protobuf-lite:3.0.0',
'com.squareup.moshi:moshi-kotlin:1.8.0',
'com.squareup.moshi:moshi-kotlin:1.11.0',
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.2.2',
)
testImplementation(
Expand All @@ -92,7 +92,7 @@ dependencies {
)
androidTestImplementation('androidx.test:runner:1.2.0',
'androidx.test.espresso:espresso-core:3.2.0')
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.8.0")
kapt("com.squareup.moshi:moshi-kotlin-codegen:1.11.0")
kaptTest(
'com.google.dagger:dagger-compiler:2.24'
)
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
2 changes: 2 additions & 0 deletions model/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ The proto_library() rule creates a proto file library to be used in multiple lan
The java_lite_proto_library() rule takes in a proto_library target and generates java code.
'''
load("//model:src/main/proto/format_import_proto_library.bzl", "format_import_proto_library")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@rules_java//java:defs.bzl", "java_lite_proto_library")

# NOTE TO DEVELOPERS: When adding new protos, each proto will need to have both a proto_library
# and java_lite_proto_library. See the examples below for context. Further, once the proto lite
Expand Down

0 comments on commit a7c8b63

Please sign in to comment.