Skip to content

Instantly share code, notes, and snippets.

@mcquinne
Created August 29, 2013 19:03
Show Gist options
  • Save mcquinne/6382095 to your computer and use it in GitHub Desktop.
Save mcquinne/6382095 to your computer and use it in GitHub Desktop.
Add a "print<PropertyName>" rule to Gradle projects to easily print project property values
/**
* Put in an init script, e.g.: $HOME/.gradle/init.d/printProperties.gradle
* Then call from a gradle project, e.g.: gradle printVersion
*/
allprojects { Project project ->
tasks.addRule( "print<PropertyName> - print the value of a property in this and any subprojects" ) { String taskName ->
if ( taskName.startsWith( "print" ) ) {
def propName = (taskName - 'print')
propName = propName[0].toLowerCase() + propName[1..-1]
task( taskName ) << { println "${propName}: ${project.properties[propName]}" }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment