下面针对Hadoop2.5.0源码讲解源码编译:
编译前的需求:
- Linux System
- JDK 1.6+
- Maven 3.0+
- Findbugs 1.3.9(if running findbugs)
- ProtocolBuffer 2.5.0
- CMake 2.6+(if compiling native code)
- Zlib devel(if compiling native code)
- openssl devel(if compiling native hadoop-pipes)
- Internet connection for first build(to fetch all Maven and Hadoop dependencies)
Maven main modules: hadoop(Main Hadoop Project)
- hadoop-project(Parent POM for all Hadoop Maven modules)
- hadoop-project-dist(Parent POM for modules that generate distributions)
- hadoop-annotations(Generates the Hadoop doclet used to generated the Javadocs)
- hadoop-assembiles(Maven assembiles used by the different modules)
- hadoop-common-project(Hadoop Common)
- hadoop-hdfs-project(Hadoop HDFS)
- hadoop-mapreduce-project(Hadoop MapReduce)
- hadoop-tools(Hadoop tools like Streaming, Distcp, etc)
- hadoop-dist(Hadoop distributions assembler)
Maven build goals:
- Clean: mvn clean
- Compile: mvn compile [-Pnative]
- Run tests: mvn test [-Pnative]
- Create JAR: mvn package
- Run findbugs: mvn compile fingbugs:findbugs
- Run checkstyle: mvn compile checkstyle:checkstyle
- Install JAR in M2 cache: mvn install
- Deploy JAR to Maven repo: mvn deploy
- Run clover: mvn test -Pclover [-DcloverLicenseLocation=${use.name}/.clover.license]
- Run Rat: mvn apache-rat:check
- Build javadocs: mvn javadoc:javadoc
- Build distribution: mvn package [-Pdist][-Pdocs][-Psrc][-Pnative][-Dtar]
- Change Hadoop version: mvn version:set -DnewVersion=NEWVERSION
Build options:
- Use -Pnative to compile/bundle native code
- Use -Pdocs to generate & bundle the documentation in the distribution(using -Pdist)
- Use -Psrc to create a project source TAR.GZ
- Use -Dtar to create a TAR with the distribution(using -Pdist)