с#
Size: a a a
с#
с#
с#
VP
IP
VP
с#
VP
с#
с#
VP
с#
с#
с#
VP
VP
PS
abstract class DevPlatformAuthService : BuildService<DevPlatformAuthService.Params>, KLogging() {- пример. Ловлю ava.net.UnknownHostException. На таск в текущей итерации переделывать не очень хотелось бы
internal interface Params : BuildServiceParameters {
var workingDir: File
}
@get:OutputFile
abstract val dpOutputFile: RegularFileProperty
var dpVersion = "3.0.0"
private val dpName = object : OsSpecificAction<String> {
override fun onWindows() = "windows/dp.exe"
override fun onLinux() = "linux/dp"
override fun onMac() = "darwin/dp"
}.perform()
private val host = "https://наш-хост/cli/prod/dp/"
init {
dpOutputFile.get().asFile.also {
it.createNewFile()
it.setWritable(true)
it.writeBytes(URL("$host$dpVersion$dpName")
.openConnection().getInputStream().readBytes())
it.setExecutable(true)
}
}
fun token(): String {
logger.info("Try to get devPlatform token")
val apiKeyFile = getEnv("devplatform_api_key")
logger.info(runCommand("${dpOutputFile.asFile.get().absolutePath} auth service-acc --key-file $apiKeyFile"))
return runCommandSilent(
"${dpOutputFile.asFile.get().absolutePath} auth print-token"
)?.trim() ?: throw DevPlatformClientException("couldn't get token.")
}
class DevPlatformClientException(message: String) : Exception(message)
}
VS