This is my final installment, and it's a biggie! This post includes:
* automatically opening test reports on test failure
* grouping tasks for the gradle task list
* renaming all your build.gradle files to match the names of the subprojects
* plugin extensions as the replacement for plugin conventions
* changing the project's artifactId (useful for non-uploadArchive tasks consuming the pom)
* dependency specifications for easy reuse of customizations such as exclusions in multi-project builds
Automatically opening test reports on test failure. As an added bonus, your headless CI server will return false for Desktop.isDesktopSupported(). Note that this requires JDK 1.6:
test {
successful = true
afterTest { desc, result ->
if (result.toString() == 'FAILURE') {
successful = false
}
}
}
import java.awt.Desktop
gradle.taskGraph.afterTask { task, taskState ->
if (task instanceof Test && !task.successful) {
if (Desktop.isDesktopSupported()) {
Desktop.desktop.browse( new File(task.testReportDir, 'index.html').toURI() )
}
}
}Grouping tasks for the gradle task list. Make use of the Task.group property:task build(dependsOn: [test, assemble]) {
group = 'build'
}Renaming all your build.gradle files to match the names of the subprojects. Place this in your settings.gradle:rootProject.children.each { project ->
String fileBaseName = project.name.replaceAll("\\p{Upper}") { "-${it.toLowerCase()}" }
project.buildFileName = "${fileBaseName}.gradle"
}Plugin extensions as the replacement for plugin conventions:project.extensions.myextension = [name: "default"]
myextension.name = "some other value"
myextension {
name = "a different value"
}Changing the project's artifactId (useful for non-uploadArchive tasks consuming the pom):project.archivesBaseName = "my-preferred-artifactId"Dependency specifications for easy reuse of customizations such as exclusions in multi-project builds. Use: dependencies.create(notation, closure).Enjoy!
2 comments:
Good stuff, but you should use unique titles for your posts.
Could you post links here to your previous articles/parts as well. Thanks!
Post a Comment