Skip to content
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 tools required for Java builds (JavaBuilder, ijar, singlejar etc.) to remote repository #6316

Closed
meisterT opened this issue Oct 5, 2018 · 10 comments
Assignees
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules

Comments

@meisterT
Copy link
Member

meisterT commented Oct 5, 2018

Part of https://docs.google.com/document/d/1Igmv-2GfXkoVFWTXvBYPeniQom8nLAwzqzridDlBIS4/edit?ts=5babff11#heading=h.wg6xrnp53jla and the logical next step after #6313.

That's also a good step in the direction to have different JavaBuilder versions for different versions of the JDK.

@meisterT meisterT added this to the shrinking the bazel binary milestone Oct 5, 2018
@meisterT meisterT self-assigned this Oct 5, 2018
@cushon
Copy link
Contributor

cushon commented Oct 5, 2018

For Java-based tools that are distributed as jars (JavaBuilder, turbine, javac) the remote repo can just contain deploy jars, right? But for ijar and singlejar it will need sources since those tools are currently build from source during the build?

Will this involve moving the sources for these tools out of the main Bazel repo and into a separate repository, or is it sufficient to leave the sources where they are and publish release artifacts somewhere so they can be used as a remote repo?

@jin jin added team-Performance Issues for Performance teams untriaged labels Oct 6, 2018
@meisterT
Copy link
Member Author

We still have to publish the srcs along with the release artifacts for licensing reasons if I'm not mistaken.

@cushon
Copy link
Contributor

cushon commented Oct 11, 2018

Right, but an archive of the sources could be published to mirror.bazel.build, that doesn't necessarily require that the development happen in a separate repository.

I don't think it'll make too much of difference to copybara, I was just curious what the plan is.

@nlopezgi
Copy link
Contributor

For remote execution having either sources (preferable) or platform agnostic binaries will be necessary. Specifically for tools like SingleJar and ijar the sources must be available for projects to compile them for the execution platform as part of a remote build.

@meisterT meisterT added P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules and removed untriaged labels Nov 29, 2018
bazel-io pushed a commit that referenced this issue Jan 16, 2019
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:
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 #7114.

PiperOrigin-RevId: 229524951
iirina added a commit to iirina/bazel that referenced this issue Jan 16, 2019
instead of embedding the deploy jar that is built when the bazel binary is built.

This comes in preparation for moving the Java tools to remote repositories (see bazelbuild#6316). This checked in jar will be moved to a remote repository and referenced from there.

Moving the Java tools happens in two phases:

Using checked-in deploy jars/binaries instead of those built when bazel was built
Moving the checked-in jars/binaries to a remote repository and make bazel reference them from there.
This PR addresses the first point for JarJar. 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).
iirina added a commit to iirina/bazel that referenced this issue Jan 16, 2019
This comes in preparation for moving the Java tools to remote repositories (see bazelbuild#6316). This checked in jar will be moved to a remote repository and referenced from there.

Moving the Java tools happens in two phases:

Using checked-in deploy jars/binaries instead of those built when bazel was built
Moving the checked-in jars/binaries to a remote repository and make bazel reference them from there.
This PR addresses the first point for JarJar. 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).
bazel-io pushed a commit that referenced this issue Jan 16, 2019
This comes in preparation for moving the Java tools to remote repositories (see #6316). This checked in jar will be moved to a remote repository and referenced from there.

Moving the Java tools happens in two phases:

Using checked-in deploy jars/binaries instead of those built when bazel was built
Moving the checked-in jars/binaries to a remote repository and make bazel reference them from there.
This PR addresses the first point for JarJar. 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).

