diff --git a/.bazelci/android.yml b/.bazelci/android.yml index 3c69d7c42..761f718e5 100644 --- a/.bazelci/android.yml +++ b/.bazelci/android.yml @@ -19,6 +19,7 @@ common: - "--noincompatible_enable_android_toolchain_resolution" - "--fat_apk_cpu=arm64-v8a,x86" - "--android_crosstool_top=@androidndk//:toolchain" + - "--enable_bzlmod" build_targets: - "//app/src/main:app" android-jetpack: &android-jetpack @@ -29,6 +30,7 @@ common: build_flags: - "--noincompatible_enable_android_toolchain_resolution" - "--remote_download_outputs=all" + - "--enable_bzlmod" build_targets: - "//app/src/main:app" android-robolectric: &android-robolectric @@ -36,8 +38,9 @@ common: # Cannot upgrade this until rules_kotlin is compatible. bazel: 6.3.2 working_directory: ../android/robolectric-testing - build_flags: + test_flags: - "--noincompatible_enable_android_toolchain_resolution" + - "--enable_bzlmod" test_targets: - "//app:test" diff --git a/android/firebase-cloud-messaging/WORKSPACE b/android/firebase-cloud-messaging/WORKSPACE index 9cc5a7acb..287d4dc78 100644 --- a/android/firebase-cloud-messaging/WORKSPACE +++ b/android/firebase-cloud-messaging/WORKSPACE @@ -6,15 +6,16 @@ android_sdk_repository(name = "androidsdk") android_ndk_repository(name = "androidndk") -RULES_JVM_EXTERNAL_TAG = "2.9" +RULES_JVM_EXTERNAL_TAG = "5.3" -RULES_JVM_EXTERNAL_SHA = "e5b97a31a3e8feed91636f42e19b11c49487b85e5de2f387c999ea14d77c7f45" +RULES_JVM_EXTERNAL_SHA = "d31e369b854322ca5098ea12c69d7175ded971435e55c18dd9dd5f29cc5249ac" http_archive( name = "rules_jvm_external", sha256 = RULES_JVM_EXTERNAL_SHA, strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG, - url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG, + url = + "https://github.com/bazelbuild/rules_jvm_external/releases/download/%s/rules_jvm_external-%s.tar.gz" % (RULES_JVM_EXTERNAL_TAG, RULES_JVM_EXTERNAL_TAG) ) load("@rules_jvm_external//:defs.bzl", "maven_install") diff --git a/android/jetpack-compose/MODULE.bazel b/android/jetpack-compose/MODULE.bazel new file mode 100644 index 000000000..3a4131fdb --- /dev/null +++ b/android/jetpack-compose/MODULE.bazel @@ -0,0 +1,38 @@ +"Bazel dependencies" + +bazel_dep(name = "platforms", version = "0.0.6") +bazel_dep(name = "rules_jvm_external", version = "5.3") + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + artifacts = [ + "androidx.appcompat:appcompat:1.5.1", + # Jetpack Compose Dependencies + "androidx.activity:activity-compose:1.6.0", + "androidx.compose.material:material:1.2.1", + "androidx.compose.ui:ui:1.2.1", + "androidx.compose.ui:ui-tooling:1.2.1", + "androidx.compose.compiler:compiler:1.3.2", + "androidx.compose.runtime:runtime:1.2.1", + # Dependencies needed to manage version conflicts + "androidx.core:core:1.6.0", + "androidx.core:core-ktx:1.6.0", + "androidx.savedstate:savedstate-ktx:1.2.0", + "androidx.savedstate:savedstate:1.2.0", + "androidx.lifecycle:lifecycle-livedata-core-ktx:2.5.1", + "androidx.lifecycle:lifecycle-livedata-core:2.5.1", + "androidx.lifecycle:lifecycle-livedata:2.5.1", + "androidx.lifecycle:lifecycle-process:2.5.1", + "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1", + "androidx.lifecycle:lifecycle-runtime:2.5.1", + "androidx.lifecycle:lifecycle-service:2.5.1", + "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1", + "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1", + "androidx.lifecycle:lifecycle-viewmodel:2.5.1", + ], + repositories = [ + "https://maven.google.com", + "https://repo1.maven.org/maven2", + ], +) +use_repo(maven, "maven") diff --git a/android/jetpack-compose/WORKSPACE b/android/jetpack-compose/WORKSPACE index 9f5bd3480..b0325a894 100644 --- a/android/jetpack-compose/WORKSPACE +++ b/android/jetpack-compose/WORKSPACE @@ -7,50 +7,6 @@ _KOTLIN_COMPILER_VERSION = "1.7.20" _KOTLIN_COMPILER_SHA = "5e3c8d0f965410ff12e90d6f8dc5df2fc09fd595a684d514616851ce7e94ae7d" -## rules_jvm_external - -http_archive( - name = "rules_jvm_external", - sha256 = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca", - strip_prefix = "rules_jvm_external-4.2", - url = "https://github.com/bazelbuild/rules_jvm_external/archive/4.2.zip", -) - -load("@rules_jvm_external//:defs.bzl", "maven_install") - -maven_install( - name = "maven", - artifacts = [ - "androidx.appcompat:appcompat:1.5.1", - # Jetpack Compose Dependencies - "androidx.activity:activity-compose:1.6.0", - "androidx.compose.material:material:1.2.1", - "androidx.compose.ui:ui:1.2.1", - "androidx.compose.ui:ui-tooling:1.2.1", - "androidx.compose.compiler:compiler:1.3.2", - "androidx.compose.runtime:runtime:1.2.1", - # Dependencies needed to manage version conflicts - "androidx.core:core:1.6.0", - "androidx.core:core-ktx:1.6.0", - "androidx.savedstate:savedstate-ktx:1.2.0", - "androidx.savedstate:savedstate:1.2.0", - "androidx.lifecycle:lifecycle-livedata-core-ktx:2.5.1", - "androidx.lifecycle:lifecycle-livedata-core:2.5.1", - "androidx.lifecycle:lifecycle-livedata:2.5.1", - "androidx.lifecycle:lifecycle-process:2.5.1", - "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1", - "androidx.lifecycle:lifecycle-runtime:2.5.1", - "androidx.lifecycle:lifecycle-service:2.5.1", - "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1", - "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1", - "androidx.lifecycle:lifecycle-viewmodel:2.5.1", - ], - repositories = [ - "https://maven.google.com", - "https://repo1.maven.org/maven2", - ], -) - ## Android http_archive( @@ -62,9 +18,7 @@ http_archive( load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository") -android_sdk_repository( - name = "androidsdk", -) +android_sdk_repository(name = "androidsdk") ## Kotlin @@ -86,3 +40,4 @@ kotlin_repositories( load("@io_bazel_rules_kotlin//kotlin:core.bzl", "kt_register_toolchains") kt_register_toolchains() + diff --git a/android/ndk/MODULE.bazel b/android/ndk/MODULE.bazel new file mode 100644 index 000000000..8ebec3fb7 --- /dev/null +++ b/android/ndk/MODULE.bazel @@ -0,0 +1,27 @@ +"Bazel dependencies" + +bazel_dep(name = "platforms", version = "0.0.6") +bazel_dep(name = "rules_android", version = "0.1.1") +bazel_dep(name = "rules_jvm_external", version = "5.3") + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + artifacts = [ + "androidx.appcompat:appcompat:1.5.1", + "androidx.constraintlayout:constraintlayout:2.1.4", + # Needed to enforce version conflict resolution + "androidx.savedstate:savedstate:1.2.0", + "androidx.lifecycle:lifecycle-livedata-core:2.5.1", + "androidx.lifecycle:lifecycle-livedata:2.5.1", + "androidx.lifecycle:lifecycle-process:2.5.1", + "androidx.lifecycle:lifecycle-runtime:2.5.1", + "androidx.lifecycle:lifecycle-service:2.5.1", + "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1", + "androidx.lifecycle:lifecycle-viewmodel:2.5.1", + ], + repositories = [ + "https://maven.google.com", + "https://repo1.maven.org/maven2", + ], +) +use_repo(maven, "maven") diff --git a/android/ndk/WORKSPACE b/android/ndk/WORKSPACE index 4bcb0479f..407fa06e7 100644 --- a/android/ndk/WORKSPACE +++ b/android/ndk/WORKSPACE @@ -1,42 +1,5 @@ -# FIXME(alexeagle): move to bzlmod -workspace(name = "bazel_android_sample_project") - load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -## rules_jvm_external - -http_archive( - name = "rules_jvm_external", - sha256 = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca", - strip_prefix = "rules_jvm_external-4.2", - url = "https://github.com/bazelbuild/rules_jvm_external/archive/4.2.zip", -) - -load("@rules_jvm_external//:defs.bzl", "maven_install") - -maven_install( - name = "maven", - artifacts = [ - "androidx.appcompat:appcompat:1.5.1", - "androidx.constraintlayout:constraintlayout:2.1.4", - # Needed to enforce version conflict resolution - "androidx.savedstate:savedstate:1.2.0", - "androidx.lifecycle:lifecycle-livedata-core:2.5.1", - "androidx.lifecycle:lifecycle-livedata:2.5.1", - "androidx.lifecycle:lifecycle-process:2.5.1", - "androidx.lifecycle:lifecycle-runtime:2.5.1", - "androidx.lifecycle:lifecycle-service:2.5.1", - "androidx.lifecycle:lifecycle-viewmodel-savedstate:2.5.1", - "androidx.lifecycle:lifecycle-viewmodel:2.5.1", - ], - repositories = [ - "https://maven.google.com", - "https://repo1.maven.org/maven2", - ], -) - -## Android - http_archive( name = "build_bazel_rules_android", sha256 = "cd06d15dd8bb59926e4d65f9003bfc20f9da4b2519985c27e190cddc8b7a7806", @@ -46,9 +9,7 @@ http_archive( load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository") -android_sdk_repository( - name = "androidsdk", -) +android_sdk_repository(name = "androidsdk") http_archive( name = "rules_android_ndk", @@ -59,6 +20,4 @@ http_archive( load("@rules_android_ndk//:rules.bzl", "android_ndk_repository") -android_ndk_repository( - name = "androidndk", -) +android_ndk_repository(name = "androidndk") diff --git a/android/ndk/app/src/main/BUILD.bazel b/android/ndk/app/src/main/BUILD.bazel index c1c6909d2..697a5d262 100644 --- a/android/ndk/app/src/main/BUILD.bazel +++ b/android/ndk/app/src/main/BUILD.bazel @@ -1,4 +1,4 @@ -load("@build_bazel_rules_android//android:rules.bzl", "android_binary", "android_library") +load("@rules_android//android:rules.bzl", "android_binary", "android_library") load("@rules_cc//cc:defs.bzl", "cc_library") android_library( diff --git a/android/robolectric-testing/MODULE.bazel b/android/robolectric-testing/MODULE.bazel new file mode 100644 index 000000000..3cbb7d9b4 --- /dev/null +++ b/android/robolectric-testing/MODULE.bazel @@ -0,0 +1,23 @@ +"Bazel dependencies" + +bazel_dep(name = "platforms", version = "0.0.6") +bazel_dep(name = "rules_jvm_external", version = "5.3") + +maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven") +maven.install( + artifacts = [ + "org.robolectric:robolectric:4.9", + "junit:junit:4.13.2", + "com.google.truth:truth:1.1.3", + "org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10", + "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10", + "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10", + "org.jetbrains.kotlin:kotlin-stdlib:1.7.10", + ], + repositories = [ + "https://maven.google.com", + "https://repo1.maven.org/maven2", + ], +) + +use_repo(maven, "maven") diff --git a/android/robolectric-testing/WORKSPACE b/android/robolectric-testing/WORKSPACE index c47596f15..5343ada0e 100644 --- a/android/robolectric-testing/WORKSPACE +++ b/android/robolectric-testing/WORKSPACE @@ -3,34 +3,6 @@ workspace(name = "bazel_android_sample_project") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") -## rules_jvm_external - -http_archive( - name = "rules_jvm_external", - sha256 = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca", - strip_prefix = "rules_jvm_external-4.2", - url = "https://github.com/bazelbuild/rules_jvm_external/archive/4.2.zip", -) - -load("@rules_jvm_external//:defs.bzl", "maven_install") - -maven_install( - name = "maven", - artifacts = [ - "org.robolectric:robolectric:4.9", - "junit:junit:4.13.2", - "com.google.truth:truth:1.1.3", - "org.jetbrains.kotlin:kotlin-stdlib-common:1.7.10", - "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.7.10", - "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.7.10", - "org.jetbrains.kotlin:kotlin-stdlib:1.7.10", - ], - repositories = [ - "https://maven.google.com", - "https://repo1.maven.org/maven2", - ], -) - ## Android http_archive( @@ -42,9 +14,7 @@ http_archive( load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository") -android_sdk_repository( - name = "androidsdk", -) +android_sdk_repository(name = "androidsdk") ## Kotlin