Task.inputs.property


(crotwell) #1

I just figured out that task.inputs.property(“project version”, { project.version }) causes a task to do an up-to-date check on the project’s version. Nice!

Gradle is just awash in awesomeness!

Thank you!

PS Would be really nice to add this to the docs http://gradle.org/docs/current/userguide/more_about_tasks.html#N10DF8 as they make it sound like inputs and outputs only work for files now.


(Stig Kleppe-Jørgensen) #2

Hi Philip,

Not sure I understood this. When is a project’s version not up-to-date with itself? What would you use this for?


(Matias Bjarland) #3

My understanding is that gradle maintains a “task state cache” which is stored in the .gradle directory and which caches task states across build executions. In the above case you could include a task in your build chain which, using the settings in the original post, would only be executed when somebody changes the project version. This could for example send out a notification email from a continuous integration build or do some specific only-once-a-version maintenance on the build server etc.


(Stig Kleppe-Jørgensen) #4

Amazing, just amazing…discovering new features all the time.


(crotwell) #5

The use I was putting it to was building a “launcher”, either windows exe or a mac app bundle. The launcher in both cases contains the version as a property and so I want the it to be rebuilt when I update the version, even if nothing else has changed in the source code. Would be very embarrassing to finally say, “yep 1.0 is ready to go” and then have the launcher say something ugly like “I am version 1.0-rc27-SNAPSHOT”. I am sure there are lots of other cases where the thing that is no longer “up to date” isn’t a file, but you still want to trigger a task to run.

An example is here, where the GenerateInfoPlistTask depends on the projects version.

http://code.google.com/p/gradle-macappbundle/source/browse/src/main/groovy/edu/sc/seis/gradle/macAppBundle/MacAppBundlePlugin.groovy

I agree, Gradle is pretty amazing. The only downside is that I feel like the cool features are coming faster than I can learn about them. :slight_smile: