显示标签为“Lucene”的博文。显示所有博文
显示标签为“Lucene”的博文。显示所有博文

2007年4月17日

Build Lucene 2.1.0 from Scratch in Eclipse Under Windows

Main steps:
1、Download JDK from http://java.sun.com/
2、Install JDK.
3、Download source code Lucene 2.1.0 from its official site: http://lucene.apache.org/
4、Extract files from archieve package to D:\test\lucene-2.1.0(I choose this directory only for demonstration, you can change to anywhere you like,but you must make corresponding changes below).

5、Got Eclipse from http://www.eclipse.org/
And extract it to D:\Eclipse

6、launch your Eclipse. And then click menus or buttons as following:
File=>New=>Project...(Select Java->Java Project, Then click Next)=>Select the option "Create project from existing place" and then press Browse button to select the project directory. I set it to D:\test\lucene-2.1.0, And set the project name "lucene-2.1.0". Click Next=>Finish.
7、Now, You will got the new project named "lucene-2.1.0" in your Package Explorer.
Eclipse IDE will build the Java files automatically and there are may be some errors.Please don't mind about that.Just continue.
8、Select the project "lucene" in your workspace. the
click menus or buttons as following:
Run=>External tools=>External tools...
The wizard has already configured the build task for you? Right.
You can see one node named "lucene" in the Ant Build.
Press Run you will launch the build process.
At last, I got the messages as I show in the last article in Eclipse Console.

9、May be you will build failed. Please check JAVA_HOME environment variable. It must point to your Java Development Kit directory. If not,set one.
Or change the JRE of Ant in External tools wizard. I do not encounter this. So I do not show how to solve it in detail. If you have any question. Feel free to contact me or comment this article.


Build Lucene 2.1.0 from scratch under Linux

In this Linux version, all operations are excecuted by command line.
And I will also give a Windows version build.
The build process on Windows can be finished the same as on Linux using command line. But I will show how to get the last result using Eclipse and Ant integrated with Eclipse.

Main steps:
1、Download JDK from http://java.sun.com/
2、Install JDK.
3、Download source code Lucene 2.1.0 from its official site: http://lucene.apache.org/
4、Extract files from archieve package.
tar -zxvf lucene-2.1.0.tar.gz

5、Got build tool Ant from http://ant.apache.org/

if you already have an old version of Ant(before 1.6.2, like 1.5.2-23), the build process will be failed. The error message is:
BUILD FAILED
file:/usr/home/test/code/lucene-2.1.0/build.xml:7: Unexpected element "import"
please use "ant -v " to check your ant version.

The lastest Ant version is 1.7.0, I download the zip file and use it to show how to finish the left build steps.
wget http://apache.mirrors.redwire.net/ant/binaries/apache-ant-1.7.0-bin.zip
unzip
apache-ant-1.7.0-bin.zip

Now, It's time to build! Change your directory to lucene directory: /usr/home/test/code/lucene-2.1.0
For instance, ant is under the code directory. use command
../apache-ant-1.7.0/bin/ant

If no exception ,you will got the following messages:
Buildfile: build.xml

javacc-uptodate-check:

javacc-notice:

init:

clover.setup:

clover.info:
[echo]
[echo] Clover not found. Code coverage reports disabled.
[echo]

clover:

common.compile-core:
[mkdir] Created dir: /usr/home/test/code/lucene-2.1.0/build/classes/java
[javac] Compiling 204 source files to /usr/home/wuxing/code/lucene-2.1.0/build/classes/java
[javac] Note: * uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.

compile-core:
[rmic] RMI Compiling 1 class to /usr/home/test/code/lucene-2.1.0/build/classes/java

jar-core:
[jar] Building jar: /usr/home/test/code/lucene-2.1.0/build/lucene-core-2.1.1-dev.jar

default:

BUILD SUCCESSFUL
Total time: 10 seconds



Easy? Are you got it,haha