From 7676fa0a93cd9f36849f198ee6b5fdc7ac39fec0 Mon Sep 17 00:00:00 2001
From: utzcoz <utzcoz@outlook.com>
Date: Sat, 18 Mar 2023 11:31:35 +0800
Subject: [PATCH] gradle: Bump AGP to 7.1.2

1. Bump AGP to 7.1.2.
2. Bump hiltVersion to 2.38.1.
3. Migrate lintOptions to lint.
4. Move package from AndroidManifest to Gradle.
5. Fully qualify application class name.
6. Fix packagingOptions usage with resources wrapper.

Signed-off-by: utzcoz <utzcoz@outlook.com>
Signed-off-by: Ryan Pavlik <ryan.pavlik@collabora.com>
---
 build.gradle                                          |  6 +++---
 src/xrt/auxiliary/android/build.gradle                | 11 +++++++----
 .../auxiliary/android/src/main/AndroidManifest.xml    |  3 +--
 src/xrt/ipc/android/build.gradle                      | 11 +++++++----
 src/xrt/ipc/android/src/main/AndroidManifest.xml      |  3 +--
 src/xrt/targets/android_common/build.gradle           | 11 +++++++----
 .../android_common/src/main/AndroidManifest.xml       |  3 +--
 src/xrt/targets/openxr_android/build.gradle           | 11 +++++++----
 .../openxr_android/src/main/AndroidManifest.xml       |  3 +--
 9 files changed, 35 insertions(+), 27 deletions(-)

diff --git a/build.gradle b/build.gradle
index ccf4420fe..79ce8c459 100644
--- a/build.gradle
+++ b/build.gradle
@@ -15,7 +15,7 @@ buildscript {
         androidxCardViewVersion = '1.0.0'
         androidxRecyclerViewVersion = '1.2.1'
 
-        hiltVersion = '2.37'
+        hiltVersion = '2.38.1'
 
         materialVersion = "1.3.0"
 
@@ -36,8 +36,8 @@ buildscript {
 }
 plugins {
     // Android Gradle Plugin
-    id 'com.android.application' version '7.0.4' apply false
-    id 'com.android.library' version '7.0.4' apply false
+    id 'com.android.application' version '7.1.2' apply false
+    id 'com.android.library' version '7.1.2' apply false
 
     id 'org.jetbrains.kotlin.android' version "$kotlinVersion" apply false
 
diff --git a/src/xrt/auxiliary/android/build.gradle b/src/xrt/auxiliary/android/build.gradle
index 7b876e589..f06a6df75 100644
--- a/src/xrt/auxiliary/android/build.gradle
+++ b/src/xrt/auxiliary/android/build.gradle
@@ -24,15 +24,18 @@ android {
         }
     }
 
-    lintOptions {
-        fatal 'StopShip'
-    }
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
     packagingOptions {
-        exclude("META-INF/*.kotlin_module")
+        resources {
+            excludes += ['META-INF/*.kotlin_module']
+        }
+    }
+    namespace 'org.freedesktop.monado.auxiliary'
+    lint {
+        fatal 'StopShip'
     }
 }
 
diff --git a/src/xrt/auxiliary/android/src/main/AndroidManifest.xml b/src/xrt/auxiliary/android/src/main/AndroidManifest.xml
index bdbf534a0..287d4f759 100644
--- a/src/xrt/auxiliary/android/src/main/AndroidManifest.xml
+++ b/src/xrt/auxiliary/android/src/main/AndroidManifest.xml
@@ -1,5 +1,4 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.freedesktop.monado.auxiliary">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
 <!--
     Copyright 2020, Collabora, Ltd.
     SPDX-License-Identifier: BSL-1.0
diff --git a/src/xrt/ipc/android/build.gradle b/src/xrt/ipc/android/build.gradle
index 2fd655566..69a27ba75 100644
--- a/src/xrt/ipc/android/build.gradle
+++ b/src/xrt/ipc/android/build.gradle
@@ -39,15 +39,18 @@ android {
         }
     }
 
