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

Stamp scala_import jars #1160

Merged
merged 11 commits into from
Jan 22, 2021
Merged

Stamp scala_import jars #1160

merged 11 commits into from
Jan 22, 2021

Conversation

liucijus
Copy link
Collaborator

@liucijus liucijus commented Dec 4, 2020

Probably very naive approach on stamping scala_import jars. @ittaiz WDYT?

@liucijus
Copy link
Collaborator Author

liucijus commented Dec 9, 2020

Few problems:

  • java_common.stamp_jar seems to be duplicating some Manifest attributes
  • due to symlinking, all rules that depend on toolchain deps need to have incompatible_use_toolchain_transition = True, set to prevent host and target dependencies mixing. I'll do it with a separate PR.

Copy link
Member

@ittaiz ittaiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good in general. see one question inside.
FYI for other people watching- I was curious on why I didn't use symlink before and found out it was only introduced in 1.0 and even then it was experimental and required a bazel flag

@@ -4,8 +4,8 @@ load("//scala:scala.bzl", "scala_junit_test", "scala_test")

common_jvm_flags = [
"-Dplugin.jar.location=$(location //third_party/dependency_analyzer/src/main:dependency_analyzer)",
"-Dscala.library.location=$(location //external:io_bazel_rules_scala/dependency/scala/scala_library)",
"-Dscala.reflect.location=$(location //external:io_bazel_rules_scala/dependency/scala/scala_reflect)",
"-Dscala.library.location=$(rootpath //external:io_bazel_rules_scala/dependency/scala/scala_library)",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't remember the difference between location and rootpath. Do you remember?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think they are good for runtime information, but as we use them there's some info on them:

https://docs.bazel.build/versions/master/be/make-variables.html#predefined_label_variables

and

bazelbuild/bazel#2475 (comment)

@liucijus
Copy link
Collaborator Author

liucijus commented Jan 13, 2021

Status of various stamping techniques:

  • java_common.stamp_jar calls ijar tool, which incorrectly handles MANIFEST sections
  • singlejar does not preserve existing attributes
  • custom ijar works fine, but requires to bring in modified ijar sources

Currently the only way is to proceed with custom ijar until bazelbuild/bazel#12730 is fixed

@liucijus liucijus marked this pull request as ready for review January 13, 2021 07:37
@ittaiz
Copy link
Member

ittaiz commented Jan 13, 2021

I think we should advance with custom ijar.
How complicated will it be to only have custom ijar on opt-in?
I'm concerned that if some orgs are really strict on security then they might have a problem with the custom ijar and they might be blocked on upgrades.
If we can have this ability (and so also custom ijar requirement) be opt-in then maybe we have the best of both worlds.

@liucijus
Copy link
Collaborator Author

I think we should advance with custom ijar.
How complicated will it be to only have custom ijar on opt-in?
I'm concerned that if some orgs are really strict on security then they might have a problem with the custom ijar and they might be blocked on upgrades.
If we can have this ability (and so also custom ijar requirement) be opt-in then maybe we have the best of both worlds.

Custom ijar source is under third_party, I don't think it's a security concern. I don't want to have opt-in, as it would be very confusing for users (buggy stamping, etc).

@ittaiz
Copy link
Member

ittaiz commented Jan 13, 2021

ok

"--nostrip_jar",
"--target_label",
ctx.label.name,
symlink_file.path,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why symlink is needed? Can't you just pass jar.path?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because bazel does not allow modifications outside package

],
)
#
#cc_binary(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe remove this?

srcs = glob(["**"]),
)

#filegroup(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say remove commented coded

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left it commented out to have it easier to update if needed. Otherwise it's a bit harder to pick what's needed to be changed.

Copy link
Collaborator

@simuons simuons left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.
I didn't look at ijar/zlib code.
I though there is a need only for ijar, why there is code for zlib?

@liucijus
Copy link
Collaborator Author

I though there is a need only for ijar, why there is code for zlib?

It's a source dependency used to process jar archives

@simuons
Copy link
Collaborator

simuons commented Jan 22, 2021

@liucijus thanks for your answers. LGMT

Copy link
Member

@ittaiz ittaiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ittaiz ittaiz merged commit 939fa4c into bazelbuild:master Jan 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants