Mac Apache Ant版本1.8.2而不是1.9.6

时间:2016-12-13 22:59:35

标签: apache ant

我已经在我的Mac上下载了最后一个apache ant版本,但版本似乎是旧版本。 有什么想法吗?

myMac:~ mauri$ brew install ant
==> Downloading https://homebrew.bintray.com/bottles/ant-1.9.7.el_capitan.bottle.tar.gz
######################################################################## 100,0%
==> Pouring ant-1.9.7.el_capitan.bottle.tar.gz
  /usr/local/Cellar/ant/1.9.7: 1,611 files, 34.9M
myMac:~ mauri$ 
myMac:~ mauri$ ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
myMac:~ mauri$ 
myMac:~ mauri$ ./Downloads/apache-ant-1.9.6/bin/ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
myMac:~ mauri$ uname -a
Darwin myMac 15.6.0 Darwin Kernel Version 15.6.0: Mon Aug 29 20:21:34 PDT 2016; root:xnu-3248.60.11~1/RELEASE_X86_64 x86_64

这里是相对的出口变量。

myMac:~ mauri$ export ANT_HOME=/Users/mauri/Downloads/apache-ant-1.9.6
myMac:~ mauri$ export CLASSPATH=$ANT_HOME/lib:$CLASSPATH
myMac:~ mauri$ export PATH=$ANT_HOME/bin:$PATH
myMac:~ mauri$ ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
myMac:~ mauri$ /Users/mauri/Downloads/apache-ant-1.9.6/bin/ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
myMac:~ mauri$ which ant
/Users/mauri/Downloads/apache-ant-1.9.6/bin/ant
myMac:~ mauri$ 

这里还有一个命令核心任务是什么意思?

myMac:~mauri $ ant -diagnostics

------- Ant diagnostics report -------
Apache Ant(TM) version 1.8.2 compiled on December 20 2010

-------------------------------------------
 Implementation Version
-------------------------------------------
core tasks     : 1.8.2 in file:/Library/Java/Extensions/selenium-html-runner-3.0.1.jar

-------------------------------------------
 ANT PROPERTIES
-------------------------------------------
ant.version: Apache Ant(TM) version 1.8.2 compiled on December 20 2010
ant.java.version: 1.7
Is this the Apache Harmony VM? no
Is this the Kaffe VM? no
Is this gij/gcj? no
ant.core.lib: /Library/Java/Extensions/selenium-html-runner-3.0.1.jar
ant.home: /usr/local/Cellar/ant/1.9.7

-------------------------------------------
 ANT_HOME/lib jar listing
-------------------------------------------
ant.home: /usr/local/Cellar/ant/1.9.7
No such directory.

-------------------------------------------
 USER_HOME/.ant/lib jar listing
-------------------------------------------
user.home: /Users/mauri
No such directory.

我已经尝试从brew中再次卸载并安装ANT,但问题仍然是相同的

myMac:OrgSight mauri$ brew uninstall ant
Uninstalling /usr/local/Cellar/ant/1.9.7... (1,611 files, 34.9M)
myMac:OrgSight mauri$ brew install ant
==> Downloading https://homebrew.bintray.com/bottles/ant-1.9.7.el_capitan.bottle.tar.gz
Already downloaded: /Users/mauri/Library/Caches/Homebrew/ant-1.9.7.el_capitan.bottle.tar.gz
==> Pouring ant-1.9.7.el_capitan.bottle.tar.gz
  /usr/local/Cellar/ant/1.9.7: 1,611 files, 34.9M
myMac:OrgSight mauri$ which ant
/usr/local/bin/ant
myMac:OrgSight mauri$ ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
myMac:OrgSight mauri$ /usr/local/Cellar/ant/1.9.7/bin/ant -version
Apache Ant(TM) version 1.8.2 compiled on December 20 2010

2 个答案:

答案 0 :(得分:0)

我在重新审视帖子后意识到,您尝试安装ant,它已下载ant 1.9.7版本,并且提取似乎是/usr/local/Cellar/ant/1.9.7

或者您可以使用下载的目录/Users/mauri/Downloads/apache-ant-1.9.6

因此,您需要做的就是将环境变量设置为正确的安装路径。

在终端上运行以下命令。

export ANT_HOME=/Users/mauri/Downloads/apache-ant-1.9.6
export CLASSPATH=$ANT_HOME/lib:$CLASSPATH
export PATH=$ANT_HOME/bin:$PATH

现在ant -v应该给出正确的结果。

请注意,上述更改仅适用于命令会话。如果您想永久应用它,请在~/.bash_profile文件中更新相同内容。

<强>更新
如果继续存在(即,指的是较旧版本的ant),则可以使用旧版本的软链接。尝试删除它。

答案 1 :(得分:0)

我仍在尝试这背后的原因,但是Ant包装器脚本从/ etc中获取一些文件(如果存在),因此无论如何全局安装都可能泄漏到您的设置中。我猜关键是

core tasks  : 1.8.2 in

file:/Library/Java/Extensions/selenium-html-runner-3.0.1.jar“ - 无论有什么 把Selenium放在那里,它优先。 我要感谢来自Apache ANT的Stefan Bodewig的这一伟大见解

myMac:~ mauri$ cd /Library/Java/Extensions
myMac:Extensions mauri$ l
total 30536
-rw-r--r--@ 1 root  wheel    15M  4 Dez 12:12 selenium-html-runner-3.0.1.jar
myMac:Extensions mauri$ mv selenium-html-runner-3.0.1.jar ~/
myMac:Extensions mauri$ which ant
/Users/mauri/Downloads/apache-ant-1.9.6/bin/ant
myMac:Extensions mauri$ ant -version
Apache Ant(TM) version 1.9.6 compiled on June 29 2015