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

Fix generated resources #538

Merged
merged 2 commits into from
Jul 10, 2021

Conversation

jdai8
Copy link
Contributor

@jdai8 jdai8 commented May 13, 2021

Fixes #281.

The issue is that we were using short_path, which excludes the configuration root. Using file.path instead fixes this. Note that we still want to use short_path when deciding where to place the file in the jar. We don't want resources in the jar to look like bazel-bin/darwin-fastbuild/....

Tested this on our repo internally and it seems to work.

target_path = target_path,
c_dir = c_dir,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the only usage of c_dir. Since we don't need it anymore I removed it from the return values as well.

Comment on lines -273 to +272
line = "{target_path}={c_dir}{res_path}\n".format(
res_path = res_path,
line = "{target_path}={f_path}\n".format(
Copy link

@freetheinterns freetheinterns May 13, 2021

Choose a reason for hiding this comment

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

Thanks for this change @jdai8! I was so confused why zipping was failing for some resource files generated under bazel-out.

To be super clear this argument line {target_path}={c_dir}{res_path} is saying that the file located at {c_dir}{res_path} should be zipped under {target_path} for the resource jar. So moving to {target_path}={f_path} should be more stable, because f.path should always be how input files are located by a bazel action and {target_path} remains the same.

@cgruber cgruber added this to the Candidate 1.5 milestone Jun 4, 2021
Copy link
Collaborator

@cgruber cgruber left a comment

Choose a reason for hiding this comment

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

This is subtle. Thanks for figuring it out.

@cgruber cgruber merged commit 847166c into bazelbuild:master Jul 10, 2021
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.

Cannot include generated file as a resource
3 participants