Skip to content

Instantly share code, notes, and snippets.

@sit
Last active June 24, 2022 11:50
Show Gist options
  • Save sit/3606537 to your computer and use it in GitHub Desktop.
Save sit/3606537 to your computer and use it in GitHub Desktop.
A sample build.gradle for setting up a basic Gradle project for CDH application development
apply plugin: "java"
apply plugin: "eclipse"
apply plugin: "idea"
group = "com.mycompany.hadoopproject"
version = "1.0"
repositories {
// Standard Maven
mavenCentral()
maven {
url "https://repository.cloudera.com/artifactory/cloudera-repos/"
}
}
// Mimic Maven 'provided' configuration, as suggested in GRADLE-784
configurations {
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
}
ext.hadoopVersion = "2.0.0-mr1-cdh4.0.1"
dependencies {
provided "org.apache.hadoop:hadoop-client:${hadoopVersion}"
// Example of adding a specific compile time dependency
compile "com.google.guava:guava:11.0.2"
testCompile "junit:junit:4.8.2"
}
// Java version selection
sourceCompatibility = 1.6
targetCompatibility = 1.6
eclipse {
classpath {
// Ensure Eclipse build output appears in build directory
defaultOutputDir = file("${buildDir}/eclipse-classes")
// Ensure the provided configuration jars are available in Eclipse
plusConfigurations += configurations.provided
}
}
// Emulate Maven shade plugin with a fat jar.
// http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-Creatingafatjar
jar {
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment