Magisk/buildSrc/src/main/java/BuildSource.kt

26 lines
702 B
Kotlin
Raw Normal View History

2020-07-04 13:53:31 +00:00
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
2020-08-15 12:43:28 +00:00
import org.gradle.kotlin.dsl.provideDelegate
2020-07-04 13:53:31 +00:00
import java.io.File
import java.util.*
private val props = Properties()
object Config {
operator fun get(key: String) = props[key] as? String
fun contains(key: String) = props.containsKey(key)
}
class MagiskPlugin : Plugin<Project> {
override fun apply(project: Project) {
2020-08-15 12:43:28 +00:00
val configPath: String? by project
val file = configPath?.let { File(it) } ?: project.file("config.prop")
2020-07-04 13:53:31 +00:00
if (!file.exists())
throw GradleException("Please setup config.prop")
file.inputStream().use { props.load(it) }
}
}