Created
August 29, 2013 19:03
-
-
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
This file contains hidden or 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
/** | |
* 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