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

Support -sources.jar source jars and sourcejars with MANIFEST.MF files in them #48

Merged
merged 2 commits into from
Jul 29, 2024

Conversation

jjudd
Copy link

@jjudd jjudd commented Jul 27, 2024

We only handled .srcjar before, but many source jars are -sources.jar

Also many source jars have MANIFEST.MF files in them. We were treating those as Scala sources before this fix, which is not correct.

@jjudd jjudd force-pushed the handle-source-jars-better branch from 0115f0b to cb7a448 Compare July 27, 2024 06:39
@jjudd
Copy link
Author

jjudd commented Jul 27, 2024

I also tried re-enabling ijars for Scala 3 and it looks like that is working now after all the recent work, so I bolted that commit onto this PR.

src_jars = [
file
for file in ctx.files.srcs
if file.path.endswith("srcjar") or file.path.endswith("-sources.jar") or

Choose a reason for hiding this comment

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

is the .lower() not necessary for the file.path like it is for the file.extension?

Copy link
Author

Choose a reason for hiding this comment

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

Good catch. I'll fix and see if I can add a test for it.

Copy link
Author

Choose a reason for hiding this comment

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

I've updated these to be consistent with the others and have lower()

That said, looks like allow_files is not case insensitive, so I can't add a test. Which makes me question whether we want the lower here, but I suppose it won't hurt.

@@ -24,7 +24,11 @@ def scala_import_implementation(ctx):
_jar = []
_src_jar = []
for jar in ctx.files.jars:
if jar.basename.endswith("sources.jar") or jar.basename.endswith("src.jar"):
if (
jar.basename.endswith("sources.jar") or

Choose a reason for hiding this comment

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

In the other places we check for -sources.jar and -src.jar (with the -), should that be consistent here?

Copy link
Author

Choose a reason for hiding this comment

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

Yep. I'll change this.

# classfile format changed somehow for Scala 3 and Bazel does not yet
# handle that.
#
# In the meantime, we've added a use_ijar Scala configuration value and

Choose a reason for hiding this comment

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

Did you consider removing the use_ijar configuration altogether?

Copy link
Author

Choose a reason for hiding this comment

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

I have, but I want to get this merged and try it out in our main repo before I remove it. The rest I wrote here no longer fails, but I'll need more evidence to feel more confident.

James Judd added 2 commits July 29, 2024 10:51
…s in them

We only handled .srcjar before, but many source jars are -sources.jar

Also many source jars have MANIFEST.MF files in them. We were treating
those as Scala sources before this fix, which is not correct.
@jjudd jjudd force-pushed the handle-source-jars-better branch from cb7a448 to 42c014e Compare July 29, 2024 16:57
@jjudd jjudd merged commit 5eb0406 into lucid-master Jul 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants