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

Java rules should be able to build tree artifacts in their sources #11996

Open
AutomatedTester opened this issue Aug 22, 2020 · 6 comments · May be fixed by #22229
Open

Java rules should be able to build tree artifacts in their sources #11996

AutomatedTester opened this issue Aug 22, 2020 · 6 comments · May be fixed by #22229
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules type: bug

Comments

@AutomatedTester
Copy link

Description of the problem / feature request:

Java_library rules does not know how to interpret TreeArtifact that react_scripts

Feature requests: what underlying problem are you trying to solve with this feature?

I was trying to bundle a React site in a Java Jar for deployment. See question asked on Slack

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Revert this change and add resources = [ "//javascript/grid-ui:build" ]. The contents on the :build are not in the jar.

What operating system are you running Bazel on?

OSX and Linux

What's the output of bazel info release?

davidburns in ~/development/selenium on trunk λ bazel info
bazel-bin: /private/var/tmp/_bazel_davidburns/ee760a273fbaa30310e4e04981835b81/execroot/selenium/bazel-out/darwin-fastbuild/bin
bazel-genfiles: /private/var/tmp/_bazel_davidburns/ee760a273fbaa30310e4e04981835b81/execroot/selenium/bazel-out/darwin-fastbuild/bin
bazel-testlogs: /private/var/tmp/_bazel_davidburns/ee760a273fbaa30310e4e04981835b81/execroot/selenium/bazel-out/darwin-fastbuild/testlogs
character-encoding: file.encoding = ISO-8859-1, defaultCharset = ISO-8859-1
command_log: /private/var/tmp/_bazel_davidburns/ee760a273fbaa30310e4e04981835b81/command.log
committed-heap-size: 1142MB
execution_root: /private/var/tmp/_bazel_davidburns/ee760a273fbaa30310e4e04981835b81/execroot/selenium
gc-count: 432
gc-time: 60770ms
install_base: /var/tmp/_bazel_davidburns/install/3f6b57c2e011992922afe70680fb9546
java-home: /private/var/tmp/_bazel_davidburns/install/3f6b57c2e011992922afe70680fb9546/embedded_tools/jdk
java-runtime: OpenJDK Runtime Environment (build 11.0.6+10-LTS) by Azul Systems, Inc.
java-vm: OpenJDK 64-Bit Server VM (build 11.0.6+10-LTS, mixed mode) by Azul Systems, Inc.
max-heap-size: 2147MB
output_base: /private/var/tmp/_bazel_davidburns/ee760a273fbaa30310e4e04981835b81
output_path: /private/var/tmp/_bazel_davidburns/ee760a273fbaa30310e4e04981835b81/execroot/selenium/bazel-out
package_path: %workspace%
release: release 3.4.1
repository_cache: /var/tmp/_bazel_davidburns/cache/repos/v1
server_log: /private/var/tmp/_bazel_davidburns/ee760a273fbaa30310e4e04981835b81/java.log.davids-macbook-pro.davidburns.log.java.20200819-213313.43194
server_pid: 43194
used-heap-size: 535MB
workspace: /Users/davidburns/development/selenium

What's the output of git remote get-url origin ; git rev-parse master ; git rev-parse HEAD ?

davidburns in ~/development/selenium on trunk λ git remote get-url origin ; git rev-parse trunk ; git rev-parse HEAD
git@github.com:SeleniumHQ/selenium.git
5a5bc38279920bd67b2c7f805bb6b3adbbc6e190
5a5bc38279920bd67b2c7f805bb6b3adbbc6e190

Have you found anything relevant by searching the web?

No, asked on Slack and link is above

Any other information, logs, or outputs that you want to share?

Not really

@lberki lberki added P2 We'll consider working on this in future. (Assignee optional) and removed untriaged labels Oct 5, 2020
@lberki
Copy link
Contributor

lberki commented Oct 5, 2020

It would be nice to handle TreeArtifacts. Is this bug "only" about TreeArtifacts or is there something special about React?

@AutomatedTester
Copy link
Author

It would be nice to handle TreeArtifacts. Is this bug "only" about TreeArtifacts or is there something special about React?

I believe it's only about tree artifacts as we have been able to get around it by fudging the react stuff into a tree artifact that the Java libraries can understand.

@lberki
Copy link
Contributor

lberki commented Oct 5, 2020

I'll rename this bug then; React or not, it's a pretty reasonable request.

@lberki lberki changed the title Java_library rules does not know how to interpret TreeArtifact that react_scripts Java rules should be able to build tree artifacts in their sources Oct 5, 2020
@fanStefan
Copy link

+1 for tree artifacts in java rules

@nickbreen
Copy link

I've just wasted a day on this :-(

I ended up writing a rule that used the "current_java_runtime" to get access to bin/jar and created a jar.

Then used java_import to import the jar output of that rule.

@tanishiking
Copy link

tanishiking commented Nov 7, 2022

For those who hit the same issue, I could work around it by java_import the zipped output directory of rules_js / rules_nodejs and include it to the classpath by runtime_deps with the following change tanishiking/bazel-playground@b9dee7a

here's the complete example https://github.com/tanishiking/bazel-playground/tree/main/11_rules_js_migration

And here's the link to the conversion on Bazel slack https://bazelbuild.slack.com/archives/CEZUUKQ6P/p1667714288145819

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 type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants