Dla Gradle użytkownik
Mam ten sam problem, kiedy zaczynam pracę z Gradle. Chcę skompilować moją oszczędność przez zdalny kompilator oszczędzania (na zamówienie mojej firmy).
Poniżej jak to rozwiązać mój problem:
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/"
}
}
}
}
Interesujące. Nie działa tak, jak tego oczekiwałem. Ale wynika to z faktu, że używam skryptu z Ganta. Tak więc kodSource jest w rzeczywistości tym, gdzie jest Gant, a nie gdzie jest mój skrypt. –
Nie działa dla mnie. 'getClass(). protectionDomain.codeSource' zwraca null. Używam Groovy 2.0.1. – quux00
Nie działa na Groovy 1.8.5 (na windows) – Fels