Add simple sharding support to jarjar

- The "process" subcommand now takes optional two
integer arguments. If they're set, jarjar will
process only a subset of the input jar file which is determined
by the arguments. For example, if you pass "2 0",
then jarjar will only process the first half of the input jar.
Use "2 1" for processing the second half.

We then use merge_zips to combine the output jars.

- Passing "1 0" will effectively disable the sharding behavior.

- Other than that, we don't change any logic.

- Because jarjar sorts the entries in the output file, the sharded
version may have entries in a different order. But that shouldn't matter
because the input file has no duplicate entries, which we know
because jarjar already has a duplicate entry check.

Test: m framework-minus-apex framework-minus-apex_jarjar-sharded
  and make sure the javac output jars have the same entries.
  $ diff \
    <(jar tf $ANDROID_BUILD_TOP/out/soong/.intermediates/frameworks/base/framework-minus-apex/android_common/jarjar/framework.jar \
      | sort) \
    <(jar tf $ANDROID_BUILD_TOP/out/soong/.intermediates/frameworks/base/framework-minus-apex_jarjar-sharded/android_common/jarjar/framework-minus-apex_jarjar-sharded.jar \
      | sort)
  (no output)

Bug: 383559945
Flag: EXEMPT New options are not used on production jars
Change-Id: Ib32a5404ec36e9f145e9d4cb838ef48b9860006b
2 files changed