Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Commit

Permalink
Set the correct main class on the desugar java_binary target in Bazel.
Browse files Browse the repository at this point in the history
This will make it easier to build the desugarer tool from the Bazel source tree as an executable (deploy) jar and then use it for something else.

For example, with this CL, you can do the following steps to get a standalone
desugarer binary:

1. git clone https://github.com/bazelbuild/bazel
2. bazel build //src/tools/android/java/com/google/devtools/build/android/desugar:desugar_bin_deploy.jar
3. cp bazel-bin/src/tools/android/java/com/google/devtools/build/android/desugar/desugar_bin_deploy.jar ~/bin/desugar.jar

And then you can invoke desugar without bazel with `java -jar ~/bin/desugar.jar`.

bazelbuild#2975

RELNOTES: None
PiperOrigin-RevId: 155629711
  • Loading branch information
aj-michael authored and kchodorow committed May 10, 2017
1 parent 889bbe5 commit 20824c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ filegroup(
name = "embedded_tools",
srcs = [
"BUILD.tools",
"desugar_bin_deploy.jar",
"Desugar_deploy.jar",
],
visibility = ["//src/tools/android/java/com/google/devtools/build/android:__pkg__"],
)
Expand All @@ -28,8 +28,8 @@ java_library(
)

java_binary(
name = "desugar_bin",
main_class = "does.not.exist",
name = "Desugar",
main_class = "com.google.devtools.build.android.desugar.Desugar",
runtime_deps = [":desugar"],
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package(default_visibility = ["//visibility:public"])

# This target is named "Desugar_embedded" instead of "Desugar" so as to avoid
# a naming conflict with the existing Desugar_deploy.jar that it depends on.
java_binary(
name = "Desugar",
name = "Desugar_embedded",
main_class = "com.google.devtools.build.android.desugar.Desugar",
runtime_deps = [":desugar_bin_deploy.jar"],
)
runtime_deps = [":Desugar_deploy.jar"],
)
2 changes: 1 addition & 1 deletion tools/android/BUILD.tools
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ alias(

alias(
name = "desugar_java8",
actual = "//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar",
actual = "//src/tools/android/java/com/google/devtools/build/android/desugar:Desugar_embedded",
)

# Bazel puts this on the bootclasspath of android_* targets to support Java 8
Expand Down

0 comments on commit 20824c1

Please sign in to comment.