Fix Windows Build Fail Error

This commit is contained in:
2022-02-17 22:51:23 +08:00
parent e8e29928d9
commit ff47e2be19

View File

@@ -162,24 +162,29 @@ class YukiHookXposedProcessor : SymbolProcessorProvider {
environment { environment {
if (codePath.isBlank()) error(msg = "Project CodePath not available") if (codePath.isBlank()) error(msg = "Project CodePath not available")
if (sourcePath.isBlank()) error(msg = "Project SourcePath not available") if (sourcePath.isBlank()) error(msg = "Project SourcePath not available")
val projectPath = when (File.separator) { val separator = when {
"\\" -> sourcePath.replace("/", "\\") codePath.contains("\\") -> "\\"
"/" -> sourcePath.replace("\\", "/") codePath.contains("/") -> "/"
else -> kotlin.error("Unix File Separator unknown")
}
val projectPath = when {
codePath.contains("\\") -> sourcePath.replace("/", "\\")
codePath.contains("/") -> sourcePath.replace("\\", "/")
else -> kotlin.error("Unix File Separator unknown") else -> kotlin.error("Unix File Separator unknown")
}.let { }.let {
if (codePath.contains(it)) if (codePath.contains(it))
codePath.split(it)[0] + it codePath.split(it)[0] + it
else error(msg = "Project Source Path \"$it\" not matched") else error(msg = "Project Source Path \"$it\" not matched")
} }
File("$projectPath${File.separator}assets").also { assFile -> File("$projectPath${separator}assets").also { assFile ->
if (File("$projectPath${File.separator}AndroidManifest.xml").exists()) { if (File("$projectPath${separator}AndroidManifest.xml").exists()) {
if (!assFile.exists() || !assFile.isDirectory) { if (!assFile.exists() || !assFile.isDirectory) {
assFile.delete() assFile.delete()
assFile.mkdirs() assFile.mkdirs()
} }
File("${assFile.absolutePath}${File.separator}xposed_init") File("${assFile.absolutePath}${separator}xposed_init")
.writeText(text = "$packageName.$className$xposedClassShortName") .writeText(text = "$packageName.$className$xposedClassShortName")
File("${assFile.absolutePath}${File.separator}yukihookapi_init") File("${assFile.absolutePath}${separator}yukihookapi_init")
.writeText(text = "$packageName.$className") .writeText(text = "$packageName.$className")
} else error(msg = "Project Source Path \"$sourcePath\" verify failed! Is this an Android Project?") } else error(msg = "Project Source Path \"$sourcePath\" verify failed! Is this an Android Project?")
} }