All Downloads are FREE. Search and download functionalities are using the official Maven repository.

main.name.remal.gradle_plugins.utils.org.gradle.api.Project.kt Maven / Gradle / Ivy

There is a newer version: 1.9.2
Show newest version
package name.remal.gradle_plugins.utils

import name.remal.gradle_plugins.api.BuildTimeConstants.getStringProperties
import name.remal.gradle_plugins.dsl.extensions.unwrapProviders
import name.remal.nullIfEmpty
import org.gradle.api.Project

private val versionProperties = getStringProperties("*.version").mapKeys { it.key.substring(0, it.key.length - ".version".length) }

internal fun Project.findVersionProperty(id: String): String? {
    findProperty("$id.version").unwrapProviders()?.toString().nullIfEmpty()?.let { return it }
    versionProperties[id]?.let { return it }
    return null
}

internal fun Project.getVersionProperty(id: String): String {
    return findVersionProperty(id) ?: throw IllegalArgumentException("Version can't be found: $id")
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy