My company recently wrote gradle plugin for vanilla configuration (repositories, common dependencies across projects, etc). Overall, this has greatly simplified our build p
When you define a task in build.gradle script one (out of 4) of task method is called - you can see the first one here. As you can also see none of these methods matches the DSL - with which - you define a task in build.gradle. Why? Because before execution every build.gradle is evaluated to translate the DSL to appropriate methods invocations. For further details please have a look at this question.
The mentioned mechanism does not work in a custom plugin - here the code is interpreted as is without translating it. As you can see here there's no sourcesJar method defined on Project class. To create a task inside a plugin you need to invoke on of the mentioned task methods, e.g.:
task('sourcesJar', type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
which invokes exactly this method (I know the arguments order is different but this is how groovy works - trust me).
Also you don't need project.configure(project) {...}, project.with {...} will be enough.