Seperate out repackaged Protobuf library in core
BUG: 296864329
TESTED: Ran ./gradlew :core:core-location-altitude:cC and it passed
Change-Id: Ibdb84453854eb74432b038fadb0aea9ead2541fe
diff --git a/core/core-location-altitude-external-protobuf/api/current.txt b/core/core-location-altitude-external-protobuf/api/current.txt
new file mode 100644
index 0000000..e6f50d0
--- /dev/null
+++ b/core/core-location-altitude-external-protobuf/api/current.txt
@@ -0,0 +1 @@
+// Signature format: 4.0
diff --git a/core/core-location-altitude-external-protobuf/api/restricted_current.txt b/core/core-location-altitude-external-protobuf/api/restricted_current.txt
new file mode 100644
index 0000000..e6f50d0
--- /dev/null
+++ b/core/core-location-altitude-external-protobuf/api/restricted_current.txt
@@ -0,0 +1 @@
+// Signature format: 4.0
diff --git a/core/core-location-altitude-external-protobuf/build.gradle b/core/core-location-altitude-external-protobuf/build.gradle
new file mode 100644
index 0000000..541ce8d
--- /dev/null
+++ b/core/core-location-altitude-external-protobuf/build.gradle
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2024 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.
+ */
+
+/**
+ * This file was created using the `create_project.py` script located in the
+ * `<AndroidX root>/development/project-creator` directory.
+ *
+ * Please use that script when creating a new project, rather than copying an existing project and
+ * modifying its settings.
+ */
+import androidx.build.LibraryType
+
+plugins {
+ id("AndroidXPlugin")
+ id("AndroidXRepackagePlugin")
+ id("java-library")
+}
+
+repackage {
+ addRelocation {
+ sourcePackage = "com.google.protobuf"
+ targetPackage = "androidx.core.location.altitude.impl.proto"
+ }
+ artifactId = "core-location-altitude-external-protobuf"
+}
+
+dependencies {
+ repackage(libs.protobufLite)
+}
+
+androidx {
+ name = "Location Altitude External Protobuf"
+ type = LibraryType.PUBLISHED_LIBRARY
+ mavenVersion = LibraryVersions.CORE_LOCATION_ALTITUDE
+ inceptionYear = "2024"
+ description = "Repackaged proto-lite dependency for use by core"
+ doNotDocumentReason = "Repackaging only"
+ license.name = "BSD-3-Clause"
+ license.url = "https://opensource.org/licenses/BSD-3-Clause"
+}
diff --git a/core/core-location-altitude-proto/build.gradle b/core/core-location-altitude-proto/build.gradle
index 6f109c5..49f25ce 100644
--- a/core/core-location-altitude-proto/build.gradle
+++ b/core/core-location-altitude-proto/build.gradle
@@ -21,18 +21,31 @@
* Please use that script when creating a new project, rather than copying an existing project and
* modifying its settings.
*/
-import androidx.build.Publish
+import androidx.build.LibraryType
+import androidx.build.RunApiTasks
plugins {
id("AndroidXPlugin")
id("java-library")
+ id("AndroidXRepackagePlugin")
id("com.google.protobuf")
}
-dependencies {
- implementation(libs.protobufLite)
+repackage {
+ // Must match what is in core/core-location-altitiude-external-protobuf/build.gradle
+ addRelocation {
+ sourcePackage = "com.google.protobuf"
+ targetPackage = "androidx.core.location.altitude.impl.proto"
+ }
}
+dependencies {
+ // Must be compileOnly to not bring in protobufLite in runtime
+ // Repackaged protobufLite brought in by
+ // project(":core:core-location-altitude-external-protobuf") and used at runtime
+ compileOnly(libs.protobufLite)
+ api(project(":core:core-location-altitude-external-protobuf"))}
+
protobuf {
protoc {
artifact = libs.protobufCompiler.get()
@@ -58,8 +71,11 @@
}
androidx {
- name = "Location Altitude Compatibility Library Protos"
- publish = Publish.NONE
+ name = "Location Altitude Protos"
+ type = LibraryType.PUBLISHED_LIBRARY
+ mavenVersion = LibraryVersions.CORE_LOCATION_ALTITUDE
inceptionYear = "2022"
description = "Implementation protos for core-location-altitude artifact."
+ runApiTasks = new RunApiTasks.No("Metalava doesn't properly parse the proto sources " +
+ "(b/180579063)")
}
diff --git a/core/core-location-altitude/build.gradle b/core/core-location-altitude/build.gradle
index 1530ba8..d6369882 100644
--- a/core/core-location-altitude/build.gradle
+++ b/core/core-location-altitude/build.gradle
@@ -39,21 +39,11 @@
}
}
-BundleInsideHelper.forInsideAar(
- project,
- /* from = */ "com.google.protobuf",
- /* to = */ "androidx.core.location.altitude.impl.proto",
- // proto-lite dependency includes .proto files, which are not used and would clash if
- // users also use proto library directly
- /* dropResourcesWithSuffix = */ ".proto"
-)
-
dependencies {
api(libs.kotlinStdlib)
api("androidx.annotation:annotation:1.5.0")
- bundleInside(project(":core:core-location-altitude-proto"))
-
+ implementation(project(":core:core-location-altitude-proto"))
implementation(libs.autoValueAnnotations)
implementation(project(":core:core"))
implementation("androidx.room:room-runtime:2.4.3")
diff --git a/settings.gradle b/settings.gradle
index 6de0bb10..776c5e4 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -618,6 +618,7 @@
includeProject(":core:core-i18n", [BuildType.MAIN])
includeProject(":core:core-ktx", [BuildType.MAIN, BuildType.GLANCE, BuildType.MEDIA, BuildType.FLAN, BuildType.COMPOSE])
includeProject(":core:core-location-altitude", [BuildType.MAIN])
+includeProject(":core:core-location-altitude-external-protobuf", [BuildType.MAIN])
includeProject(":core:core-location-altitude-proto", [BuildType.MAIN])
includeProject(":core:core-performance", [BuildType.MAIN])
includeProject(":core:core-performance:integration-tests:testapp", [BuildType.MAIN])