I have a custom plugin contained in a standalone project, and am successfully building it and using it in other projects.
I am currently trying to extend the plugin to add a task that will publish sources.
The (working) code in the target build script that I am trying to pull into the plugin:
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
I have tried several ideas, but I continually receive the following error when running the unit test:
groovy.lang.MissingPropertyException: Could not find property 'Jar' on project ':testSubProject'.
Two examples of plugin code that gives this error (I’ve snipped out most of the plugin code)::
project.subprojects {
apply plugin: 'java'
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allJava
}
}
and
project.subprojects {
apply plugin: 'java'
task(['type': Jar], 'sourcesJar') {
classifier = 'sources'
from sourceSets.main.allJava
}
}
Any thoughts?