Custom Task never UP-TO-DATE when running daemon

I wrote a plugin for Gradle (Victor) that has a custom incremental Task. It has some annotations for when the task is considered UP-TO-DATE (input/output files, a List and an int). You can see the class here.

The mystery is that this all works great if you don’t have the gradle daemon enabled - if you execute the task twice in-a-row, it doesn’t execute the second time (recognizing it’s UP-TO-DATE).

But! If you turn on the gradle daemon, it is never considered UP-TO-DATE. The reason given is thus:

Executing task ‘:sample:rasterizeSvgsForDebug’ (up-to-date check took 0.002 secs) due to:
Value of input property ‘includeDensities’ has changed for task ‘:sample:rasterizeSvgsForDebug’

This is either a bug in the daemon or a bug in my understanding of the daemon. :smile:

I’m running this on Gradle 2.3 currently.

You’re using an enum for includeDensities. There’s a known problem with that

Workaround would be to annotate @Input on a method that returns a list of Strings instead (based on the enum) and not use @Input on the list of enums.

1 Like

I saw you’ve updated your code. I was thinking you could do something like this:

List<String> densitiesWorkaround() {
   includeDensities.collect { it.toString() }

What you’re doing with a single String is OK since I think you’re configuring all of the RasterizeTasks they’ll ever be, but if someone tried to use RasterizeTask by itself, they’d have to know to set the workaround explicitly.

Ah, interesting. I didn’t know you could annotate @Input on a method. I’ll switch to something like that soon.

Thanks for all the help, btw!

And I had a brain fart… the method needs to follow Java bean conventions:

List<String> getDensitiesWorkaround() {
   includeDensities.collect { it.toString() }