Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jetpack Compose example to CI #493

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .bazelci/presubmit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,16 @@ tasks:
build_targets:
- //coroutines-helloworld/...
- //express/...
example-jetpack-compose:
name: "Example - Jetpack Compose"
platform: ubuntu1804
shell_commands:
- "cd ../.. && bazel build //:rules_kotlin_release && rm -rf /tmp/rules_kotlin_release && mkdir -p /tmp/rules_kotlin_release && tar -C /tmp/rules_kotlin_release -xvf bazel-bin/rules_kotlin_release.tgz"
working_directory: examples/jetpack_compose
test_flags:
- "--override_repository=io_bazel_rules_kotlin=/tmp/rules_kotlin_release"
test_targets:
- //...
stardoc:
name: Stardoc api documentation
platform: ubuntu1804
Expand Down
7 changes: 7 additions & 0 deletions examples/jetpack_compose/.bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Enable d8 merger
build --define=android_dexmerger_tool=d8_dexmerger

# Flags for the D8 dexer
build --define=android_incremental_dexing_tool=d8_dexbuilder
build --define=android_standalone_dexing_tool=d8_compat_dx
build --nouse_workers_with_dexbuilder
40 changes: 31 additions & 9 deletions examples/jetpack_compose/WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

_KOTLIN_COMPILER_VERSION = "1.4.21"
_COMPOSE_VERSION = "1.0.0-beta07"

_KOTLIN_COMPILER_VERSION = "1.4.32"

_KOTLIN_COMPILER_SHA = "dfef23bb86bd5f36166d4ec1267c8de53b3827c446d54e82322c6b6daad3594c"

## JVM External

Expand All @@ -22,13 +26,14 @@ load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = [
"org.jetbrains.kotlin:kotlin-stdlib:{}".format(_KOTLIN_COMPILER_VERSION),
"androidx.core:core-ktx:1.3.2",
"androidx.appcompat:appcompat:1.2.0",
"com.google.android.material:material:1.2.1",
"androidx.compose.material:material:1.0.0-alpha09",
"androidx.compose.ui:ui:1.0.0-alpha09",
"androidx.compose.ui:ui-tooling:1.0.0-alpha09",
"androidx.compose.compiler:compiler:1.0.0-alpha09",
"androidx.core:core-ktx:1.5.0",
"androidx.appcompat:appcompat:1.3.0",
"com.google.android.material:material:1.3.0",
"androidx.activity:activity-compose:1.3.0-alpha08",
"androidx.compose.material:material:{}".format(_COMPOSE_VERSION),
"androidx.compose.ui:ui:{}".format(_COMPOSE_VERSION),
"androidx.compose.ui:ui-tooling:{}".format(_COMPOSE_VERSION),
"androidx.compose.compiler:compiler:{}".format(_COMPOSE_VERSION),
],
repositories = [
"https://maven.google.com",
Expand Down Expand Up @@ -121,11 +126,21 @@ http_archive(
],
)

http_archive(
name = "rules_android",
sha256 = _RULES_ANDROID_SHA,
strip_prefix = "rules_android-{}".format(_RULES_ANDROID_VERSION),
urls = [
"https://github.com/bazelbuild/rules_android/archive/v{}.zip".format(_RULES_ANDROID_VERSION),
],
)

load("@build_bazel_rules_android//android:rules.bzl", "android_sdk_repository")

android_sdk_repository(
name = "androidsdk",
api_level = 29,
build_tools_version = "30.0.1",
)

## Kotlin
Expand All @@ -141,6 +156,13 @@ kt_download_local_dev_dependencies()

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

kotlin_repositories()
kotlin_repositories(
compiler_release = {
"sha256": _KOTLIN_COMPILER_SHA,
"urls": [
"https://github.com/JetBrains/kotlin/releases/download/v{}/kotlin-compiler-{}.zip".format(_KOTLIN_COMPILER_VERSION, _KOTLIN_COMPILER_VERSION),
],
},
)

register_toolchains("//:kotlin_toolchain")
8 changes: 8 additions & 0 deletions examples/jetpack_compose/compose-app/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@build_bazel_rules_android//android:rules.bzl", "android_binary")
load("@bazel_skylib//rules:build_test.bzl", "build_test")

# An app that consumes android-kt deps
android_binary(
Expand All @@ -12,3 +13,10 @@ android_binary(
"//compose-ui:lib",
],
)

build_test(
name = "force_build_apks_test",
targets = [
":compose_example_app",
],
)
1 change: 1 addition & 0 deletions examples/jetpack_compose/compose-ui/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ kt_android_library(
plugins = ["//:jetpack_compose_compiler_plugin"],
visibility = ["//visibility:public"],
deps = [
"@maven//:androidx_activity_activity_compose",
"@maven//:androidx_appcompat_appcompat",
"@maven//:androidx_compose_material_material",
"@maven//:androidx_compose_ui_ui",
Expand Down
2 changes: 1 addition & 1 deletion examples/jetpack_compose/compose-ui/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package cm.ben.android.bazel.compose.example.ui

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.appcompat.app.AppCompatActivity
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.setContent

class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
Expand Down