-    lintOptions {
-        fatal 'StopShip'
-    }
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
     packagingOptions {
-        exclude("META-INF/*.kotlin_module")
+        resources {
+            excludes += ['META-INF/*.kotlin_module']
+        }
+    }
+    namespace 'org.freedesktop.monado.ipc'
+    lint {
+        fatal 'StopShip'
     }
 }
 
diff --git a/src/xrt/ipc/android/src/main/AndroidManifest.xml b/src/xrt/ipc/android/src/main/AndroidManifest.xml
index abb5976ef..db39abfc4 100644
--- a/src/xrt/ipc/android/src/main/AndroidManifest.xml
+++ b/src/xrt/ipc/android/src/main/AndroidManifest.xml
@@ -1,5 +1,4 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.freedesktop.monado.ipc">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
     <!--
         Copyright 2020, Collabora, Ltd.
         SPDX-License-Identifier: BSL-1.0
diff --git a/src/xrt/targets/android_common/build.gradle b/src/xrt/targets/android_common/build.gradle
index 4cbaa4ad1..12b4c7b0a 100644
--- a/src/xrt/targets/android_common/build.gradle
+++ b/src/xrt/targets/android_common/build.gradle
@@ -31,15 +31,18 @@ android {
         }
     }
 
-    lintOptions {
-        fatal 'StopShip'
-    }
     compileOptions {
         sourceCompatibility JavaVersion.VERSION_1_8
         targetCompatibility JavaVersion.VERSION_1_8
     }
     packagingOptions {
-        exclude("META-INF/*.kotlin_module")
+        resources {
+            excludes += ['META-INF/*.kotlin_module']
+        }
+    }
+    namespace 'org.freedesktop.monado.android_common'
+    lint {
+        fatal 'StopShip'
     }
 }
 
diff --git a/src/xrt/targets/android_common/src/main/AndroidManifest.xml b/src/xrt/targets/android_common/src/main/AndroidManifest.xml
index a06437680..15c70a746 100644
--- a/src/xrt/targets/android_common/src/main/AndroidManifest.xml
+++ b/src/xrt/targets/android_common/src/main/AndroidManifest.xml
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    package="org.freedesktop.monado.android_common">
+<manifest xmlns:android="http://schemas.android.com/apk/res/android">
     <!--
         Copyright 2020, Collabora, Ltd.
         SPDX-License-Identifier: BSL-1.0
diff --git a/src/xrt/targets/openxr_android/build.gradle b/src/xrt/targets/openxr_android/build.gradle
index 72b476859..9ba175a1f 100644
--- a/src/xrt/targets/openxr_android/build.gradle
+++ b/src/xrt/targets/openxr_android/build.gradle
@@ -148,9 +148,6 @@ android {
         }
     }
 
-    lintOptions {
-        fatal 'StopShip'
-    }
 
     flavorDimensions 'deployment'
     productFlavors {
@@ -178,7 +175,13 @@ android {
         targetCompatibility JavaVersion.VERSION_1_8
     }
     packagingOptions {
-        exclude("META-INF/*.kotlin_module")
+        resources {
+            excludes += ['META-INF/*.kotlin_module']
+        }
+    }
+    namespace 'org.freedesktop.monado.openxr_runtime'
+    lint {
+        fatal 'StopShip'
     }
 
 }
diff --git a/src/xrt/targets/openxr_android/src/main/AndroidManifest.xml b/src/xrt/targets/openxr_android/src/main/AndroidManifest.xml
index 9ce6df71c..aee342ce4 100644
--- a/src/xrt/targets/openxr_android/src/main/AndroidManifest.xml
+++ b/src/xrt/targets/openxr_android/src/main/AndroidManifest.xml
@@ -1,7 +1,6 @@
 <?xml version="1.0" encoding="utf-8"?>
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    package="org.freedesktop.monado.openxr_runtime">
+    xmlns:tools="http://schemas.android.com/tools">
     <!--
         Copyright 2020-2022, Collabora, Ltd.
         SPDX-License-Identifier: BSL-1.0