Hey Maxim, the code in the apply method of KernelPlugin is executed directly when apply plugin: ‘kernel’ is called. This means that the assignment of src=project.kernelConfig.urlSrc has already happened. You can either use conventionmapping to defere the assignment (as an example you can have a look at Gradles ApplicationPlugin). Another more simpler option for your use case might be to reconfigure the src property of your Downloader2 task directly:
Convention mapping works just as well for interdependent tasks. A stack trace including causes might help to explain where the problem is.
By the way, extension objects have effectively replaced convention objects, so you should keep using the former. They support convention mapping as well.
Thanks for the point Peter, explicit project.file() fixed the problem with the exception. Anyway to support conventin mapping I should extend ConventionTask, shouldn’t I?
You don’t have to, but it’s a decent choice if you are using Java rather than Groovy to implement the task class.
In case it hasn’t been mentioned in this topic, convention mapping is still considered an internal feature. Then again, it’s often the best solution to the lazy initialization problem.
A property for which convention mapping is used has to be called with its getter if accessed from within the same class. Otherwise Groovy will access the field directly, and there is no chance for the convention mapping to kick in. In other words, try ‘println getSrc()’ and ‘println getDest()’.