com.javiersc.hubdle.project.extensions.kotlin.android.features.HubdleKotlinAndroidBuildFeaturesExtension.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hubdle-gradle-plugin Show documentation
Show all versions of hubdle-gradle-plugin Show documentation
Single entry point to configurate any kind of project
package com.javiersc.hubdle.project.extensions.kotlin.android.features
import com.javiersc.gradle.properties.extensions.getBooleanProperty
import com.javiersc.hubdle.project.extensions.HubdleDslMarker
import com.javiersc.hubdle.project.extensions._internal.getHubdleExtension
import com.javiersc.hubdle.project.extensions.android._internal.configureAndroidCommonExtension
import com.javiersc.hubdle.project.extensions.apis.HubdleConfigurableExtension
import com.javiersc.hubdle.project.extensions.apis.HubdleEnableableExtension
import com.javiersc.hubdle.project.extensions.kotlin.android.application.hubdleAndroidApplication
import com.javiersc.hubdle.project.extensions.kotlin.android.library.hubdleAndroidLibrary
import com.javiersc.hubdle.project.extensions.kotlin.multiplatform.targets.hubdleKotlinMultiplatformAndroid
import javax.inject.Inject
import org.gradle.api.Project
import org.gradle.api.provider.Property
@HubdleDslMarker
public open class HubdleKotlinAndroidBuildFeaturesExtension @Inject constructor(project: Project) :
HubdleConfigurableExtension(project) {
override val isEnabled: Property = property { true }
override val oneOfExtensions: Set
get() =
setOf(hubdleAndroidApplication, hubdleAndroidLibrary, hubdleKotlinMultiplatformAndroid)
public val aidl: Property = property {
getBooleanProperty(BuildFeatures.aidl).orElse(trueIfApp()).get()
}
public val buildConfig: Property = property {
getBooleanProperty(BuildFeatures.buildConfig).orElse(trueIfApp()).get()
}
public val compose: Property = property {
getBooleanProperty(BuildFeatures.compose).orElse(false).get()
}
public val renderScript: Property = property {
getBooleanProperty(BuildFeatures.renderScript).orElse(trueIfApp()).get()
}
public val resValues: Property = property {
getBooleanProperty(BuildFeatures.resValues).orElse(trueIfApp()).get()
}
public val shaders: Property = property {
getBooleanProperty(BuildFeatures.shaders).orElse(trueIfApp()).get()
}
public val viewBinding: Property = property {
getBooleanProperty(BuildFeatures.viewBinding).orElse(false).get()
}
override fun Project.defaultConfiguration() {
lazyConfigurable {
val feats = this@HubdleKotlinAndroidBuildFeaturesExtension
configureAndroidCommonExtension {
buildFeatures.aidl = feats.aidl.get()
buildFeatures.buildConfig = feats.buildConfig.get()
buildFeatures.compose = feats.compose.get()
buildFeatures.renderScript = feats.renderScript.get()
buildFeatures.resValues = feats.resValues.get()
buildFeatures.shaders = feats.shaders.get()
buildFeatures.viewBinding = feats.viewBinding.get()
}
}
}
public object BuildFeatures {
public const val aidl: String = "android.defaults.buildfeatures.aidl"
public const val buildConfig: String = "android.defaults.buildfeatures.buildconfig"
public const val compose: String = "android.defaults.buildfeatures.compose"
public const val renderScript: String = "android.defaults.buildfeatures.renderscript"
public const val resValues: String = "android.defaults.buildfeatures.resvalues"
public const val shaders: String = "android.defaults.buildfeatures.shaders"
public const val viewBinding: String = "android.defaults.buildfeatures.viewbinding"
}
}
private fun HubdleEnableableExtension.trueIfApp(): Boolean =
hubdleAndroidApplication.isFullEnabled.get()
internal val HubdleEnableableExtension.hubdleAndroidBuildFeatures:
HubdleKotlinAndroidBuildFeaturesExtension
get() = getHubdleExtension()