Hi Adam,

Am 29.07.11 01:04, schrieb Adam Murdoch:

On 29/07/2011, at 7:22 AM, phil swenson wrote:

Is there anyway I could override gradle's up-to-date functionality?

I have two scenarios in mind
1) I need to call a web service, pass in the last message ID from
previous run, and check to see if it is the latest.  If there is new
info, then the task is not "up to date" and I need to execute the task

A couple of options:

You can use the outputs.upToDateWhen() method:

myTask {
    def newValue
    outputs.upToDateWhen {
        def oldValue = loadValueFromSomePersistentStorage()
        newValue = fetchNewValueFromWebService()
        return oldValue == newValue
    }
    doFirst {
        writeValueToSomePersistentStorage(newValue)
    }
}

If you have a task type, you can simplify this to:

class MyTask extends DefaultTask {
    @Input
    String getMessageId() {
return fetchNewValueFromWebService() // might want to cache this value in a field
    }
}

just a small note on your example above.

The UP-TO-DATE check above won't work at the moment. As long as no Output(dir or file) is declared, gradle will execute this task again and again, even though the input hasn't changed.

regards,
René

--
-----------------------
regards René

rene groeschke
http://www.breskeby.com
@breskeby


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to