Created
May 29, 2013 14:53
-
-
Save melix/5670897 to your computer and use it in GitHub Desktop.
Apply local tweaks to a Gradle build if user.gradle is present
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// here goes the conf | |
... | |
// append this | |
if (file('user.gradle').exists()) { | |
apply from: 'user.gradle' // if a user file is present, tweak the build (add tasks, ...). This file should not be in VCS. | |
} |
My user.gradle would contain things like this, for example:
// Add desktop notifications
apply plugin: 'announce'
gradle.afterProject {project, projectState ->
if (projectState.failure) {
announce.announce ("Evaluation of $project FAILED\n${projectState.failure}", 'local')
}
}
gradle.addBuildListener(
['buildStarted': {},
'projectsEvaluated': {},
'projectsLoaded': {},
'settingsEvaluated': {},
'buildFinished': { BuildResult result ->
if (result.failure) {
announce.announce("Build FAILED with ${result.failure}", 'local')
} else {
announce.announce("Build SUCCESSFUL", 'local')
}
}] as BuildListener
)
gradle.taskGraph.afterTask { Task task, TaskState state ->
if (state.failure) {
announce.announce ("Task $task FAILED\n${state.failure}", 'local')
}
}
// fast local install
task fastInstall(dependsOn: install) {
description='Installs a non indy version of Groovy into local Maven repo, without docs nor sources'
allprojects {
[javadoc,groovydoc,javadocAll,groovydocAll,sourceJar, groovydocJar, javadocJar]*.enabled = false
}
rootProject.ext.skipIndy = true
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The idea is to allow users to add tasks, shortcuts, ... to the Groovy build, without having to commit the changes to VCS.