aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bazel.WORKSPACE3
-rwxr-xr-xci/bp2build.sh5
-rw-r--r--common.bazelrc6
-rw-r--r--examples/android_app/java/com/app/BUILD22
-rw-r--r--examples/java/com/bazel/BUILD.bazel11
-rw-r--r--examples/java/com/bazel/example/HelloWorld.java10
-rw-r--r--examples/java/com/bazel/example_lib/HelloLib.java7
7 files changed, 50 insertions, 14 deletions
diff --git a/bazel.WORKSPACE b/bazel.WORKSPACE
index e828894d..e135ec3b 100644
--- a/bazel.WORKSPACE
+++ b/bazel.WORKSPACE
@@ -33,6 +33,9 @@ register_toolchains(
# For native android_binary
"//prebuilts/sdk:android_sdk_tools_for_native_android_binary",
+
+ # Local AOSP JDK
+ "//prebuilts/jdk/jdk11/linux-x86:jdk11_toolchain",
)
bind(
diff --git a/ci/bp2build.sh b/ci/bp2build.sh
index 55a55b31..e62163a6 100755
--- a/ci/bp2build.sh
+++ b/ci/bp2build.sh
@@ -41,8 +41,9 @@ BUILD_TARGETS_LIST=(
//prebuilts/clang/host/linux-x86:all
//build/bazel/...
--
- # TODO(b/194639753): remove once android_app builds
- -//build/bazel/examples/android_app/...
+ # TODO(b/194639753): remove once android_app cc targets build
+ -//build/bazel/examples/android_app/java/com/app:jni
+ -//build/bazel/examples/android_app/java/com/app:jni_dep
)
BUILD_TARGETS="${BUILD_TARGETS_LIST[@]}"
tools/bazel --max_idle_secs=5 build ${BUILD_FLAGS} --platforms //build/bazel/platforms:android_x86 -k ${BUILD_TARGETS}
diff --git a/common.bazelrc b/common.bazelrc
index fad3990e..db339881 100644
--- a/common.bazelrc
+++ b/common.bazelrc
@@ -7,7 +7,7 @@ build --platforms //build/bazel/platforms:android_arm
build --incompatible_enable_cc_toolchain_resolution
# Ensure that the host_javabase always use @local_jdk, the checked-in JDK.
-build --tool_java_runtime_version=local_jdk
+build --tool_java_runtime_version=jdk11
# Lock down the PATH variable in actions to /usr/bin and /usr/local/bin.
build --experimental_strict_action_env
@@ -72,6 +72,7 @@ build --experimental_android_databinding_v2
build --define=android_incremental_dexing_tool=d8_dexbuilder
build --define=android_dexmerger_tool=d8_dexmerger
build --nouse_workers_with_dexbuilder
+build --fat_apk_cpu=k8
# Developer instance for result storage. This only works if you have access
# to the Bazel GCP project. Follow the GCP gcloud client's auth instructions to
@@ -84,3 +85,6 @@ build:results --test_summary=detailed
build:results --bes_backend=buildeventservice.googleapis.com
build:results --bes_results_url=https://source.cloud.google.com/results/invocations
build:results --show_progress_rate_limit=5
+
+# Use JDK11 that's checked into AOSP for building
+build --java_runtime_version=jdk11
diff --git a/examples/android_app/java/com/app/BUILD b/examples/android_app/java/com/app/BUILD
index 5f70697e..f80585a7 100644
--- a/examples/android_app/java/com/app/BUILD
+++ b/examples/android_app/java/com/app/BUILD
@@ -9,17 +9,17 @@ android_binary(
)
android_library(
- name = "applib",
- srcs = [
- "MainActivity.java",
- #"Jni.java", # TODO: integrate JNI
- ],
- resource_files = glob(["res/**"]),
- manifest = "AndroidManifest.xml",
- deps = [
- ":lib",
- #":jni", # TODO: integrate JNI
- ]
+ name = "applib",
+ srcs = [
+ "MainActivity.java",
+ #"Jni.java", # TODO: integrate JNI
+ ],
+ manifest = "AndroidManifest.xml",
+ resource_files = glob(["res/**"]),
+ deps = [
+ ":lib",
+ #":jni", # TODO: integrate JNI
+ ],
)
android_library(
diff --git a/examples/java/com/bazel/BUILD.bazel b/examples/java/com/bazel/BUILD.bazel
new file mode 100644
index 00000000..6f96f9d3
--- /dev/null
+++ b/examples/java/com/bazel/BUILD.bazel
@@ -0,0 +1,11 @@
+java_binary(
+ name = "hello_java",
+ srcs = ["example/HelloWorld.java"],
+ main_class = "com.bazel.example.HelloWorld",
+ deps = [":hello_java_lib"],
+)
+
+java_library(
+ name = "hello_java_lib",
+ srcs = ["example_lib/HelloLib.java"],
+)
diff --git a/examples/java/com/bazel/example/HelloWorld.java b/examples/java/com/bazel/example/HelloWorld.java
new file mode 100644
index 00000000..d74bb89b
--- /dev/null
+++ b/examples/java/com/bazel/example/HelloWorld.java
@@ -0,0 +1,10 @@
+package com.bazel.example;
+
+import com.bazel.example_lib.HelloLib;
+
+public class HelloWorld {
+ public static void main(String[] args) {
+ System.out.println("Hello world!");
+ System.out.println("Library says: " + HelloLib.libValue());
+ }
+}
diff --git a/examples/java/com/bazel/example_lib/HelloLib.java b/examples/java/com/bazel/example_lib/HelloLib.java
new file mode 100644
index 00000000..8937060b
--- /dev/null
+++ b/examples/java/com/bazel/example_lib/HelloLib.java
@@ -0,0 +1,7 @@
+package com.bazel.example_lib;
+
+public class HelloLib {
+ public static String libValue() {
+ return "Hello Library!";
+ }
+}