1. 安裝Gradle
CentOS下安裝
官網(wǎng)下載安裝Gradle步驟,下載安裝包以后解壓并配置環(huán)境變量(不羅嗦了)Ubuntu下安裝
sudo apt-get install -f gradle
測試Gradle是否安裝成功
gradle -v
2. 使用Gradle編譯
gradle build
gradle會根據(jù)build.gradle
文件自動下載依賴包缭付,并把源碼編譯成jar包。當(dāng)然也可以在
build.gradle
文件中修改依賴,
舉個我在編譯Myriad時出現(xiàn)的一個例子(Myriad就不做介紹了滩报,后面會對Myriad做一個簡單的介紹):
dependencies { compile project(':myriad-commons') compile "org.apache.hadoop:hadoop-common:${hadoopVer}" compile "org.apache.hadoop:hadoop-yarn-common:${hadoopVer}" compile "org.apache.hadoop:hadoop-yarn-server-resourcemanager:${hadoopVer}" compile "com.lmax:disruptor:3.3.0" compile "io.dropwizard.metrics:metrics-core:${metricsVer}" compile "io.dropwizard.metrics:metrics-annotation:${metricsVer}" compile "io.dropwizard.metrics:metrics-healthchecks:${metricsVer}" compile "org.hibernate:hibernate-validator:5.1.2.Final" compile "com.fasterxml.jackson.core:jackson-annotations:2.5.1 compile "com.fasterxml.jackson.core:jackson-databind:2.5.1 compile "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.5.1 compile "org.apache.curator:curator-framework:2.7.1" compile "org.apache.commons:commons-lang3:3.4" compile 'com.google.inject.extensions:guice-multibindings:3.0' testCompile "org.apache.hadoop:hadoop-yarn-server-resourcemanager:${hadoopVer}:tests" }
由于Myriad編譯jackson的版本是2.5.1伦连,編譯完成后把jar包復(fù)制到Y(jié)ARN_HOME/lib/下间驮,但是yarn自帶的jacksoon包是2.2.3漱病,這樣就會發(fā)生版本沖突浊洞,所以在使用gradle進(jìn)行編譯的時候就要把版本號修改好惜姐。