BUILDING.txt 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. Build instructions for Hadoop
  2. ----------------------------------------------------------------------------------
  3. Requirements:
  4. * Unix System
  5. * JDK 1.6
  6. * Maven 3.0
  7. * Findbugs 1.3.9 (if running findbugs)
  8. * ProtocolBuffer 2.5.0
  9. * CMake 2.6 or newer (if compiling native code)
  10. * Internet connection for first build (to fetch all Maven and Hadoop dependencies)
  11. ----------------------------------------------------------------------------------
  12. Maven main modules:
  13. hadoop (Main Hadoop project)
  14. - hadoop-project (Parent POM for all Hadoop Maven modules. )
  15. (All plugins & dependencies versions are defined here.)
  16. - hadoop-project-dist (Parent POM for modules that generate distributions.)
  17. - hadoop-annotations (Generates the Hadoop doclet used to generated the Javadocs)
  18. - hadoop-assemblies (Maven assemblies used by the different modules)
  19. - hadoop-common-project (Hadoop Common)
  20. - hadoop-hdfs-project (Hadoop HDFS)
  21. - hadoop-mapreduce-project (Hadoop MapReduce)
  22. - hadoop-tools (Hadoop tools like Streaming, Distcp, etc.)
  23. - hadoop-dist (Hadoop distribution assembler)
  24. ----------------------------------------------------------------------------------
  25. Where to run Maven from?
  26. It can be run from any module. The only catch is that if not run from utrunk
  27. all modules that are not part of the build run must be installed in the local
  28. Maven cache or available in a Maven repository.
  29. ----------------------------------------------------------------------------------
  30. Maven build goals:
  31. * Clean : mvn clean
  32. * Compile : mvn compile [-Pnative]
  33. * Run tests : mvn test [-Pnative]
  34. * Create JAR : mvn package
  35. * Run findbugs : mvn compile findbugs:findbugs
  36. * Run checkstyle : mvn compile checkstyle:checkstyle
  37. * Install JAR in M2 cache : mvn install
  38. * Deploy JAR to Maven repo : mvn deploy
  39. * Run clover : mvn test -Pclover [-DcloverLicenseLocation=${user.name}/.clover.license]
  40. * Run Rat : mvn apache-rat:check
  41. * Build javadocs : mvn javadoc:javadoc
  42. * Build distribution : mvn package [-Pdist][-Pdocs][-Psrc][-Pnative][-Dtar]
  43. * Change Hadoop version : mvn versions:set -DnewVersion=NEWVERSION
  44. Build options:
  45. * Use -Pnative to compile/bundle native code
  46. * Use -Pdocs to generate & bundle the documentation in the distribution (using -Pdist)
  47. * Use -Psrc to create a project source TAR.GZ
  48. * Use -Dtar to create a TAR with the distribution (using -Pdist)
  49. Snappy build options:
  50. Snappy is a compression library that can be utilized by the native code.
  51. It is currently an optional component, meaning that Hadoop can be built with
  52. or without this dependency.
  53. * Use -Drequire.snappy to fail the build if libsnappy.so is not found.
  54. If this option is not specified and the snappy library is missing,
  55. we silently build a version of libhadoop.so that cannot make use of snappy.
  56. This option is recommended if you plan on making use of snappy and want
  57. to get more repeatable builds.
  58. * Use -Dsnappy.prefix to specify a nonstandard location for the libsnappy
  59. header files and library files. You do not need this option if you have
  60. installed snappy using a package manager.
  61. * Use -Dsnappy.lib to specify a nonstandard location for the libsnappy library
  62. files. Similarly to snappy.prefix, you do not need this option if you have
  63. installed snappy using a package manager.
  64. * Use -Dbundle.snappy to copy the contents of the snappy.lib directory into
  65. the final tar file. This option requires that -Dsnappy.lib is also given,
  66. and it ignores the -Dsnappy.prefix option.
  67. Tests options:
  68. * Use -DskipTests to skip tests when running the following Maven goals:
  69. 'package', 'install', 'deploy' or 'verify'
  70. * -Dtest=<TESTCLASSNAME>,<TESTCLASSNAME#METHODNAME>,....
  71. * -Dtest.exclude=<TESTCLASSNAME>
  72. * -Dtest.exclude.pattern=**/<TESTCLASSNAME1>.java,**/<TESTCLASSNAME2>.java
  73. ----------------------------------------------------------------------------------
  74. Building components separately
  75. If you are building a submodule directory, all the hadoop dependencies this
  76. submodule has will be resolved as all other 3rd party dependencies. This is,
  77. from the Maven cache or from a Maven repository (if not available in the cache
  78. or the SNAPSHOT 'timed out').
  79. An alternative is to run 'mvn install -DskipTests' from Hadoop source top
  80. level once; and then work from the submodule. Keep in mind that SNAPSHOTs
  81. time out after a while, using the Maven '-nsu' will stop Maven from trying
  82. to update SNAPSHOTs from external repos.
  83. ----------------------------------------------------------------------------------
  84. Protocol Buffer compiler
  85. The version of Protocol Buffer compiler, protoc, must match the version of the
  86. protobuf JAR.
  87. If you have multiple versions of protoc in your system, you can set in your
  88. build shell the HADOOP_PROTOC_PATH environment variable to point to the one you
  89. want to use for the Hadoop build. If you don't define this environment variable,
  90. protoc is looked up in the PATH.
  91. ----------------------------------------------------------------------------------
  92. Importing projects to eclipse
  93. When you import the project to eclipse, install hadoop-maven-plugins at first.
  94. $ cd hadoop-maven-plugins
  95. $ mvn install
  96. Then, generate eclipse project files.
  97. $ mvn eclipse:eclipse -DskipTests
  98. At last, import to eclipse by specifying the root directory of the project via
  99. [File] > [Import] > [Existing Projects into Workspace].
  100. ----------------------------------------------------------------------------------
  101. Building distributions:
  102. Create binary distribution without native code and without documentation:
  103. $ mvn package -Pdist -DskipTests -Dtar
  104. Create binary distribution with native code and with documentation:
  105. $ mvn package -Pdist,native,docs -DskipTests -Dtar
  106. Create source distribution:
  107. $ mvn package -Psrc -DskipTests
  108. Create source and binary distributions with native code and documentation:
  109. $ mvn package -Pdist,native,docs,src -DskipTests -Dtar
  110. Create a local staging version of the website (in /tmp/hadoop-site)
  111. $ mvn clean site; mvn site:stage -DstagingDirectory=/tmp/hadoop-site
  112. ----------------------------------------------------------------------------------
  113. Building on OS/X
  114. ----------------------------------------------------------------------------------
  115. A one-time manual step is required to enable building Hadoop OS X with Java 7
  116. every time the JDK is updated.
  117. see: https://issues.apache.org/jira/browse/HADOOP-9350
  118. $ sudo mkdir `/usr/libexec/java_home`/Classes
  119. $ sudo ln -s `/usr/libexec/java_home`/lib/tools.jar `/usr/libexec/java_home`/Classes/classes.jar
  120. ----------------------------------------------------------------------------------
  121. Building on Windows
  122. ----------------------------------------------------------------------------------
  123. Requirements:
  124. * Windows System
  125. * JDK 1.6
  126. * Maven 3.0
  127. * Windows SDK or Visual Studio 2010 Professional
  128. * ProtocolBuffer 2.4.1+ (for MapReduce and HDFS)
  129. * Findbugs 1.3.9 (if running findbugs)
  130. * Unix command-line tools from GnuWin32 or Cygwin: sh, mkdir, rm, cp, tar, gzip
  131. * Internet connection for first build (to fetch all Maven and Hadoop dependencies)
  132. If using Visual Studio, it must be Visual Studio 2010 Professional (not 2012).
  133. Do not use Visual Studio Express. It does not support compiling for 64-bit,
  134. which is problematic if running a 64-bit system. The Windows SDK is free to
  135. download here:
  136. http://www.microsoft.com/en-us/download/details.aspx?id=8279
  137. ----------------------------------------------------------------------------------
  138. Building:
  139. Keep the source code tree in a short path to avoid running into problems related
  140. to Windows maximum path length limitation. (For example, C:\hdc).
  141. Run builds from a Windows SDK Command Prompt. (Start, All Programs,
  142. Microsoft Windows SDK v7.1, Windows SDK 7.1 Command Prompt.)
  143. JAVA_HOME must be set, and the path must not contain spaces. If the full path
  144. would contain spaces, then use the Windows short path instead.
  145. You must set the Platform environment variable to either x64 or Win32 depending
  146. on whether you're running a 64-bit or 32-bit system. Note that this is
  147. case-sensitive. It must be "Platform", not "PLATFORM" or "platform".
  148. Environment variables on Windows are usually case-insensitive, but Maven treats
  149. them as case-sensitive. Failure to set this environment variable correctly will
  150. cause msbuild to fail while building the native code in hadoop-common.
  151. set Platform=x64 (when building on a 64-bit system)
  152. set Platform=Win32 (when building on a 32-bit system)
  153. Several tests require that the user must have the Create Symbolic Links
  154. privilege.
  155. All Maven goals are the same as described above with the exception that
  156. native code is built by enabling the 'native-win' Maven profile. -Pnative-win
  157. is enabled by default when building on Windows since the native components
  158. are required (not optional) on Windows.
  159. ----------------------------------------------------------------------------------
  160. Building distributions:
  161. * Build distribution with native code : mvn package [-Pdist][-Pdocs][-Psrc][-Dtar]