From 7562088a92cdb20cccb99b996c1c147b0773e60a Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 23 Mar 2023 16:22:25 +0000 Subject: [PATCH 1/9] Add platform-specific selects --- java/example/simple/BUILD.bazel | 15 +++++++++++++-- java/example/simple/LinuxDep.java | 5 +++++ java/example/simple/SimpleLinux.java | 7 +++++++ 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 java/example/simple/LinuxDep.java create mode 100644 java/example/simple/SimpleLinux.java diff --git a/java/example/simple/BUILD.bazel b/java/example/simple/BUILD.bazel index 65d9e7e..5d3c185 100644 --- a/java/example/simple/BUILD.bazel +++ b/java/example/simple/BUILD.bazel @@ -2,8 +2,14 @@ load("//rules:simple_java_library.bzl", "simple_java_library") simple_java_library( name = "simple", - src = "Simple.java", - deps = [":simple_dep"], + src = select({ + "@platforms//os:linux": "SimpleLinux.java", + "//conditions:default": "Simple.java", + }), + deps = select({ + "@platforms//os:linux": [":simple_dep_linux"], + "//conditions:default": [":simple_dep"], + }), visibility = ["//visibility:public"], ) @@ -11,3 +17,8 @@ simple_java_library( name = "simple_dep", src = "Dep.java", ) + +simple_java_library( + name = "simple_dep_linux", + src = "LinuxDep.java", +) diff --git a/java/example/simple/LinuxDep.java b/java/example/simple/LinuxDep.java new file mode 100644 index 0000000..3d2b729 --- /dev/null +++ b/java/example/simple/LinuxDep.java @@ -0,0 +1,5 @@ +package example.simple; + +public class LinuxDep { + public static final String NAME = "LinuxDep"; +} diff --git a/java/example/simple/SimpleLinux.java b/java/example/simple/SimpleLinux.java new file mode 100644 index 0000000..4294a08 --- /dev/null +++ b/java/example/simple/SimpleLinux.java @@ -0,0 +1,7 @@ +package example.simple; + +public class SimpleLinux { + public static String description() { + return String.format("I am a simple class named SimpleLinux, and I know about %s", LinuxDep.NAME); + } +} From c5a9f0ad1fc7fc9c3dd31fd904fcc97a55bd2fce Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 23 Mar 2023 17:27:01 +0000 Subject: [PATCH 2/9] Change linux dep --- java/example/simple/LinuxDep.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/example/simple/LinuxDep.java b/java/example/simple/LinuxDep.java index 3d2b729..fe099bf 100644 --- a/java/example/simple/LinuxDep.java +++ b/java/example/simple/LinuxDep.java @@ -1,5 +1,5 @@ package example.simple; public class LinuxDep { - public static final String NAME = "LinuxDep"; + public static final String NAME = "LinuxDep - changed"; } From 34998f83c18ae24419dd628406da1f2646ee0e9a Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 23 Mar 2023 17:27:05 +0000 Subject: [PATCH 3/9] Revert "Change linux dep" This reverts commit c5a9f0ad1fc7fc9c3dd31fd904fcc97a55bd2fce. --- java/example/simple/LinuxDep.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/example/simple/LinuxDep.java b/java/example/simple/LinuxDep.java index fe099bf..3d2b729 100644 --- a/java/example/simple/LinuxDep.java +++ b/java/example/simple/LinuxDep.java @@ -1,5 +1,5 @@ package example.simple; public class LinuxDep { - public static final String NAME = "LinuxDep - changed"; + public static final String NAME = "LinuxDep"; } From cf576d11d53172fd95899c86a5a21268bb5a3d5e Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 23 Mar 2023 17:27:20 +0000 Subject: [PATCH 4/9] Change non-linux dep --- java/example/simple/Dep.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/example/simple/Dep.java b/java/example/simple/Dep.java index 34254dd..a95c620 100644 --- a/java/example/simple/Dep.java +++ b/java/example/simple/Dep.java @@ -1,5 +1,5 @@ package example.simple; public class Dep { - public static final String NAME = "Dep"; + public static final String NAME = "Dep - non-linux"; } From d06538bf48b552296d9fb6c5a19ae295ab44f97b Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 23 Mar 2023 17:27:22 +0000 Subject: [PATCH 5/9] Revert "Change non-linux dep" This reverts commit cf576d11d53172fd95899c86a5a21268bb5a3d5e. --- java/example/simple/Dep.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/example/simple/Dep.java b/java/example/simple/Dep.java index a95c620..34254dd 100644 --- a/java/example/simple/Dep.java +++ b/java/example/simple/Dep.java @@ -1,5 +1,5 @@ package example.simple; public class Dep { - public static final String NAME = "Dep - non-linux"; + public static final String NAME = "Dep"; } From 9aac49274c8e79be8b50e28bc028e44c022476ef Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 23 Mar 2023 17:27:40 +0000 Subject: [PATCH 6/9] Change non-linux src --- java/example/simple/Simple.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/example/simple/Simple.java b/java/example/simple/Simple.java index 8de0c47..a9f5bf8 100644 --- a/java/example/simple/Simple.java +++ b/java/example/simple/Simple.java @@ -2,6 +2,6 @@ public class Simple { public static String description() { - return String.format("I am a simple class named Simple, and I know about %s", Dep.NAME); + return String.format("I am a simple class named Simple, and I know about %s - changed", Dep.NAME); } } From 4d6a965d21f75921f13a0796c9274d839db75ff0 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 23 Mar 2023 17:27:43 +0000 Subject: [PATCH 7/9] Revert "Change non-linux src" This reverts commit 9aac49274c8e79be8b50e28bc028e44c022476ef. --- java/example/simple/Simple.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/example/simple/Simple.java b/java/example/simple/Simple.java index a9f5bf8..8de0c47 100644 --- a/java/example/simple/Simple.java +++ b/java/example/simple/Simple.java @@ -2,6 +2,6 @@ public class Simple { public static String description() { - return String.format("I am a simple class named Simple, and I know about %s - changed", Dep.NAME); + return String.format("I am a simple class named Simple, and I know about %s", Dep.NAME); } } From 2b52614c2eabb5c62f81dac6d9d3b37240258996 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 23 Mar 2023 17:27:55 +0000 Subject: [PATCH 8/9] Change linux src --- java/example/simple/SimpleLinux.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/example/simple/SimpleLinux.java b/java/example/simple/SimpleLinux.java index 4294a08..fa01d51 100644 --- a/java/example/simple/SimpleLinux.java +++ b/java/example/simple/SimpleLinux.java @@ -2,6 +2,6 @@ public class SimpleLinux { public static String description() { - return String.format("I am a simple class named SimpleLinux, and I know about %s", LinuxDep.NAME); + return String.format("I am a simple class named SimpleLinux, and I know about %s - changed", LinuxDep.NAME); } } From 31eefd46e77d32bd27926080ed99f8e1dc44b6cc Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 23 Mar 2023 17:27:57 +0000 Subject: [PATCH 9/9] Revert "Change linux src" This reverts commit 2b52614c2eabb5c62f81dac6d9d3b37240258996. --- java/example/simple/SimpleLinux.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/example/simple/SimpleLinux.java b/java/example/simple/SimpleLinux.java index fa01d51..4294a08 100644 --- a/java/example/simple/SimpleLinux.java +++ b/java/example/simple/SimpleLinux.java @@ -2,6 +2,6 @@ public class SimpleLinux { public static String description() { - return String.format("I am a simple class named SimpleLinux, and I know about %s - changed", LinuxDep.NAME); + return String.format("I am a simple class named SimpleLinux, and I know about %s", LinuxDep.NAME); } }