我们会看到文件:pom.xml以及README.txt,其中README.txt介绍如何使用maven来编译protobuf源码的过程,原文如下:
1) Install Apache Maven if you don't have it: http://maven.apache.org/ 2) Build the C++ code, or obtain a binary distribution of protoc. If you install a binary distribution, make sure that it is the same version as this package. If in doubt, run: $ protoc --version You will need to place the protoc executable in ../src. (If you built it yourself, it should already be there.) 3) Run the tests: $ mvn test If some tests fail, this library may not work correctly on your system. Continue at your own risk. 4) Install the library into your Maven repository: $ mvn install 5) If you do not use Maven to manage your own build, you can build a .jar file to use: $ mvn package The .jar will be placed in the "target" directory. Installation - 'Lite' Version - With Maven
如果你尚未安装maven环境,你可以到上文中描述的地址先下载maven,下载地址:
http://maven.apache.org/
为满足当前的编译需要,你仅需要配置一个MAVEN_HOME,并指定一个maven.bin的的目录即可,如:
在windows系统环境变量内增加:
1、MAVEN_HOME=x:/apache-maven-3.0.5
2、path=%MAVEN_HOME%/bin;
接下来就可以按照README.txt描述的步骤逐一执行即可得到protobuf-java-2.5.0.jar,该文件会保存在当前目录下的target目录内。