gpt4 book ai didi

java - gradle设置外部类路径

转载 作者:行者123 更新时间:2023-12-03 06:20:12 24 4
gpt4 key购买 nike

我想通过将classpath导出到$ CLASSPATH来与外部应用程序(VIM)共享gradle创建的classpath。我尝试通过调用gradle和设置变量在shell中执行此操作,但是有很多额外的输出使此操作变得麻烦。我也通过gradle脚本查看了shell命令,但这似乎创建了一个新的shell实例,因此不会影响当前shell的env变量。

有没有人有完成此工作的经验?谢谢您的帮助!

我认为一个例子将有助于澄清:

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
}
}

最佳答案

您可以为此编写一个任务并调用它(可能使用--quiet),也可以使用Gradle工具API(可能来自vim插件)。

关于java - gradle设置外部类路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26340890/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com