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

ijar: fix manifest sections handling #12771

Closed

Conversation

liucijus
Copy link
Contributor

@liucijus liucijus commented Jan 4, 2021

Fixes #12730

Important changes:

  • removed line stripping from the original implementation
  • label/rule attributes are appended after main attributes, then the rest of the MANIFEST.MF content is appended - this way sections data is preserved.

@google-cla google-cla bot added the cla: yes label Jan 4, 2021
@comius comius requested a review from cushon January 6, 2021 11:31
@ittaiz
Copy link
Member

ittaiz commented Jan 11, 2021

@cushon wdyt? Rather small PR which could help us out at rules_scala

@jin jin added the team-Rules-Java Issues for Java rules label Jan 15, 2021
@ittaiz
Copy link
Member

ittaiz commented Jan 22, 2021

Can anyone help with this? @liucijus stepped up and not only reported the issue but also sent a small PR and it's just sitting here.
FYI we're copying ~25k LOC into rules scala to be unblocked.
Divergences are happening :(

@ittaiz
Copy link
Member

ittaiz commented Jan 29, 2021

@aiuto process wise and bazel community- how long should a community contributor wait before getting a review? Especially for a small and confined PR?
I'm asking because this is demoralizing and works against your efforts of having not only Google look out for Bazel

Copy link
Contributor

@comius comius left a comment

Choose a reason for hiding this comment

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

LGTM, except that I would like to also have a test where Target-Label is in the manifest with sections and it is skipped.

@@ -144,6 +144,14 @@ genrule(
tools = ["//third_party/ijar"],
)

genrule(
name = "jar_with_manifest_sections",
srcs = ["jar-with-manifest-sections.jar"],
Copy link
Contributor

Choose a reason for hiding this comment

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

For reference:

Archive:  jar-with-manifest-sections.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
     1382  2010-01-01 05:00   AnnotatedClass.class
      476  2010-01-01 05:00   Annotations.class
      381  2010-01-01 05:00   Annotations$ParametersOnlyAnnotation.class
      468  2010-01-01 05:00   Annotations$RuntimeInvisible.class
      561  2010-01-01 05:00   Annotations$RuntimeVisible.class
        0  2010-01-01 05:00   META-INF/
       96  2021-01-04 09:23   META-INF/MANIFEST.MF
       19  2018-03-29 15:53   textfile.txt
---------                     -------
     3383                     8 files
$ cat META-INF/MANIFEST.MF 
Manifest-Version: 1.0
Created-By: test-code

Name: foo
Foo: bar

Name: baz
Another: bar

@comius
Copy link
Contributor

comius commented Jan 29, 2021

@cushon, do you think this could have any impact on the other Java code? My best guess is that it doesn't, because before the patch manifests with sections would just get mangled.


genrule(
name = "jar_with_target_label_and_manifest_sections",
srcs = ["jar-with-target-label-and-manifest-sections.jar"],
Copy link
Contributor

Choose a reason for hiding this comment

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

For reference:

Archive:  jar-with-target-label-and-manifest-sections.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
     1382  2010-01-01 05:00   AnnotatedClass.class
      476  2010-01-01 05:00   Annotations.class
      381  2010-01-01 05:00   Annotations$ParametersOnlyAnnotation.class
      468  2010-01-01 05:00   Annotations$RuntimeInvisible.class
      561  2010-01-01 05:00   Annotations$RuntimeVisible.class
        0  2010-01-01 05:00   META-INF/
      122  2021-01-29 08:19   META-INF/MANIFEST.MF
       19  2018-03-29 15:53   textfile.txt
---------                     -------
     3409                     8 files
$ cat META-INF/MANIFEST.MF 
Manifest-Version: 1.0
Created-By: test-code
Target-Label: //not:this

Name: foo
Foo: bar

Name: baz
Another: bar

@comius
Copy link
Contributor

comius commented Jan 29, 2021

Internal linter says: ".jar files are no longer allowed in third_party." and prevents me from adding new .jar file (while old ones are fine). Bazel should be able to generate those .jars from sources, but it's another curve ball.

@liucijus
Copy link
Contributor Author

liucijus commented Jan 29, 2021

LGTM, except that I would like to also have a test where Target-Label is in the manifest with sections and it is skipped.

I assume you want a test to show that existing label is update, right? If I'm not missing anything, it's the way ijar works.

@comius
Copy link
Contributor

comius commented Jan 29, 2021

LGTM, except that I would like to also have a test where Target-Label is in the manifest with sections and it is skipped.

I assume you want a test to show that existing label is update, right? If I'm not missing anything, it's the way ijar works.

Correct. I already reviewed it, it's ok.

@comius
Copy link
Contributor

comius commented Jan 29, 2021

Internal linter says: ".jar files are no longer allowed in third_party." and prevents me from adding new .jar file (while old ones are fine). Bazel should be able to generate those .jars from sources, but it's another curve ball.

Do you have resource/will to fix this as well?

@liucijus
Copy link
Contributor Author

Internal linter says: ".jar files are no longer allowed in third_party." and prevents me from adding new .jar file (while old ones are fine). Bazel should be able to generate those .jars from sources, but it's another curve ball.
Do you have resource/will to fix this as well?

I'll look into it

@liucijus
Copy link
Contributor Author

Internal linter says: ".jar files are no longer allowed in third_party." and prevents me from adding new .jar file (while old ones are fine). Bazel should be able to generate those .jars from sources, but it's another curve ball.
Do you have resource/will to fix this as well?

I'll look into it

Done

@bazel-io bazel-io closed this in ba60c0b Feb 1, 2021
@ittaiz
Copy link
Member

ittaiz commented Feb 1, 2021

Thanks @liucijus and @comius!

philwo pushed a commit that referenced this pull request Mar 15, 2021
Fixes #12730

Important changes:
 - removed line stripping from the original implementation
 - label/rule attributes are appended after main attributes, then the rest of the `MANIFEST.MF` content is appended - this way sections data is preserved.

Closes #12771.

PiperOrigin-RevId: 354909855
philwo pushed a commit that referenced this pull request Mar 15, 2021
Fixes #12730

Important changes:
 - removed line stripping from the original implementation
 - label/rule attributes are appended after main attributes, then the rest of the `MANIFEST.MF` content is appended - this way sections data is preserved.

Closes #12771.

PiperOrigin-RevId: 354909855
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes team-Rules-Java Issues for Java rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ijar incorrectly handles MANIFESTs with sections
4 participants