Do not jarjar classes in the target package

Update the jarjar generator to avoid jarjaring the target package, as
classes inside it do not need to be moved to it, and update integration
tests to match new class names.

Test: atest CtsNetTestCasesLatestSdk FrameworksNetIntegrationTests
Change-Id: I60ffb9f4769b4b86d9205d92c3d8b3f6637d4560
This commit is contained in:
Remi NGUYEN VAN 2022-07-21 18:57:41 +09:00
commit 3ba00cb6f8
2 changed files with 27 additions and 1 deletions

View file

@ -115,7 +115,8 @@ def make_jarjar_rules(args):
jar_classes = _list_jar_classes(jar)
jar_classes.sort()
for clazz in jar_classes:
if (_get_toplevel_class(clazz) not in excluded_classes and
if (not clazz.startswith(args.prefix + '.') and
_get_toplevel_class(clazz) not in excluded_classes and
not any(r.fullmatch(clazz) for r in exclude_regexes)):
outfile.write(f'rule {clazz} {args.prefix}.@0\n')
# Also include jarjar rules for unit tests of the class, so the package matches

View file

@ -0,0 +1,25 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package jarjar.prefix;
/**
* Sample class to test jarjar rules, already in the "jarjar.prefix" package.
*/
public class AlreadyInTargetPackageClass {
/** Test inner class that should not be jarjared either */
public static class TestInnerClass {}
}