Add keep annotations in androidx namespace
The only difference between the source in the androidx.annotation.keep
namespace and the original (now legacy) ones is the namespace and the
header comments, e.g. for AnnotationPattern.java:
diff src/keepanno/java/com/android/tools/r8/keepanno/annotations/AnnotationPattern.java src/keepanno/java/androidx/annotation/keep/AnnotationPattern.java
1,3c1,15
< // Copyright (c) 2024, the R8 project authors. Please see the AUTHORS file
< // for details. All rights reserved. Use of this source code is governed by a
< // BSD-style license that can be found in the LICENSE file.
Change-Id: I3369dcb057fb8ec39b43cab2e3e610cc90a26ff2
---
> /*
> * Copyright 2025 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.
> */
9c21,25
< package com.android.tools.r8.keepanno.annotations;
---
> // ***********************************************************************************
> // MAINTAINED AND TESTED IN THE R8 REPO. PLEASE MAKE CHANGES THERE AND REPLICATE.
> // ***********************************************************************************
>
> package androidx.annotation.keep;
This will build and archive three keep annotations JAR's:
build/libs/keepanno-annotations-androidx.jar
build/libs/keepanno-annotations.jar
build/libs/keepanno-annotations-legacy.jar
Currently keepanno-annotations.jar and keepanno-annotations-legacy.jar
are the same and contains the annotations in the current namespace
(com.android.tools.r8.keepanno.annotations).
Bug: b/392865072
Change-Id: Ifca1ad134913b1d99c96325180013a91d78b062e
diff --git a/tools/utils.py b/tools/utils.py
index 1e26ee9..0354cd9 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -45,6 +45,8 @@
GRADLE_TASK_CLEAN_TEST = ':test:cleanTest'
GRADLE_TASK_CONSOLIDATED_LICENSE = ':main:consolidatedLicense'
GRADLE_TASK_KEEP_ANNO_JAR = ':keepanno:keepAnnoAnnotationsJar'
+GRADLE_TASK_KEEP_ANNO_LEGACY_JAR = ':keepanno:keepAnnoLegacyAnnotationsJar'
+GRADLE_TASK_KEEP_ANNO_ANDROIDX_JAR = ':keepanno:keepAnnoAndroidXAnnotationsJar'
GRADLE_TASK_KEEP_ANNO_DOC = ':keepanno:keepAnnoAnnotationsDoc'
GRADLE_TASK_MAIN_COMPILE = ':main:compileJava'
GRADLE_TASK_R8 = ':main:r8WithRelocatedDeps'
@@ -90,6 +92,8 @@
KEEPANNO_ANNOTATIONS_JAR = os.path.join(LIBS, 'keepanno-annotations.jar')
KEEPANNO_ANNOTATIONS_DOC = os.path.join('d8_r8', 'keepanno', 'build', 'docs',
'javadoc')
+KEEPANNO_LEGACY_ANNOTATIONS_JAR = os.path.join(LIBS, 'keepanno-annotations-legacy.jar')
+KEEPANNO_ANDROIDX_ANNOTATIONS_JAR = os.path.join(LIBS, 'keepanno-annotations-androidx.jar')
DESUGAR_CONFIGURATION = os.path.join('src', 'library_desugar',
'desugar_jdk_libs.json')