BUILDING.txt 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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.4.1+ (for MapReduce and HDFS)
  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. Importing projects to eclipse
  85. When you import the project to eclipse, install hadoop-maven-plugins at first.
  86. $ cd hadoop-maven-plugins
  87. $ mvn install
  88. Then, generate eclipse project files.
  89. $ mvn eclipse:eclipse -DskipTests
  90. At last, import to eclipse by specifying the root directory of the project via
  91. [File] > [Import] > [Existing Projects into Workspace].
  92. ----------------------------------------------------------------------------------
  93. Building distributions:
  94. Create binary distribution without native code and without documentation:
  95. $ mvn package -Pdist -DskipTests -Dtar
  96. Create binary distribution with native code and with documentation:
  97. $ mvn package -Pdist,native,docs -DskipTests -Dtar
  98. Create source distribution:
  99. $ mvn package -Psrc -DskipTests
  100. Create source and binary distributions with native code and documentation:
  101. $ mvn package -Pdist,native,docs,src -DskipTests -Dtar
  102. Create a local staging version of the website (in /tmp/hadoop-site)
  103. $ mvn clean site; mvn site:stage -DstagingDirectory=/tmp/hadoop-site
  104. ----------------------------------------------------------------------------------
  105. Building on OS/X
  106. ----------------------------------------------------------------------------------
  107. Hadoop does not build on OS/X with Java 7.
  108. see: https://issues.apache.org/jira/browse/HADOOP-9350
  109. ----------------------------------------------------------------------------------
  110. Building on Windows
  111. ----------------------------------------------------------------------------------
  112. Requirements:
  113. * Windows System
  114. * JDK 1.6
  115. * Maven 3.0
  116. * Windows SDK or Visual Studio 2010 Professional
  117. * ProtocolBuffer 2.4.1+ (for MapReduce and HDFS)
  118. * Findbugs 1.3.9 (if running findbugs)
  119. * Unix command-line tools from GnuWin32 or Cygwin: sh, mkdir, rm, cp, tar, gzip
  120. * Internet connection for first build (to fetch all Maven and Hadoop dependencies)
  121. If using Visual Studio, it must be Visual Studio 2010 Professional (not 2012).
  122. Do not use Visual Studio Express. It does not support compiling for 64-bit,
  123. which is problematic if running a 64-bit system. The Windows SDK is free to
  124. download here:
  125. http://www.microsoft.com/en-us/download/details.aspx?id=8279
  126. ----------------------------------------------------------------------------------
  127. Building:
  128. Keep the source code tree in a short path to avoid running into problems related
  129. to Windows maximum path length limitation. (For example, C:\hdc).
  130. Run builds from a Windows SDK Command Prompt. (Start, All Programs,
  131. Microsoft Windows SDK v7.1, Windows SDK 7.1 Command Prompt.)
  132. JAVA_HOME must be set, and the path must not contain spaces. If the full path
  133. would contain spaces, then use the Windows short path instead.
  134. You must set the Platform environment variable to either x64 or Win32 depending
  135. on whether you're running a 64-bit or 32-bit system. Note that this is
  136. case-sensitive. It must be "Platform", not "PLATFORM" or "platform".
  137. Environment variables on Windows are usually case-insensitive, but Maven treats
  138. them as case-sensitive. Failure to set this environment variable correctly will
  139. cause msbuild to fail while building the native code in hadoop-common.
  140. set Platform=x64 (when building on a 64-bit system)
  141. set Platform=Win32 (when building on a 32-bit system)
  142. Several tests require that the user must have the Create Symbolic Links
  143. privilege.
  144. All Maven goals are the same as described above with the exception that
  145. native code is built by enabling the 'native-win' Maven profile. -Pnative-win
  146. is enabled by default when building on Windows since the native components
  147. are required (not optional) on Windows.
  148. ----------------------------------------------------------------------------------
  149. Building distributions:
  150. * Build distribution with native code : mvn package [-Pdist][-Pdocs][-Psrc][-Dtar]