Per l'utente Gradle
Ho lo stesso problema quando sto iniziando a lavorare con Gradle. Voglio compilare il mio parsimonia con il compilatore di parsimonia remoto (personalizzato dalla mia azienda).
seguito è riportato come ho risolto il mio problema:
task compileThrift {
doLast {
def projectLocation = projectDir.getAbsolutePath(); // HERE is what you've been looking for.
ssh.run {
session(remotes.compilerServer) {
// Delete existing thrift file.
cleanGeneratedFiles()
new File("$projectLocation/thrift/").eachFile() { f ->
def fileName=f.getName()
if(f.absolutePath.endsWith(".thrift")){
put from: f, into: "$compilerLocation/$fileName"
}
}
execute "mkdir -p $compilerLocation/gen-java"
def compileResult = execute "bash $compilerLocation/genjar $serviceName", logging: 'stdout', pty: true
assert compileResult.contains('SUCCESSFUL')
get from: "$compilerLocation/$serviceName" + '.jar', into: "$projectLocation/libs/"
}
}
}
}
fonte
2018-01-30 08:05:36
Interessante. Non funziona come mi aspettavo. Ma questo è dovuto al fatto che sto eseguendo uno script gant di Gant. Quindi il codeSource è in realtà dove gant è, non dove è il mio script. –
Non funziona per me. 'getClass(). protectionDomain.codeSource' restituisce null. Sto usando Groovy 2.0.1. – quux00
Non funziona su Groovy 1.8.5 (su Windows) – Fels