Skip to content

Commit

Permalink
Download kotlin compiler JARs for Buck instead of checking them in (f…
Browse files Browse the repository at this point in the history
…acebook#33209)

Summary:
Pull Request resolved: facebook#33209

Downloads Kotlin compiler JARs with Buck before starting docker build. This solution is slower than checking in JARs directly, but it allows to keep lighter size of the repo for people who want a complete checkout.

Changelog: [Internal] - Update CI build to download Kotlin jars for buck

Reviewed By: cortinico

Differential Revision: D34582932

fbshipit-source-id: 290398579ce2a4d57c7af318c66526689db6073c
  • Loading branch information
Andrei Shikov authored and facebook-github-bot committed Mar 2, 2022
1 parent 6abbef1 commit fc9dec9
Show file tree
Hide file tree
Showing 14 changed files with 100 additions and 25 deletions.
1 change: 0 additions & 1 deletion .buckconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
[kotlin]
compile_against_abis = True
kotlin_version = 1.6.10
kotlin_home = ReactAndroid/src/main/third-party/kotlin/$(config kotlin.kotlin_version)

[download]
max_number_of_retries = 3
Expand Down
4 changes: 4 additions & 0 deletions .circleci/Dockerfiles/Dockerfile.android
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ LABEL maintainer="Héctor Ramos <hector@fb.com>"
# set default environment variables
ENV GRADLE_OPTS="-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs=\"-Xmx512m -XX:+HeapDumpOnOutOfMemoryError\""
ENV JAVA_TOOL_OPTIONS="-Dfile.encoding=UTF8"
ENV KOTLIN_HOME="third-party/kotlin"

ADD .buckconfig /app/.buckconfig
ADD .buckjavaargs /app/.buckjavaargs
Expand All @@ -33,9 +34,12 @@ ADD React /app/React
ADD keystores /app/keystores
ADD packages/react-native-codegen /app/packages/react-native-codegen
ADD tools /app/tools
add scripts /app/scripts

WORKDIR /app

RUN scripts/download-kotlin-compiler-with-buck.sh

RUN buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
RUN buck fetch ReactAndroid/src/main/java/com/facebook/react
RUN buck fetch ReactAndroid/src/main/java/com/facebook/react/shell
Expand Down
2 changes: 2 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,8 @@ jobs:
run_disabled_tests:
type: boolean
default: false
environment:
KOTLIN_HOME=third-party/kotlin
steps:
- checkout
- setup_artifacts
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
102 changes: 78 additions & 24 deletions ReactAndroid/src/main/third-party/kotlin/BUCK
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,16 @@ rn_android_library(

rn_prebuilt_jar(
name = "jetbrains-annotations",
binary_jar = ":jetbrains-annotations.jar",
binary_jar = ":annotations-13.0.jar",
visibility = ["//ReactAndroid/..."],
)

fb_native.remote_file(
name = "jetbrains-annotations.jar",
sha1 = "919f0dfe192fb4e063e7dacadee7f8bb9a2672a9",
url = "mvn:org.jetbrains:annotations:jar:13.0",
)

rn_prebuilt_jar(
name = "kotlin-stdlib-binary",
binary_jar = ":kotlin-stdlib-binary.jar",
binary_jar = ":kotlin-stdlib.jar",
visibility = ["//ReactAndroid/..."],
)

fb_native.remote_file(
name = "kotlin-stdlib-binary.jar",
sha1 = "ea29e063d2bbe695be13e9d044dcfb0c7add398e",
url = "mvn:org.jetbrains.kotlin:kotlin-stdlib:jar:1.4.10",
)

rn_prebuilt_jar(
name = "kotlin-stdlib-common",
binary_jar = ":kotlin-stdlib-common.jar",
Expand All @@ -62,30 +50,96 @@ rn_prebuilt_jar(

fb_native.remote_file(
name = "kotlin-stdlib-common.jar",
sha1 = "6229be3465805c99db1142ad75e6c6ddeac0b04c",
url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.4.10",
sha1 = "0c118700e3a33c8a0d9adc920e9dec0831171925",
url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.6.10",
)

rn_prebuilt_jar(
name = "kotlin-stdlib-jdk7-binary",
binary_jar = ":kotlin-stdlib-jdk7-binary.jar",
binary_jar = ":kotlin-stdlib-jdk7.jar",
visibility = ["//ReactAndroid/..."],
)

fb_native.remote_file(
name = "kotlin-stdlib-jdk7-binary.jar",
sha1 = "30e46450b0bb3dbf43898d2f461be4a942784780",
url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.4.10",
name = "kotlin-stdlib-jdk7.jar",
sha1 = "e1c380673654a089c4f0c9f83d0ddfdc1efdb498",
url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.6.10",
)

rn_prebuilt_jar(
name = "kotlin-stdlib-jdk8-binary",
binary_jar = ":kotlin-stdlib-jdk8-binary.jar",
binary_jar = ":kotlin-stdlib-jdk8.jar",
visibility = ["//ReactAndroid/..."],
)

fb_native.remote_file(
name = "kotlin-stdlib-jdk8-binary.jar",
sha1 = "998caa30623f73223194a8b657abd2baec4880ea",
url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.4.10",
name = "kotlin-stdlib-jdk8.jar",
sha1 = "e80fe6ac3c3573a80305f5ec43f86b829e8ab53d",
url = "mvn:org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.6.10",
)

fb_native.genrule(
name = "kotlin-compiler-download",
type = "copy",
srcs = [
":annotations-13.0.jar",
":kotlin-annotation-processing.jar",
":kotlin-compiler.jar",
":kotlin-compiler-embeddable.jar",
":kotlin-reflect.jar",
":kotlin-script-runtime.jar",
":kotlin-stdlib.jar",
":trove4j.jar",
],
cmd = "mkdir ${OUT} && cp ${SRCS} ${OUT}",
cmd_exe = "@powershell -Command Copy-Item '${SRCS}' '${OUT}'",
out = "kotlin-compiler-out",
)

fb_native.remote_file(
name = "kotlin-compiler-embeddable.jar",
sha1 = "88f2073f4020cdb83132cfe940ceb9a60aba54ea",
url = "mvn:org.jetbrains.kotlin:kotlin-compiler-embeddable:jar:1.6.10",
)

fb_native.remote_file(
name = "kotlin-compiler.jar",
sha1 = "d3e2482aae0dfd96eb51054c8845963b9cbcf49f",
url = "mvn:org.jetbrains.kotlin:kotlin-compiler:jar:1.6.10",
)

fb_native.remote_file(
name = "kotlin-annotation-processing.jar",
sha1 = "bdc1313091f9bd04c1d965c9fda16c214f9f27fc",
url = "mvn:org.jetbrains.kotlin:kotlin-annotation-processing:jar:1.6.10",
)

fb_native.remote_file(
name = "kotlin-reflect.jar",
sha1 = "1cbe9c92c12a94eea200d23c2bbaedaf3daf5132",
url = "mvn:org.jetbrains.kotlin:kotlin-reflect:jar:1.6.10",
)

fb_native.remote_file(
name = "kotlin-script-runtime.jar",
sha1 = "d0a7ff2e2500ef497ed0214ae40ad3c8387a6164",
url = "mvn:org.jetbrains.kotlin:kotlin-script-runtime:jar:1.6.10",
)

fb_native.remote_file(
name = "kotlin-stdlib.jar",
sha1 = "b8af3fe6f1ca88526914929add63cf5e7c5049af",
url = "mvn:org.jetbrains.kotlin:kotlin-stdlib:jar:1.6.10",
)

fb_native.remote_file(
name = "trove4j.jar",
sha1 = "3afb14d5f9ceb459d724e907a21145e8ff394f02",
url = "mvn:org.jetbrains.intellij.deps:trove4j:jar:1.0.20200330",
)

fb_native.remote_file(
name = "annotations-13.0.jar",
sha1 = "919f0dfe192fb4e063e7dacadee7f8bb9a2672a9",
url = "mvn:org.jetbrains:annotations:jar:13.0",
)
4 changes: 4 additions & 0 deletions scripts/circleci/buck_fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ function retry {
return 0
}

CURRENT_DIR=$(pwd)
export KOTLIN_HOME="$CURRENT_DIR/third-party/kotlin"
retry 3 scripts/download-kotlin-compiler-with-buck.sh

retry 3 buck fetch ReactAndroid/src/test/java/com/facebook/react/modules
retry 3 buck fetch ReactAndroid/src/main/java/com/facebook/react
retry 3 buck fetch ReactAndroid/src/main/java/com/facebook/react/shell
Expand Down
12 changes: 12 additions & 0 deletions scripts/download-kotlin-compiler-with-buck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

buck fetch //ReactAndroid/src/main/third-party/kotlin:kotlin-compiler-download

BUCK_OUTPUT_FOLDER=$(buck build //ReactAndroid/src/main/third-party/kotlin:kotlin-compiler-download --show-output -v 0 | sed -E 's/^(.*) (.*)$/\2/g')

mkdir -p "$KOTLIN_HOME"
cp -R "$BUCK_OUTPUT_FOLDER/." "$KOTLIN_HOME"

0 comments on commit fc9dec9

Please sign in to comment.