Hive源码环境搭建(一)——源码编译

Hive源码环境搭建(一)——源码编译

北京时间:2020年04月21日12:16:00

Hive项目地址

本人环境:

系统:macOS 10.14.6、Maven版本:3.5.4、JDK版本:1.8.0_201

IDE版本:IntelliJ IDEA 2020.1

Hive版本:3.1.1(当前最新的HIve分支4.0我也编译了)

1、下载源码

  1. 可以通过git clone xxxxxxx直接拉取分支

    例如:git clone https://github.com/apache/hive.git

  2. 直接下载源码

    例如:https://codeload.github.com/apache/hive/tar.gz/rel/release-3.1.1

2、源码编译

进入源码的项目目录,例如:cd ~/code/java/hive-rel-release-3.1.1

  1. 需要先执行:export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home

    (这是似乎是因为开发人员编译的环境变量会写脚本中,但是我们这里没有,这里好像也是Maven的一个bug)

  2. 执行编译命令:mvn clean package -DskipTests -Phadoop-2 -Pdist

    当你看到BUILD SUCCESS时说明编译成功

    [INFO] Hive HCatalog Webhcat Java Client .................. SUCCESS [  1.932 s]
    [INFO] Hive HCatalog Webhcat .............................. SUCCESS [  6.526 s]
    [INFO] Hive HCatalog Streaming ............................ SUCCESS [ 55.170 s]
    [INFO] Hive HPL/SQL ....................................... SUCCESS [04:46 min]
    [INFO] Hive Streaming ..................................... SUCCESS [  1.450 s]
    [INFO] Hive Llap External Client .......................... SUCCESS [  1.428 s]
    [INFO] Hive Shims Aggregator .............................. SUCCESS [  0.047 s]
    [INFO] Hive Kryo Registrator .............................. SUCCESS [  8.624 s]
    [INFO] Hive TestUtils ..................................... SUCCESS [  0.085 s]
    [INFO] Hive Packaging 3.1.1 ............................... SUCCESS [ 51.884 s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 09:40 min
    [INFO] Finished at: 2020-04-21T11:27:26+08:00
    [INFO] ------------------------------------------------------------------------
    [WARNING] The requested profile "hadoop-2" could not be activated because it does not exist.
    

注意:

  1. 在编译Hive 3.1.1时mvn报错:提示找不到javadoc这个工具

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-javadoc-plugin:2.4:javadoc (resourcesdoc.xml) on project hive-webhcat: An error has occurred in JavaDocs report generation:Unable to find javadoc command: The environment variable JAVA_HOME is not correctly set. -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    [ERROR]
    [ERROR] After correcting the problems, you can resume the build with the command
    [ERROR]   mvn <goals> -rf :hive-webhcat
    

    在查阅后发现这是可能是(众说纷纭):

    1. 系统原因,开发人员使用的是Linux,但是这里是MacOS
    2. Maven插件maven-javadoc-plugin的bug导致的

    解决方法:

    在项目目录最外层的pom.xml标签中加入${java.home}/../bin/javadoc

    <properties>
        <javadocExecutable>${java.home}/../bin/javadocjavadocExecutable>
        ......(其他的省略)
    properties>
    

    说明:就是直接告诉maven-javadoc-plugin插件javadoc的具体位置:/Library/Java/JavaVirtualMachines/jdk1.8.0_201.jdk/Contents/Home/bin/javadoc

3、导入IDEA

  1. 选择File->New->Project from Existing Sources…(从已有源码导入项目)
    在这里插入图片描述
  2. 选择Hive的项目目录就行了
    Hive源码环境搭建(一)——源码编译_第1张图片
  3. 接来下等IDEA慢慢导入就行了(需要很久的时间。。。)

你可能感兴趣的:(大数据组件,hive)