在 ant 构建文件中获取 shell 配置文件?
我正在使用 Cruisecontrol 和 ant 构建一些旧版可执行文件,这些可执行文件也依赖于 shell 配置文件来正确设置环境变量。有没有办法在当前进程中使用 ant 执行此配置文件,以便 makefiles ant 调用正确获取环境变量?
另一个解决方案是是否有一种方法可以将配置文件源添加到我正在调用的子 make 文件中。
编辑:我想我的问题不清楚。我知道需要传递哪些环境变量才能使用 exec/env 任务。但是,我不知道如何让 ant 从通常通过 获取的 shell 配置文件中获取值。 /usr/local/profile/foo.profile
I am using cruisecontrol and ant to build some legacy executables that also depend on a shell profile to setup env vars properly. Is there a way to exec this profile using ant in the current process so the makefiles ant calls get the env vars correctly?
Another solution would be if there is a way to add the profile sourcing to the sub make files I'm calling.
Edit: I guess I wasn't clear in my question. I know what env varibles need to be passed to make using the exec/env tasks. However, I don't know how to have ant grab the values from a shell profile that is usually sourced via: . /usr/local/profile/foo.profile
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我根据 ant 本身如何获取环境变量找出了如何做到这一点。
再往下,我可以使用 exec 标签将它们传递给 sub make 调用。例如:
I figured out how to do it based off of how ant itself sources env variables.
Further down I can then pass them to sub make calls using the exec tags. For example:
您将无法在当前进程中执行 make。
看看ant
任务,使用它来执行您的make
构建。环境变量仍然可用于 make 过程,事实上您可以使用 newenvironment 属性显式关闭它。以下简单的 exec 应该保留 make 中的所有环境变量:如果您需要额外的环境变量,或者想要通过 ant 构建维护它们,您可以通过添加
元素在 exec 任务中使用它们像这样:You will not be able to execute make in the current process.
Take a look at the ant
<exec>
task, use this to execute yourmake
build. The environment variables will still be available for the make process, in fact you can turn this off explicitly with thenewenvironment
attribute. The following simple exec should retain all environment variables in make:If you need extra environment variables, or want to maintain them through your ant build you can use them in the exec task by adding
<env>
elements like so: