我从某个自定义位置而不是从“本地”安装位置调用 Ant
在我的系统中(/usr/share/ant/bin/ant
)。令人惊讶的是,当我回显 ${ant.core.lib}
属性,我看到 Ant 无论如何都会从/usr/share/lib 中获取它。
例如使用以下 build.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<project name="foo" basedir=".">
<echo message="ant.core.lib: ${ant.core.lib}"/>
</project>
这就是我所看到的:
$ /some/other/location/apache/apache-ant-1.9.9/bin/ant
OpenJDK 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
Buildfile: /home/username/tmp/build.xml
[echo] ant.core.lib: /usr/share/java/ant/ant.jar
即使显式传递备用 -lib 位置(另一个 ant.jar 所在的位置),我仍然看到相同的内容:
$ /some/other/location/apache/apache-ant-1.9.9/bin/ant -lib /some/other/location/apache/apache-ant-1.9.9/lib
(same output as before)
Ant 如何决定如何设置 ${ant.core.lib}
属性的值以及我可以从哪里覆盖它以使 Ant
使用其他位置的 ant.jar?
最佳答案
在这种情况下,还必须在 shell 中设置环境变量 ANT_HOME。
然后,从 ${ANT_HOME}/lib/ant.jar
中获取 ${ant.core.lib}
。
关于java - 如何覆盖 ant.core.lib 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52228561/