ai.digital.integration.server.deploy.internals.EnvironmentUtil.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of integration-server-gradle-plugin Show documentation
Show all versions of integration-server-gradle-plugin Show documentation
The easy way to get custom setup for Deploy up and running
package ai.digital.integration.server.deploy.internals
import ai.digital.integration.server.deploy.domain.Cli
import ai.digital.integration.server.common.domain.Server
import ai.digital.integration.server.common.util.OsUtil
import ai.digital.integration.server.common.util.TlsUtil
import org.gradle.api.Project
import java.io.File
class EnvironmentUtil {
companion object {
fun getServerEnv(project: Project,server: Server): MutableMap {
return getEnv(project, "JDK_JAVA_OPTIONS", server.debugSuspend, server.debugPort, null)
}
fun getCliEnv(project: Project, cli: Cli, extraParams: Map, extraClassPath: List, auxiliaryServer: Boolean = false): Map {
val env = getEnv(project, "JDK_JAVA_OPTIONS", cli.debugSuspend, cli.debugPort, null, extraParams, auxiliaryServer)
env["EXTRA_DEPLOYIT_CLI_CLASSPATH"] = extraClassPath.joinToString(separator = OsUtil.getPathSeparator())
return env
}
fun getEnv(
project: Project,
variableName: String,
debugSuspend: Boolean,
debugPort: Int?,
logFileName: String?
): MutableMap {
return getEnv(project, variableName, debugSuspend, debugPort, logFileName, mutableMapOf())
}
fun getEnv(
project: Project,
variableName: String,
debugSuspend: Boolean,
debugPort: Int?,
logFileName: String?,
extraProps: Map,
auxiliaryServer: Boolean = false
): MutableMap {
var opts = if (!logFileName.isNullOrEmpty()) "-Xmx1024m -DLOGFILE=\"$logFileName\"" else "-Xmx1024m"
debugPort?.let {
opts = "$opts ${DeployServerUtil.createDebugString(debugSuspend, it)} "
}
if (!auxiliaryServer && DeployServerUtil.isTls(project)) {
val tls = TlsUtil.getTls(project, DeployServerUtil.getServerWorkingDir(project))
opts = "$opts -Djavax.net.ssl.trustStore=\"${tls?.trustStoreFile()}\" -Djavax.net.ssl.trustStorePassword=\"${tls?.truststorePassword}\" "
}
opts += extraProps
.filterValues { it != null }
.map { "-D${it.key}=\"${it.value}\"" }
.joinToString(separator = " ")
return mutableMapOf(
variableName to opts
)
}
}
}