Commit 3c3d628f authored by Ryan Pavlik's avatar Ryan Pavlik Committed by Lubosz Sarnecki
Browse files

t/oxr_android: Add resources and build code to grab the CDDL license for display.

Used by a dependency of Hilt.
parent 885dd1d4
......@@ -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 {
......
......@@ -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 '<br /><br />'
} 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 '<br /><br />'
} 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 {
......
cjson:mit
# Copyright 2020, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
javax_annotation__jsr250_api:cddl_1_0
# SPDX-License-Identifier: CC0-1.0
# SPDX-FileCopyrightText: 2020 Collabora, Ltd. and the Monado contributors
bsl_1_0.txt
cddl_1_0.txt
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!--
Copyright 2020, Collabora, Ltd.
SPDX-License-Identifier: BSL-1.0
-->
<string name="define_license_cddl_1_0" translatable="false" />
<string name="license_cddl_1_0_licenseName" translatable="false">Common Development and Distribution License 1.0</string>
<!-- name of the license file under the raw folder -->
<string name="license_cddl_1_0_licenseDescription" translatable="false">raw:cddl_1_0</string>
</resources>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment