Gradle -v output

Currently when I run the gradle -v command, I get something like this:

C:\Projects1\SomeTestProject>gradle -v
Gradle 1.1
  Gradle build time: Tuesday, July 31, 2012 1:24:32 PM UTC
Groovy: 1.8.6
Ant: Apache Ant(TM) version 1.8.4 compiled on May 22 2012
Ivy: 2.2.0
JVM: 1.6.0_31 (Sun Microsystems Inc. 20.6-b01)
OS: Windows 7 6.1 amd64

Is there a way to customize what gets printed? We are creating a custom distribution and packaging our own custom plugins along with the distribution. I’d like to be able to print out the version of our plugins along with this info.

There is no support in Gradle to modify this output at the moment. The version number and the build time is taken from a resource at /org/gradle/

cheers, René

I don’t really need to modify what gets printed - might there be a way I can add things to the end of it? Maybe capture the fact that the user used the -v option and append my own text to whatever gradle is outputting?

Could you just supply another task (such as ‘info’) that comes from your custom distribution/plugins? This would also give you access to the versions of the plugins defined in your dependency blocks.

I guess I could, but then you would have to be in context of a project right? Plugins are applied to projects and tasks are added to projects. The -v option can be run from anywhere without actually evaluating any projects.

It depends - you could add the dependencies of the plugins in a gradle init script which would get loaded by your custom distribution, which would always be loaded regardless of the existence of a project, right?

I could - but aren’t tasks associated with projects? Can I create a task in an init script and then execute it?

I’m not aware of a way to hook into ‘gradle -v’ or do something similar yourself. The best solution I can think of is to have an init script add an ‘info’ task to the root project (or all projects). For example:


gradle.rootProject {
  task info {
    doLast { println "info" }

Running this task from outside the build’s workspace should work fine.