Skip to content

Instantly share code, notes, and snippets.

@djangofan
Created November 19, 2012 03:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djangofan/4108725 to your computer and use it in GitHub Desktop.
Save djangofan/4108725 to your computer and use it in GitHub Desktop.
build.gradle example
apply plugin: 'java'
apply plugin: 'groovy'
group = 'qa.webdriver'
allprojects {
apply plugin: 'java'
project.ext.sourceCompatibility = 1.6
repositories {
mavenCentral()
maven {
url "http://maven2.javacpp.googlecode.com/git/"
}
maven {
url "http://maven2.javacv.googlecode.com/git/"
}
}
dependencies {
// stored at: %HOMEPATH%/.gradle/caches/artifacts-14/filestore
compile group: 'org.sikuli', name: 'sikuli-api', version: '1.0.+'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+'
compile group: 'commons-collections', name: 'commons-collections', version: '3.+'
compile group: 'junit', name: 'junit', version: '4.+'
compile group: 'commons-lang', name: 'commons-lang', version: '2.+'
compile group: 'commons-io', name: 'commons-io', version: '2.+'
}
}
subprojects {
task show << {
println ""
println "-----------------------------------------------"
println "Project Name: " + projTitle
println "Version: " + projVersion
println "Home directory: "
println "Build output: " + relativePath(compileJava.destinationDir)
println "Resources output: " + relativePath(processResources.destinationDir)
println "Test output dir: " + relativePath(sourceSets.test.output.classesDir)
println "Test result dir: " + relativePath(testResultsDir)
println "Report dir: " + relativePath(testReportDir)
println "-----------------------------------------------"
}
test {
// this enables output in build/test-results directory
testLogging {
exceptionFormat "full"
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
}
}
task listClasses << {
tree = fileTree('build/classes') {
include '**/*.class'
}
tree.each {File file ->
println relativePath(file)
}
}
task testJar(type: Jar) {
classifier = 'tests'
from sourceSets.test.output.classesDir
}
}
task identify {
println "-----------------------------------"
println " _____ _ _ "
println " / ____| | | | "
println " | | __ _ __ __ _ __| | | ___ "
println " | | |_ | '__/ _` |/ _` | |/ _ \\ "
println " | |__| | | | (_| | (_| | | __/ "
println " \\_____|_| \\__,_|\\__,_|_|\\___| "
println ""
println "-----------------------------------"
println "Using build file '$buildFile.name' in '$buildFile.parentFile.name'."
configurations.runtime.each { File f -> println f }
}
subprojects.each { subproject -> evaluationDependsOn( subproject.path ) }
task uberJar(type: Jar, dependsOn: subprojects.tasks['testClasses'] ) {
println "An uberJar can be over 100MB and take 5+ minutes to build..."
baseName = 'uberJar'
subprojects.each { subproject ->
from subproject.configurations.archives.allArtifacts.files.collect {
zipTree(it)
}
from files(subproject.tasks["test"].testClassesDir)
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest { attributes 'Main-Class': 'qa.webdriver.tests.AllGoogleTests' }
}
task allJar(type: Jar, dependsOn: subprojects.tasks['testClasses'] ) {
baseName = 'allJar'
subprojects.each { subproject ->
from subproject.configurations.archives.allArtifacts.files.collect {
zipTree(it)
}
from files(subproject.tasks["test"].testClassesDir)
}
}
artifacts {
// don't mention uberJar here because we don't want to build it every time
archives allJar
}
project(':core') {
project.ext.projTitle = 'WebDriver Core On Gradle'
project.ext.projVersion = '0.99.0'
}
project(':core:google') {
evaluationDependsOn(':core')
dependencies {
compile project(':core')
}
project.ext.projVersion = '0.99.2'
project.ext.projTitle = 'WebDriver on Google'
}
project(':core:bing') {
evaluationDependsOn(':core')
dependencies {
compile project(':core')
}
project.ext.projVersion = '0.99.2'
project.ext.projTitle = 'WebDriver on Bing'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment