Como usar a saída exec () no gradle
Eu estou tentando implementar uma tarefa gradle para criar dinamicamente um arquivo buildsignature.properties de uma série de valores de variáveis de ambiente e execuções de shell. Eu tenho isso funcionando principalmente, mas não consigo obter a saída dos comandos do shell. Aqui está minha tarefa ...
task generateBuildSignature << {
ext.whoami = exec() {
executable = "whoami"
}
ext.hostname = exec() {
executable = "hostname"
}
ext.buildTag = System.env.BUILD_TAG ?: "dev"
ant.propertyfile(
file: "${buildDir}/buildsignature.properties",
comment: "This file is automatically generated - DO NOT EDIT!" ) {
entry( key: "version", value: "${project.version}" )
entry( key: "buildTimestamp", value: "${new Date().format('yyyy-MM-dd HH:mm:ss z')}" )
entry( key: "buildUser", value: "${ext.whoami}" )
entry( key: "buildSystem", value: "${ext.hostname}" )
entry( key: "buildTag", value: "$ext.buildTag" )
}
}
Mas o campo de propriedades resultante não obtém os resultados desejados para buildUser e buildSystem.
#This file is automatically generated - DO NOT EDIT!
#Mon, 18 Jun 2012 18:14:14 -0700
version=1.1.0
buildTimestamp=2012-06-18 18\:14\:14 PDT
buildUser=org.gradle.process.internal.DefaultExecHandle$ExecResultImpl@2e6a54f9
buildSystem=org.gradle.process.internal.DefaultExecHandle$ExecResultImpl@46f0bf3d
buildTag=dev
Como obtenho buildUser e buildSystem para corresponder à saída do exec correspondente, em vez de algum padrão ExecResultImpl toString? Isso realmente não pode ser tão difícil, pode?