diff --git a/build.gradle b/build.gradle
index c215eff55..dcaeb3fa1 100644
--- a/build.gradle
+++ b/build.gradle
@@ -37,6 +37,9 @@ plugins {
// For getting git describe data and formatting it how Android wants.
id "com.gladed.androidgitversion" version "0.4.13"
+
+ // For downloading e.g. the CDDL (for transitive dependencies of hilt)
+ id "de.undercouch.download" version "4.1.1"
}
ext {
diff --git a/src/xrt/targets/openxr_android/build.gradle b/src/xrt/targets/openxr_android/build.gradle
index e4fa3ffde..9b7bb1a7f 100644
--- a/src/xrt/targets/openxr_android/build.gradle
+++ b/src/xrt/targets/openxr_android/build.gradle
@@ -25,27 +25,51 @@ def parseOpenXRVersion(def fn) {
String.join('.', components)
}
+// For JSR250 used by Hilt
+task getCDDL {
+ doLast {
+ ant.invokeMethod("get", [src: "https://spdx.org/licenses/CDDL-1.0.txt", dest: "${} "])
+ }
+
+}
+
+project.ext.renameLicense = { String name ->
+ def lowerNoExtension = name.toLowerCase().replace(".txt", "")
+ def result = lowerNoExtension.replaceAll(~/[\-.]/, "_") + ".txt"
+ return result
+}
+
+project.ext.filterLicense = {String line ->
+ if (line.trim().isEmpty()) {
+ return '
'
+ } else {
+ return groovy.xml.XmlUtil.escapeXml(line)
+ }
+}
// TODO: this copies to the source dir for simplicity right now, but it's not great!
task copyLicenses(type: Copy) {
from "${rootDir}/LICENSES/"
include 'BSL-1.0.txt'
- rename {
- String name ->
- def lowerNoExtension = name.toLowerCase().replace(".txt", "")
- def result = lowerNoExtension.replaceAll(~/[\-.]/, "_") + ".txt"
- return result
- }
+ rename(renameLicense)
into project.layout.projectDirectory.dir('src/main/res/raw').asFile
- filter { line ->
- if (line.trim().isEmpty()) {
- return '
'
- } else {
- return groovy.xml.XmlUtil.escapeXml(line)
- }
- }
+ filter(filterLicense)
+}
+project.ext.licenseDir = new File(project.buildDir, 'intermediates/licenses/')
+
+task downloadCddl(type: Download) {
+ src 'https://spdx.org/licenses/CDDL-1.0.txt'
+ dest "${project.licenseDir}/CDDL-1.0.txt"
+ overwrite false
}
+task copyDownloadedLicenses(type: Copy) {
+ from downloadCddl.dest
+ rename(renameLicense)
+ into project.layout.projectDirectory.dir('src/main/res/raw').asFile
+ filter(filterLicense)
+ dependsOn downloadCddl
+}
android {
compileSdkVersion project.sharedTargetSdk
buildToolsVersion '30.0.2'
@@ -79,6 +103,7 @@ android {
// Be sure to copy over licenses formatted as required.
preBuild.dependsOn(copyLicenses)
+ preBuild.dependsOn(copyDownloadedLicenses)
}
buildTypes {
diff --git a/src/xrt/targets/openxr_android/config/custom_license_mappings.prop b/src/xrt/targets/openxr_android/config/custom_license_mappings.prop
index 9fb09f650..1ecfb3283 100644
--- a/src/xrt/targets/openxr_android/config/custom_license_mappings.prop
+++ b/src/xrt/targets/openxr_android/config/custom_license_mappings.prop
@@ -1 +1,3 @@
-cjson:mit
+# Copyright 2020, Collabora, Ltd.
+# SPDX-License-Identifier: BSL-1.0
+javax_annotation__jsr250_api:cddl_1_0
diff --git a/src/xrt/targets/openxr_android/src/main/res/.gitignore b/src/xrt/targets/openxr_android/src/main/res/.gitignore
new file mode 100644
index 000000000..beb826d81
--- /dev/null
+++ b/src/xrt/targets/openxr_android/src/main/res/.gitignore
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: CC0-1.0
+# SPDX-FileCopyrightText: 2020 Collabora, Ltd. and the Monado contributors
+
+bsl_1_0.txt
+cddl_1_0.txt
diff --git a/src/xrt/targets/openxr_android/src/main/res/raw/.gitignore b/src/xrt/targets/openxr_android/src/main/res/raw/.gitignore
deleted file mode 100644
index ab25a59eb..000000000
--- a/src/xrt/targets/openxr_android/src/main/res/raw/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bsl_1_0.txt
diff --git a/src/xrt/targets/openxr_android/src/main/res/values/license_cddl_1_0.xml b/src/xrt/targets/openxr_android/src/main/res/values/license_cddl_1_0.xml
new file mode 100644
index 000000000..030744fd8
--- /dev/null
+++ b/src/xrt/targets/openxr_android/src/main/res/values/license_cddl_1_0.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ Common Development and Distribution License 1.0
+
+
+ raw:cddl_1_0
+