【发布时间】:2014-10-13 13:15:33
【问题描述】:
我想通过将类路径导出到 $CLASSPATH 来与外部应用程序 (VIM) 共享 gradle 创建的类路径。我已经尝试通过调用 gradle 并设置变量在 shell 中执行此操作,但是有一堆额外的输出使这很麻烦。我还通过 gradle 脚本查看了 shelling 命令,但这似乎创建了一个新的 shell 实例,因此不会影响当前 shell 的环境变量。
有没有人有过这方面的经验?感谢您的帮助!
我认为一个例子将有助于澄清:
task classpath {
classpathcmd = "export CLASSPATH=" + sourceSets.test.runtimeClasspath.asPath
// Prints too much extra text
println classpathcmd
// Executes command in another shell instance so the variable is "lost"
exec {
executable = "sh"
args = classpathcmd
}
// Stracktrace because of file not found exception
exec {
commandLine classpathcmd
}
}
【问题讨论】: