aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorRomain Jobredeaux <jobredeaux@google.com>2021-08-05 20:52:03 +0000
committerRomain Jobredeaux <jobredeaux@google.com>2021-08-10 13:58:03 +0000
commiteda68acb745c3b9d06274dff5c9cb90bc1332c55 (patch)
tree1f91c41187f2498adbd9d1a0eb61aa193994f9cf /examples
parent178a26e7d037a9963394350772d2871f48a7bfd4 (diff)
downloadbazel-eda68acb745c3b9d06274dff5c9cb90bc1332c55.tar.gz
Add a java binary, a java library, and an android app target building to bp2build ci.
Excluding cc jni targets as they currently don't compile (but the app does). Adding the --fat_apk_cpu=k8 flag to common.bazelrc as it only applies to android app building rules, and it is currently required to successfully build them. Forcing the use of the checked in Java JDK to avoid falling back to the local machine's JDK. Test: ./build/bazel/ci/bp2build.sh runs successfully Change-Id: I0f107d334f00c6ac7d91396a70c5023e48b6742b Bug: 195786204 Bug: 195786195 Bug: 194639753
Diffstat (limited to 'examples')
-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
4 files changed, 39 insertions, 11 deletions
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!";
+ }
+}