Partial commit for third_party/*, see #7145.

Signed-off-by: iirina <elenairina@google.com>
bazel-io pushed a commit that referenced this issue Jan 16, 2019
instead of embedding the deploy jar that is built when the bazel binary is built.

This comes in preparation for moving the Java tools to remote repositories (see #6316). This checked in jar will be moved to a remote repository and referenced from there.

Moving the Java tools happens in two phases:

Using checked-in deploy jars/binaries instead of those built when bazel was built
Moving the checked-in jars/binaries to a remote repository and make bazel reference them from there.
This PR addresses the first point for `JarJar`. 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 #7143.

PiperOrigin-RevId: 229548071
bazel-io pushed a commit that referenced this issue Jan 21, 2019
…t java_toolchain and host_java_toolchain.

This PR introduces the flags:
* `--incompatible_use_remote_host_java_toolchain`
*  `--incompatible_use_remote_java_toolchain`

Progress on #6316 #7196 #7197

Closes #7156.

PiperOrigin-RevId: 230209934
weixiao-huang pushed a commit to weixiao-huang/bazel that referenced this issue Jan 31, 2019
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
weixiao-huang pushed a commit to weixiao-huang/bazel that referenced this issue Jan 31, 2019
This comes in preparation for moving the Java tools to remote repositories (see bazelbuild#6316). This checked in jar will be moved to a remote repository and referenced from there.

Moving the Java tools happens in two phases:

Using checked-in deploy jars/binaries instead of those built when bazel was built
Moving the checked-in jars/binaries to a remote repository and make bazel reference them from there.
This PR addresses the first point for JarJar. 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).

Partial commit for third_party/*, see bazelbuild#7145.

Signed-off-by: iirina <elenairina@google.com>
weixiao-huang pushed a commit to weixiao-huang/bazel that referenced this issue Jan 31, 2019
instead of embedding the deploy jar that is built when the bazel binary is built.

This comes in preparation for moving the Java tools to remote repositories (see bazelbuild#6316). This checked in jar will be moved to a remote repository and referenced from there.

Moving the Java tools happens in two phases:

Using checked-in deploy jars/binaries instead of those built when bazel was built
Moving the checked-in jars/binaries to a remote repository and make bazel reference them from there.
This PR addresses the first point for `JarJar`. 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#7143.

PiperOrigin-RevId: 229548071
weixiao-huang pushed a commit to weixiao-huang/bazel that referenced this issue Jan 31, 2019
…t java_toolchain and host_java_toolchain.

This PR introduces the flags:
* `--incompatible_use_remote_host_java_toolchain`
*  `--incompatible_use_remote_java_toolchain`

Progress on bazelbuild#6316 bazelbuild#7196 bazelbuild#7197

Closes bazelbuild#7156.

PiperOrigin-RevId: 230209934
bazel-io pushed a commit that referenced this issue Feb 3, 2019
Transitively this pulls in skydoc which pulls in other large deps, so this is one step closer to a smaller bazel binary, see #6316.

RELNOTES: None
PiperOrigin-RevId: 232215895
@dslomov
Copy link
Contributor

dslomov commented Feb 15, 2019

Please do not assign issues to more than one team

@dslomov dslomov removed the team-Performance Issues for Performance teams label Feb 15, 2019
bazel-io pushed a commit that referenced this issue Feb 21, 2019
The flags that enable using remote Java tools by default were pushed in 4d935d5.

This PR shrinks the bazel binary by ~25%.

To measure the binary sizes I used `bazel build -c opt //src:bazel` at a57c879 with and without the changes in this PR:

```
$ ls -lh ~/bazel-with-java-tools | awk '{print $5}'
141M
$ ls -lh ~/bazel-no-java-tools | awk '{print $5}'
105M
```

Progress on #6316.

Closes #7472.

PiperOrigin-RevId: 234972713
bazel-io pushed a commit that referenced this issue Feb 21, 2019
This was part of #7472 but was reverted by mistake by 9192ee3

The bazel binary gets down to 94M. 😃

Progress on #6316.

Closes #7492.

PiperOrigin-RevId: 235003109
bazel-io pushed a commit that referenced this issue Feb 22, 2019
Commit c33ae8a removed some targets and replaced them with targets called "remote-X". This PR adds back the initial targets but now referencing remote tools.

Progress on #6316.

Closes #7506.

PiperOrigin-RevId: 235174166
@iirina
Copy link
Contributor

iirina commented Mar 1, 2019

Update: all tools except singlejar and ijar (sources) have been removed, reducing the bazel binary size by 33%.

bazel-io pushed a commit that referenced this issue Mar 12, 2019
Progress on #6316.

Partial merge of #7659.

PiperOrigin-RevId: 237969861
bazel-io pushed a commit that referenced this issue Mar 12, 2019
`BUILD-new.pkg` was added as an intermediate BUILD.pkg file in order to facilitate a new data structure in the remote tools archive. It is not longer needed.

Progress on #6316.

Closes #7694.

PiperOrigin-RevId: 238002273
bazel-io pushed a commit that referenced this issue Mar 12, 2019
…Java tools archive

Progress on #6316.

Closes #7696.

PiperOrigin-RevId: 238018531
bazel-io pushed a commit that referenced this issue Mar 15, 2019
Bazel now doesn't embed ijar anymore and uses ijar embeded in the Java tools remote repository.

Bazel embedded both ijar's source code (required by remote execution) and platform specific pre-built binaries. This change adds platform specific remote Java tools repository that include the corresponding pre-built ijar binary (for Windows, Darwin and Linux), alongside ijar's source code.

This change introduces a collection of macros that wrap the native rules `filegroup` and `java_import` and select a given target from the external java tools repository based on the current platform.

Progress on #6316.

Closes #7665.

PiperOrigin-RevId: 238613298
@ghost
Copy link

ghost commented Apr 11, 2019

Just discovered this change after trying to rev our builds to 0.24.0. This is causing some trouble for CI instances w/o access to the public internet, because they now need to reach out to mirror.bazel.build to locate turbine, singlejar, et al. Additionally, I peeked into the java_tools_pkg archive, and it contains naked jars but w/o any indication of their provenance, how to rebuild them from source, etc etc.

What is the Bazel team's recommendation? Ideally I would prefer to continue embedding these binaries with our Bazel distribution, but if a remote repo is the only option, I at least need to be able to build all the tools myself and host them internally. (I.e. maybe I have to maintain my own internal java_tools_pkg build process, and then I patch my internal copy's URL into src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE.)

@iirina
Copy link
Contributor

iirina commented Apr 12, 2019

We are still working on a good way to pass your own built archive. We currently host archives with their sources on mirror.bazel.build but only for licensing purposes and without the BUILD files to be able to rebuild the tools from source.

Until we have a better solution you can do the following:

  • checkout the bazel repo locally
  • build the archive by running bazel build //src:java_tools_zip
  • upload bazel-bin/src/java_tools.zip on the CI instances
  • pass --distdir=path_to_java_tools_zip when you run bazel on your CI

--distdir specifies places to search for archives before accessing the network to download them, so you won't need to modify the jdk.WORKSPACE file.

@ghost
Copy link

ghost commented Apr 12, 2019

We are still working on a good way to pass your own built archive. We currently host archives with their sources on mirror.bazel.build but only for licensing purposes and without the BUILD files to be able to rebuild the tools from source.

Until we have a better solution you can do the following:

  • checkout the bazel repo locally
  • build the archive by running bazel build //src:java_tools_zip
  • upload bazel-bin/src/java_tools.zip on the CI instances
  • pass --distdir=path_to_java_tools_zip when you run bazel on your CI

--distdir specifies places to search for archives before accessing the network to download them, so you won't need to modify the jdk.WORKSPACE file.

Gotcha. Thanks for the follow-up!

I backported some of your changes to 0.24.0 so that I can build the Java tools locally. So, that much is good. However, --distdir isn't as straightforward I hoped, because the locally built archive's SHA256 needs to match the checksum recorded in jdk.WORKSPACE. We're using custom builds of Bazel anyway, so patching jdk.WORKSPACE really isn't a problem for us. (We'll just carry forward similar patches against that file as we do Bazel's top-level WORKSPACE to repoint to internal mirrors instead of reaching out to github.com, mirror.bazel.build, etc.)

As for long-term maintenance, could the Java tools team please look into publishing build instructions, release information, etc. with each remote_java_tools_foo archive bump so that users can maintain their own packages? Like, I have no idea what commit java_tools_javac10_linux-x86_64-v2.1.zip corresponds to, so even with the instructions provided above I still don't know how exactly to recreate the same zip.

@iirina
Copy link
Contributor

iirina commented Apr 15, 2019

As for long-term maintenance, could the Java tools team please look into publishing build instructions, release information, etc. with each remote_java_tools_foo archive bump so that users can maintain their own packages?

Yes, definitely. We'll get onto this ASAP. The cleaner path forward is to publish releases with the source files + the associated BUILD files, so that anyone can just build the tools from a published source release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules
Projects
None yet
Development

No branches or pull requests

6 participants