我通常使用命令行(dos)中的这两个命令构建我的项目
G:\> cd c:
C:\> cd c:\my\directory\where\ant\exists
C:\my\directory\where\ant\exists> ant -Mysystem
...
.....
build successful
Run Code Online (Sandbox Code Playgroud)
如果我想从groovy做上述事情呢?groovy有execute()方法,但以下对我不起作用:
def cd_command = "cd c:"
def proc = cd_command.execute()
proc.waitFor()
Run Code Online (Sandbox Code Playgroud)
它给出了错误:
Caught: java.io.IOException: Cannot run program "cd": CreateProcess error=2, The
system cannot find the file specified
at ant_groovy.run(ant_groovy.groovy:2)
Run Code Online (Sandbox Code Playgroud)