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

ai.digital.integration.server.util.SatelliteUtil.groovy Maven / Gradle / Ivy

The newest version!
package ai.digital.integration.server.util


import ai.digital.integration.server.domain.Satellite
import org.gradle.api.Project

import java.nio.file.Paths

import static ai.digital.integration.server.constant.PluginConstant.DIST_DESTINATION_NAME

class SatelliteUtil {

    static def hasSatellites(Project project) {
        getSatellites(project).size() > 0
    }

    static List getSatellites(Project project) {
        ExtensionUtil.getExtension(project).satellites.collect { Satellite satellite ->
            enrichSatellite(project, satellite)
        }
    }

    private static Satellite enrichSatellite(Project project, Satellite satellite) {
        satellite.setDebugPort(getDebugPort(project, satellite))
        satellite.setVersion(getServerVersion(project, satellite))
        satellite
    }

    static def getSatelliteWorkingDir(Project project, Satellite satellite) {
        def targetDir = project.buildDir.toPath().resolve(DIST_DESTINATION_NAME).toAbsolutePath().toString()
        Paths.get(targetDir, "xl-satellite-server-${satellite.version}").toAbsolutePath().toString()
    }

    static def getBinDir(Project project, Satellite satellite) {
        Paths.get(getSatelliteWorkingDir(project, satellite), "bin").toFile()
    }

    static def getSatelliteLog(Project project, Satellite satellite) {
        project.file("${getSatelliteWorkingDir(project, satellite)}/log/xl-satellite.log")
    }

    private static String getServerVersion(Project project, Satellite satellite) {
        project.hasProperty("xlSatelliteVersion") ? project.property("xlSatelliteVersion") : satellite.version
    }

    private static Integer getDebugPort(Project project, Satellite satellite) {
        project.hasProperty("satelliteDebugPort") ? Integer.valueOf(project.property("satelliteDebugPort").toString()) : satellite.debugPort
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy