Mac Apache Ant version 1.8.2 instead of 1.9.6

别来无恙 提交于 2019-12-25 07:43:13

问题


I've downloaded the last apache ant version on my Mac but the version seems the old one. Any idea?

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

here the relative export variables.

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$ 

here one more command what the core tasks mean?

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.

I've tried to uninstall and install ANT again from brew, but the problem is still the same

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

回答1:


I realized after relooking at the post, that you tried to install ant, it has downloaded ant 1.9.7 version and extraction seemed to be /usr/local/Cellar/ant/1.9.7.

Or you may use the downloaded directory which is /Users/mauri/Downloads/apache-ant-1.9.6

So, all you need to do is to set the environment variables to the right installation path.

Run the following commands on the terminal.

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

Now ant -v should give right result.

Note that the above changes are only for the command session. If you want to apply it permanently, then update the same in your ~/.bash_profile file.

UPDATE:
If the is continue to persist(i.e., referring to older version of ant), it is possible to have softlink to older version. Try to remove that.




回答2:


I'm still trying to the reason behind that, but The Ant wrapper script sources some files from /etc if present, so the global installation may leak into your setup regardless. I guess the key is

core tasks  : 1.8.2 in

file:/Library/Java/Extensions/selenium-html-runner-3.0.1.jar" - whatever has put Selenium there, it takes precedence. I want to thank Stefan Bodewig from Apache ANT for this great insight

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


来源:https://stackoverflow.com/questions/41132033/mac-apache-ant-version-1-8-2-instead-of-1-9-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!