-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Move the Java tools deploy jars refrences to checked-in deploy jars #7114
Conversation
@lberki PTAL. If/when this looks OK to you I'll do the same for the other deploy jars in JAVA_TOOLS. |
@lberki I updated all the deploy jars defined in src/BUILD in the embedded_tools filegroup (defined by JAVA_TOOLS). The remaining targets in JAVA_TOOLS require a bit more work and I'll do take care of them separately in new PRs. |
@lberki This PR is ready for review now, PTAL! Thanks! |
third_party/BUILD
Outdated
name = "java_tools", | ||
srcs = glob( | ||
["java/java_tools/*.jar"], | ||
exclude = ["java/java_tools/SingleJar_deploy.jar"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change will need to be split (to a Git-on-Borg and a Google internal part). (But it's easier to review in one piece!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does it need to be split?
@@ -0,0 +1,83 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: how about adding -eu
: -e
makes the shell exit early if a command returns a non-zero exit code and -u
makes using undeclared variables an error (one less opportunity for typos!)
If you want to be fancy, you can also add -x
that makes bash print every command it executes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add any of those because:
-
-e
because I still want to update some of the tools even if the others didn't build. I find it easier to debug if we keep the errors and print them at the end -
-u
because I get an error of$1
not being declared when I check if it equals "help", even though I do this check only after checking that $1 is not empty -
x
because bazel already pollutes the output a lot, by looking at it is more than enough
Let me know if you think otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a second thought, I added -e
. It can be more helpful to exit at the first error and not scroll through the whole log. 😆
local bazel_target="${1}"; shift | ||
local binary=$(echo "bazel-bin/$bazel_target" | sed 's@:@/@') | ||
|
||
bazel build "$bazel_target" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: how about issuing a single Bazel invocation that builds every tool? It's presumably faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each invocation is ~0.1s, do we need to speed it up? This script is meant to be run manually and anything under a few seconds is the same IMO. Having them separately allows printing more useful error messages and following all the logic for one build in the same place.
|
||
} | ||
|
||
for tool in "${tools_to_update[@]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opt: bash associative arrays are scary. How about simply
function process() {
bazel build $2
cp ... ...
}
process SingleJar src/java_tools/singlejar/java/com/google/devtools/build/singlejar:bazel-singlejar_deploy.jar
process GenClass rc/java_tools/buildjar/java/com/google/devtools/build/buildjar/genclass:GenClass_deploy.jar
More repetitive, but also more readable for mere mortals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, this is exactly the way I started the script! However, it ended up having too much repetition especially because I wanted to be able to print the usage. Doing it this way requires repetition 3 times, and every time one of the targets or tool name changes we have to update the other 2 as well. I updated the documentation, does it make it more readable? I really want to avoid copying all these strings everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be OK with slightly worse usage text if it makes the script simpler.
@@ -115,43 +115,47 @@ py_binary( | |||
deps = [":create_embedded_tools_lib"], | |||
) | |||
|
|||
# The tools Bazel uses to compile Java. | |||
# TODO(iirina): Gradually remove the targets here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer TODO(<bug>)
|
||
} | ||
|
||
for tool in "${tools_to_update[@]}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be OK with slightly worse usage text if it makes the script simpler.
To see how to update the tools run: | ||
|
||
``` | ||
./third_party/java/java_tools/update_java_tools.sh help |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When do we expect this script to be run? i.e. as part of the release process, or on-demand, or something else?
instead of embedding the deploy jars built at the same time with the bazel binary. This comes in preparation for moving the Java tools to remote repositories (see bazelbuild#6316). Moving the tools happens in two phases: 1. Using checked-in deploy jars/binaries instead of those built when bazel was built 2. Moving the checked-in jars/binaries to a remote repository and make bazel reference them from there. This step can only happen under an incompatible flag. This PR addresses the first point. Doing the move incrementally this way is safer and allows finding bugs earlier. It also allows moving the Java tools code base out of the bazel repository. We are making this change gradually for each java tool defined in JAVA_TOOLS (found in src/BUILD). Closes bazelbuild#7114. PiperOrigin-RevId: 229524951
instead of embedding the deploy jars built at the same time with the bazel binary.
This comes in preparation for moving the Java tools to remote repositories (see #6316).
Moving the tools happens in two phases:
This PR addresses the first point. Doing the move incrementally this way is safer and allows finding bugs earlier. It also allows moving the Java tools code base out of the bazel repository.
We are making this change gradually for each java tool defined in JAVA_TOOLS (found in src/BUILD).