summaryrefslogtreecommitdiff
path: root/compilerCommon
diff options
context:
space:
mode:
authorYigit Boyar <yboyar@google.com>2021-08-17 16:27:22 -0700
committerChris Warrington <cmw@google.com>2021-08-19 15:25:55 +0100
commit236fd6f46dbf617572a67be2340bf8557471a67b (patch)
treeb89d965bac658a400fb8cd188bf268b0ecc26908 /compilerCommon
parentcdddbf6892a0a445b82d6902c019242374a94782 (diff)
downloaddata-binding-236fd6f46dbf617572a67be2340bf8557471a67b.tar.gz
Fix sdk file loading
The api-versions file was moved. It was added to the new location in platforms in API 26 was removed in platform-tools 31+, in order that it is versioned alongside with the platform. Previously, the SDK location would be an argument to the data binding compiler, with this and the corresponding change in the Android Gradle Plugin, the the api-versions.xml for the current api level is directly injected, which means that it can be treated as an input from Gradle's perspective, and that the build won't be broken again by SDK component updates. AGP does not fall back to looking for the api file in platform-tools, instead the existing bundled version in Bug: 196847367 Test: SdkVersionTest Change-Id: I849289c7d41672ca5caf8c4250e04e35b4ce39ae
Diffstat (limited to 'compilerCommon')
-rw-r--r--compilerCommon/src/main/java/android/databinding/tool/CompilerArguments.kt15
1 files changed, 9 insertions, 6 deletions
diff --git a/compilerCommon/src/main/java/android/databinding/tool/CompilerArguments.kt b/compilerCommon/src/main/java/android/databinding/tool/CompilerArguments.kt
index f7f65f8f..dbc56a79 100644
--- a/compilerCommon/src/main/java/android/databinding/tool/CompilerArguments.kt
+++ b/compilerCommon/src/main/java/android/databinding/tool/CompilerArguments.kt
@@ -36,8 +36,8 @@ data class CompilerArguments constructor(
val modulePackage: String,
val minApi: Int,
- // the SDK directory
- val sdkDir: File,
+ // the API file from the SDK, might be null if we cannot find the right SDK
+ val apiFile: File?,
// the directory containing artifacts from library dependencies
val dependencyArtifactsDir: File,
@@ -138,7 +138,10 @@ data class CompilerArguments constructor(
args[PARAM_ARTIFACT_TYPE] = artifactType.name
args[PARAM_MODULE_PACKAGE] = modulePackage
args[PARAM_MIN_API] = minApi.toString()
- args[PARAM_SDK_DIR] = sdkDir.path
+ apiFile?.let {
+ args[PARAM_API_FILE] = it.path
+ }
+
args[PARAM_DEPENDENCY_ARTIFACTS_DIR] = dependencyArtifactsDir.path
args[PARAM_LAYOUT_INFO_DIR] = layoutInfoDir.path
args[PARAM_CLASS_LOG_DIR] = classLogDir.path
@@ -177,7 +180,7 @@ data class CompilerArguments constructor(
private const val PARAM_ARTIFACT_TYPE = PREFIX + "artifactType"
private const val PARAM_MODULE_PACKAGE = PREFIX + "modulePackage"
private const val PARAM_MIN_API = PREFIX + "minApi"
- private const val PARAM_SDK_DIR = PREFIX + "sdkDir"
+ private const val PARAM_API_FILE = PREFIX + "apiFile"
private const val PARAM_DEPENDENCY_ARTIFACTS_DIR = PREFIX + "dependencyArtifactsDir"
private const val LEGACY_PARAM_DEPENDENCY_ARTIFACTS_DIR = PREFIX + "bindingBuildFolder"
private const val PARAM_LAYOUT_INFO_DIR = PREFIX + "layoutInfoDir"
@@ -210,7 +213,7 @@ data class CompilerArguments constructor(
PARAM_ARTIFACT_TYPE,
PARAM_MODULE_PACKAGE,
PARAM_MIN_API,
- PARAM_SDK_DIR,
+ PARAM_API_FILE,
PARAM_DEPENDENCY_ARTIFACTS_DIR,
PARAM_LAYOUT_INFO_DIR,
PARAM_CLASS_LOG_DIR,
@@ -235,7 +238,7 @@ data class CompilerArguments constructor(
artifactType = Type.valueOf(options[PARAM_ARTIFACT_TYPE]!!),
modulePackage = options[PARAM_MODULE_PACKAGE]!!,
minApi = Integer.parseInt(options[PARAM_MIN_API]!!),
- sdkDir = File(options[PARAM_SDK_DIR]!!),
+ apiFile = options[PARAM_API_FILE]?.let(::File),
dependencyArtifactsDir = File(
(options[PARAM_DEPENDENCY_ARTIFACTS_DIR] ?:
options[LEGACY_PARAM_DEPENDENCY_ARTIFACTS_DIR])!!),