1) Create a folder lib under examples/HelloWorld/lib and copy the following files (depending on your Hadoop version) into the lib folder:
- hadoop-common-2.8.4.jar
- hadoop-common-2.8.4-tests.jar
- hadoop-nfs-2.8.4.jar
2) Terminal: hadoop@master:~/examples/helloWorld$ gradle init
3) Now, edit the build.gradle file:
apply plugin: 'java'
dependencies {
compile files(fileTree(dir: 'lib', includes: ['*.jar']))
}
jar {
manifest {
attributes("Main-Class": "org.hipi.examples.HelloWorld")
}
from configurations.runtime.collect { zipTree(it) }
}
4) This is what my settings.gradle file looks like:
rootProject.name = 'helloWorld'
5) Terminal: hadoop@master:~/examples/helloWorld$ gradle jar
6) Terminal: hadoop@master:~/examples/helloWorld$ hadoop jar build/libs/helloWorld.jar