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

ai.digital.integration.server.deploy.tasks.centralConfiguration.CentralConfigurationServerYamlPatchTask.kt Maven / Gradle / Ivy

There is a newer version: 23.3.0-1025.941
Show newest version
package ai.digital.integration.server.deploy.tasks.centralConfiguration

import ai.digital.integration.server.common.constant.PluginConstant
import ai.digital.integration.server.deploy.internals.CentralConfigurationServerUtil
import ai.digital.integration.server.common.util.YamlFileUtil
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction
import java.io.File

open class CentralConfigurationServerYamlPatchTask : DefaultTask() {
    companion object {
        const val NAME = "centralConfigurationServerYamlPatch"
    }

    init {
        this.group = PluginConstant.PLUGIN_GROUP
        this.onlyIf {
            CentralConfigurationServerUtil.hasCentralConfigurationServer(project)
        }

        this.mustRunAfter(PrepareCentralConfigurationServerTask.NAME)
        this.mustRunAfter(CentralConfigurationServerOverlaysTask.NAME)
    }

    @TaskAction
    fun yamlPatches() {
        val server = CentralConfigurationServerUtil.getCentralConfigurationServer(project)
        project.logger.lifecycle("Applying patches on YAML files for ${server.name}.")

        server.yamlPatches.forEach { yamlPatch ->
            val file = File("${CentralConfigurationServerUtil.getServerPath(project, server)}/${yamlPatch.key}")
            YamlFileUtil.overlayFileWithJackson(file, yamlPatch.value.toMutableMap())
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy