com.vk.gradle.plugin.compose.utils.settings.Setting.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gradle-plugin Show documentation
Show all versions of gradle-plugin Show documentation
Gradle plugins for Jetpack Compose
package com.vk.gradle.plugin.compose.utils.settings
import com.vk.gradle.plugin.composable.skippability.checker.ComposableSkippabilityCheckerExtension
import com.vk.gradle.plugin.compose.source.information.cleaner.SourceInformationCleanerExtension
import com.vk.gradle.plugin.compose.test.tag.applier.ComposeTestTagApplierExtension
import com.vk.gradle.plugin.compose.test.tag.cleaner.ComposeTestTagCleanerExtension
import com.vk.gradle.plugin.compose.test.tag.drawer.ComposeTestTagDrawerExtension
import com.vk.gradle.plugin.recompose.highlighter.RecomposeHighlighterExtension
import com.vk.gradle.plugin.recompose.logger.RecomposeLoggerExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.getByType
// properties are sorted in applying order
@SettingsMarker
sealed class Setting {
open val isEnabled: Boolean = false
internal abstract fun setup(project: Project)
}
class StrongSkippingSetting : Setting() {
override var isEnabled: Boolean = true
@JvmField
var strongSkippingFailFastEnabled = false
override fun setup(project: Project) {
project.extensions.getByType().apply {
strongSkippingEnabled = [email protected]
strongSkippingFailFastEnabled = [email protected]
}
}
}
class RecomposeLoggerSetting : Setting() {
override var isEnabled: Boolean = true
@JvmField
var logModifierChanges = true
@JvmField
var logFunctionChanges = false
override fun setup(project: Project) {
project.extensions.getByType().isEnabled = isEnabled
project.extensions.getByType().logModifierChanges = logModifierChanges
project.extensions.getByType().logFunctionChanges = logFunctionChanges
}
}
class RecomposeSetting : Setting() {
override val isEnabled: Boolean = true
private var loggerSetting = RecomposeLoggerSetting()
@JvmField
var isHighlighterEnabled = false
@JvmField
var isLoggerEnabled = false
override fun setup(project: Project) {
project.extensions.getByType().isEnabled = isHighlighterEnabled
if (isLoggerEnabled) {
loggerSetting.setup(project)
}
}
fun Project.logger(configure: RecomposeLoggerSetting.() -> Unit) {
loggerSetting.apply(configure)
loggerSetting.setup(this)
}
}
class TestTagApplierSetting : Setting() {
override var isEnabled: Boolean = true
@JvmField
var tagTemplate = ""
override fun setup(project: Project) {
project.extensions.getByType().apply {
isEnabled = [email protected]
tagTemplate = [email protected]
}
}
}
class TestTagSetting : Setting() {
override val isEnabled: Boolean = true
private var applierSetting = TestTagApplierSetting()
@JvmField
var isApplierEnabled = false
@JvmField
var isCleanerEnabled = false
@JvmField
var isDrawerEnabled = false
override fun setup(project: Project) {
if (isApplierEnabled) {
applierSetting.setup(project)
}
project.extensions.getByType().isEnabled = isCleanerEnabled
project.extensions.getByType().isEnabled = isDrawerEnabled
}
fun Project.tagApplier(configure: TestTagApplierSetting.() -> Unit) {
applierSetting.apply(configure)
applierSetting.setup(this)
}
}
class SourceInfoCleanSetting : Setting() {
override var isEnabled: Boolean = true
override fun setup(project: Project) {
project.extensions.getByType().isEnabled = isEnabled
}
}
class SkippabilityChecksSetting : Setting() {
override var isEnabled: Boolean = true
private val strongSkippingSetting = StrongSkippingSetting()
@JvmField
var stabilityConfigurationPath: String? = null
@JvmField
var strongSkippingEnabled = false
override fun setup(project: Project) {
project.extensions.getByType().apply {
stabilityConfigurationPath = [email protected]
isEnabled = [email protected]
}
if (strongSkippingEnabled) {
strongSkippingSetting.setup(project)
}
}
fun Project.strongSkipping(configure: StrongSkippingSetting.() -> Unit) {
strongSkippingSetting.apply(configure)
strongSkippingSetting.setup(this)
}
}