How to provide derived defaults for task properties?

I would like to create a task which has two properties, both with default values, where the default value of one is derived from the actual value of the other. Something like:

class ConfigurationFileTask extends DefaultTask {

String configFileName // should default to ‘config.xml’

File configFilePath // should default to new File(project.buildDir, configFileName)

}

The goal is that if the user customises the base property, the derived property should take on the appropriate value.

I would really like the derived default to be available to other tasks. That is, if another task refers to configurationFile.configFilePath (say, a copy or zip task), it should get the right value.

What is the best way to do this? I can see how to do it by writing a getter and a setter, but that seems to involve a lot of boilerplate. Is there some clever Gradle or Groovy way of doing this?

I’ve written this up in more detail (or at least, different detail) as a question on StackOverflow; i would be more than grateful for answers either here or there:

http://stackoverflow.com/q/10897811/116639