問題描述
操作系統升級後無法從 ANT 訪問環境變量 (Can't access env vars from ANT after OS upgrade)
A server was upgraded from Windows 2000 to Windows 2003 and now I can't access environment variables from Ant build scripts.
I can still access them fine from a command line, but ${env.JAVA_HOME}
for instance fails.
How can I fix this without rewriting ~100 build scripts that work on all other servers to be customized for this server?
參考解法
方法 1:
Unfortunately I don't think you should have been using that environment variable. To get around such problems there's the builtin ${java.home}
you could have been using, which isn't dependent on the operating system and/or user's environment being setup properly. (See the Ant manual discussion of built-in properties in Ant.)
You may be able to get around rewriting all your build scripts by either (1) setting the JAVA_HOME environment variable manually, or (2) modifying the ant.bat file to assign it manually. Both options are brittle because they'll break when Java gets upgraded, but at least they'll likely fail fast.
(by Tristan、Chris Winters)