From eb892da093fd9d1932a4404166f3af045229dd3e Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 26 Aug 2022 16:42:18 +0800 Subject: [PATCH] [build] Fix build when `local.properties` not found --- buildSrc/src/main/kotlin/LocalProperties.kt | 2 +- settings.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/kotlin/LocalProperties.kt b/buildSrc/src/main/kotlin/LocalProperties.kt index 046ba3cda..34834150f 100644 --- a/buildSrc/src/main/kotlin/LocalProperties.kt +++ b/buildSrc/src/main/kotlin/LocalProperties.kt @@ -31,7 +31,7 @@ private lateinit var localProperties: Properties private fun Project.loadLocalPropertiesIfAbsent() { if (::localProperties.isInitialized) return localProperties = Properties().apply { - rootProject.projectDir.resolve("local.properties").bufferedReader().use { + rootProject.projectDir.resolve("local.properties").takeIf { it.exists() }?.bufferedReader()?.use { load(it) } } diff --git a/settings.gradle.kts b/settings.gradle.kts index f3a4affb8..a1cc6c0f8 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -33,7 +33,7 @@ rootProject.name = "mirai" val localProperties = Properties().apply { - rootProject.projectDir.resolve("local.properties").bufferedReader().use { + rootProject.projectDir.resolve("local.properties").takeIf { it.exists() }?.bufferedReader()?.use { load(it) } }