Outputs.upToDateWhen does not always force my task to be executed


(Jordan Black) #1

I have a test task that I always want to be executed, so I added outputs.upToDateWhen { false }. But it’s still always being marked as UP-TO-DATE.

‘’’ task myTest(type: Test) {

outputs.upToDateWhen { false }

if (allSystemProperties != null) {

allSystemProperties.propertyNames().each {

systemProperty it, allSystemProperties.getProperty(it)

}

}

include “tests/MyTest.class” } ‘’’

I’m using Gradle 1.12. Running ‘gradle clean myTest’ or ‘gradle cleanTest myTest’ always says myTest is UP-TO-Date.


(Peter Niederwieser) #2

There are other reasons for a task to be up-to-date, such as having no files to process. Perhaps the ‘–info’ or ‘–debug’ log will reveal something.


(Jordan Black) #3

Sigh… I had moved a test file to a different directory, and hadn’t updated the package name. It wasn’t getting a compile error, but turning on --debug told me that it wasn’t finding any source files for the test task. Fixing the package name fixed it. Thanks for the help!