However, by calling .discoverTasks()and finding a known task by its name that task becomes available via the task container.
((TaskContainerInternal)it.tasks).discoverTasks()
println "I can find a known task after .discoverTasks() :" + it.tasks.findByName('publishMavenJavaPublicationToJcenterRepository')
def jcenterTasks = it.tasks.findAll { it.name.contains('ToJcenterRepository') }
println "Found jcenterTasks by path: ${jcenterTasks}"
If your plugin worked in 2.3 it was probably only incidental. The tasks created by the ‘maven-publish’ plugin aren’t available from afterEvaluate { } post 2.2. For what you are doing, you should really be using live collections.
@luke_daley: So the publishing tasks here aren’t being created unless we explicitly reference them by name. I’ve confirmed this was not the behavior in 2.3. Is this by design?
Yes, this is generally the point of the rules based model. We know about the existence of things (and some of their characteristics) without having to actually create them unless they are really needed. Tasks are somewhat special in that we have to bridge them back to the non rules world.
As the new publishing stuff is incubating (yes, still) we won’t class this as a regression. I will however add a potential breaking change to the release notes, which we should have had.
What’s the actual use case here @Adrian_Kelly? What is this code trying to do?