com.avito.test.gradle.plugin.PluginsSpec.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of test-project Show documentation
Show all versions of test-project Show documentation
Collection of infrastructure libraries and gradle plugins of Avito Android project
package com.avito.test.gradle.plugin
import com.avito.test.gradle.dependencies.GradleScriptCompatible
/**
* Analogue of [org.gradle.plugin.use.PluginDependenciesSpec]
* Use [plugins] to create an instance
*/
public class PluginsSpec(
private val plugins: MutableList = mutableListOf()
) : GradleScriptCompatible {
override fun getScriptRepresentation(): String {
return """|plugins {
| ${plugins.joinToString(separator = "\n ") { it.getScriptRepresentation() }}
|}""".trimMargin()
}
override fun toString(): String = getScriptRepresentation()
public fun id(id: String): PluginSpec {
val spec = PluginSpec(id)
plugins.add(spec)
return spec
}
public fun plus(other: PluginsSpec): PluginsSpec {
return PluginsSpec((this.plugins + other.plugins).toMutableList())
}
}
public fun plugins(init: PluginsSpec.() -> Unit = {}): PluginsSpec {
val plugins = PluginsSpec()
plugins.init()
return plugins
}