对solr源码导入到eclipse过程做个整理和备份
1. 首先得有个eclipse
2. eclipse得有个svn插件
3. 链接solr的svn地址:http://svn.apache.org/repos/asf/lucene/dev/
4. 在tag中选择相应的源码check out
5. 进入solr目录,执行ant eclipse时如下错误:
ivy-availability-check:
ivy-fail:
[echo]
[echo] This build requires Ivy and Ivy could not be found in your ant classpath.
[echo]
[echo] (Due to classpath issues and the recursive nature of the Lucene/Solr
[echo] build system, a local copy of Ivy can not be used an loaded dynamically
[echo] by the build.xml)
[echo]
[echo] You can either manually install a copy of Ivy 2.3.0 in your ant classpath:
[echo] http://ant.apache.org/manual/install.html#optionalTasks
[echo]
[echo] Or this build file can do it for you by running the Ivy Bootstrap target:
[echo] ant ivy-bootstrap
[echo]
[echo] Either way you will only have to install Ivy one time.
[echo]
[echo] 'ant ivy-bootstrap' will install a copy of Ivy into your Ant User Library:
[echo] /Users/wenchanter/.ant/lib
[echo]
[echo] If you would prefer, you can have it installed into an alternative
[echo] directory using the "-Divy_install_path=/some/path/you/choose" option,
[echo] but you will have to specify this path every time you build Lucene/Solr
[echo] in the future...
[echo] ant ivy-bootstrap -Divy_install_path=/some/path/you/choose
[echo] ...
[echo] ant -lib /some/path/you/choose clean compile
[echo] ...
[echo] ant -lib /some/path/you/choose clean compile
[echo]
[echo] If you have already run ivy-bootstrap, and still get this message, please
[echo] try using the "--noconfig" option when running ant, or editing your global
[echo] ant config to allow the user lib to be loaded. See the wiki for more details:
[echo] http://wiki.apache.org/lucene-java/HowToContribute#antivy
[echo]
可见是需要先运行ant ivy-bootstrap
6. 这里是关键,使用eclipse自带的ant插件运行ant ivy-bootstrap容易出错,可以去ant官网下载部属本地ant环境,然后通过终端使用本地ant环境执行
ant ivy-bootstrap
这个过程等待时间会比较长,一般视网络情况而定,如果卡主时间过长可以停了重新开始。
7. 只有推荐仍然使用本地ant环境执行
ant eclipse
当然仍然是在solr目录下执行。
此处下载的是solr4.7.2版本,执行完成后会看到如下信息:
eclipse:
[copy] Copying 3 files to /Users/wenchanter/Documents/workspace/lucene_solr_4_7_2/.settings
[xslt] Processing /Users/wenchanter/Documents/workspace/lucene_solr_4_7_2/build.xml to /Users/wenchanter/Documents/workspace/lucene_solr_4_7_2/.classpath
[xslt] Loading stylesheet /Users/wenchanter/Documents/workspace/lucene_solr_4_7_2/dev-tools/eclipse/dot.classpath.xsl
[echo] SUCCESS: You must right-click your project and choose Refresh.
[echo] Your project must use a Java 6 JRE.
[echo]
BUILD SUCCESSFUL
注意其中[echo]的信息,需要使用Java 6 JRE或以上版本。
8.然后最关键的地方来了,官方说refresh一下项目即可,但是根本不好使,把项目删了重新import,依旧不好使。干掉classpath,重新import,重新building,都试了,不好使。
最后发现,删了项目,然后用new project,填写与solr相同的项目名,好使,百试百灵。