Skip to content

Instantly share code, notes, and snippets.

@djangofan
Created January 24, 2013 18:12
Show Gist options
  • Save djangofan/4625910 to your computer and use it in GitHub Desktop.
Save djangofan/4625910 to your computer and use it in GitHub Desktop.
Trying to create a uber.jar build file for a Gradle multi-project build
apply plugin: 'java'
group = 'qa.webdriver'
subprojects {
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 {
compile group: 'org.sikuli', name: 'sikuli-api', version: '1.0.+'
compile group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '2.+'
compile group: 'junit', name: 'junit', version: '4.+'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
compile group: 'ch.qos.logback', name: 'logback-core', version: '1.0.+'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.0.+'
}
test {
testLogging {
exceptionFormat "full"
events "started", "passed", "skipped", "failed", "standardOut", "standardError"
}
}
// move this task to the sub project build file because of the Main-Class value
task testJar(type: Jar) {
classifier = 'tests'
from sourceSets.test.output.classesDir
manifest { attributes 'Main-Class': 'qa.webdriver.tests.GoogleTest' }
}
}
subprojects.each { subproject -> evaluationDependsOn( subproject.path ) }
task uberJar(type: Jar, dependsOn: subprojects.tasks['testClasses'] ) {
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) }
}
}
artifacts {
archives uberJar
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment