Commit graph

9 commits

Author SHA1 Message Date
Anton Hansson
2863e4535e Make package parsing code consume annotations
The code previously assumed an annotation meant there was no package
declaration, but package declarations can be annotated. Update the
code to consume any leading annotations.

Bug: 151360309
Test: jar_test.go (& manual verification on full bootclasspath srcs)
Change-Id: I3de5a2a675363fc3627a278103dd2cabe80a2d80
2023-09-26 09:55:52 +00:00
Chris Gross
fa5b4e909b Use broader permissions when archiving files.
Using broader premissions for archived files allows them to be more
easily used when extracted. For example, defaulting regular files to
0644 will allow other tooling to use a file without the need to change
permissions manually.

Bug: 189919409
Test: m dist and inspected file permissions of archived files
Change-Id: I4a0f8075206391254c639ecf865639bb9e8df0bf
2021-06-02 16:14:45 -07:00
Colin Cross
9cb51dbc0b Support moving sources in srcjars in soong_zip
Add a -srcjar argument to soong_zip that causes it to read the
package statement of each .java file and use that to place the
source file at a path that matches the package.

Test: jar_test.go, zip_test.go
Change-Id: I36017e42445ba3b0a82a10a8d81e8ac0cca096f2
2019-06-18 13:33:20 -07:00
Colin Cross
05518bc13b soong_zip: Add tests
Add test that cover basic command line usage of soong_zip.  -D
is not covered yet as the implementation will be replaced with
one that is also more easily testable in the next patch.

Bug: 116751500
Test: zip_test.go
Change-Id: I5a1bcee74ebc9cb3cf332c36f89bc12c0e807ad2
2018-09-28 13:56:06 -07:00
Colin Cross
bddcf13555 Change default jar time to match ziptime
Ziptime uses Jan 01 2008, use the same in soong_zip and merge_zips.

Test: manual
Change-Id: Ie79a2e7864a5ed5a74833caec0a50c25a451859e
2017-10-04 17:19:43 -07:00
Colin Cross
2825cb3f8d Correctly set date and mode fields for MANIFEST.MF
The file header returned by jar.ManifestFileContents had unset
date and mode fields.  The unset date field resulted in the
"Last Mod Time" field in the zip file being set to 0, which
OpenJDK 9's jar implementation treats as an error:
java.time.DateTimeException: Invalid value for MonthOfYear (valid values 1 - 12): 0

Bug: 67095392
Test: zipdetails out/host/linux-x86/framework/tradefed.jar
Change-Id: I0a818d57420f5e5de57e8ff57791951c1b538443
2017-09-29 21:52:58 +00:00
Colin Cross
635acc9446 Rearrange manifest file handling in merge_zips and soong_zip
Jar always puts default MANIFEST.MF files in if none was specified.
Copying that behavior in soong_zip causes problems with merge_zips,
because it ends up taking the default manifest from the classes.jar
instead of the user's manifest from res.jar.  We don't want the
user's manifest in the classes.jar, otherwise a change to the
manifest will cause all the class files to rebuild.  Instead,
move the manifest insertion to the final merge_zips stage.

Test: m -j checkbuild
Change-Id: Id6376961dbaf743c2fb92843f9bdf2e44b963be0
2017-09-20 13:20:45 -07:00
Colin Cross
34540315a0 Allow some duplicates in merged jars
Only take the first MANIFEST.MF or module-info.class file.

Test: m -j checkbuild
Change-Id: Ifbf9fe272437ef2c2bd51ab4849ac8d7ef37b6fc
2017-09-06 15:01:07 -07:00
Jeff Gaston
01547b23d2 Extract jar-sorting to be accessible to soong_zip
Bug: 64536066
Test: m -j # which runs unit tests
Change-Id: I4830bd331c9dab0b1d300a18aefaf25a6af4cfdc
2017-08-24 14:43:35 -07:00