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

ai.digital.integration.server.common.cache.StartCacheTask.kt Maven / Gradle / Ivy

There is a newer version: 23.3.0-1025.941
Show newest version
package ai.digital.integration.server.common.cache

import ai.digital.integration.server.common.constant.PluginConstant
import ai.digital.integration.server.common.util.CacheUtil
import com.palantir.gradle.docker.DockerComposeUp
import org.gradle.api.tasks.InputFiles
import org.gradle.api.tasks.TaskAction
import java.io.File

abstract class StartCacheTask: DockerComposeUp() {

    companion object {
        const val NAME = "startCache"
    }

    init {
        this.group = PluginConstant.PLUGIN_GROUP
        this.onlyIf {
            CacheUtil.isCacheEnabled(project)
        }
    }

    override fun getDescription(): String {
        return "Starts Cache Server using `docker-compose` and ${CacheUtil.getComposeFileRelativePath()} file."
    }

    @InputFiles
    override fun getDockerComposeFile(): File {
        return project.file(CacheUtil.getResolvedDockerFile(project))
    }

    @TaskAction
    override fun run() {
        project.logger.lifecycle("Starting Cache Server.")

        project.exec {
            executable = "docker-compose"
            args = arrayListOf("-f",
                    dockerComposeFile.path,
                    "--project-directory",
                    CacheUtil.getBaseDirectory(project),
                    "up",
                    "-d")
        }

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy