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

com.toasttab.expediter.gradle.config.IgnoreSpec.kt Maven / Gradle / Ivy

There is a newer version: 0.0.22
Show newest version
package com.toasttab.expediter.gradle.config

import com.toasttab.expediter.ignore.Ignore
import org.slf4j.LoggerFactory

open class IgnoreSpec {
    companion object {
        private val LOGGER = LoggerFactory.getLogger(PlatformSpec::class.java)
    }

    var file: Any? = null
        set(value) {
            LOGGER.warn("file property is deprecated, use the file function instead: ignore { file('path') }")
            value?.let(files::add)
        }

    val files = mutableListOf()

    val ignores = mutableListOf()

    fun file(file: Any) {
        files.add(file)
    }

    fun targetStartsWith(vararg partial: String) = or(Ignore.TargetStartsWith(*partial))

    fun callerStartsWith(vararg partial: String) = or(Ignore.CallerStartsWith(*partial))

    fun or(ignore: Ignore) {
        ignores.add(ignore)
    }

    fun buildIgnore() = if (ignores.isEmpty()) {
        Ignore.NOTHING
    } else if (ignores.size == 1) {
        ignores[0]
    } else {
        Ignore.Or(*ignores.toTypedArray())
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy