So I have a project with several sub-projects. In the subprojects block I have defined:
subprojects {
tasks.withType(Jar).all { jarTask ->
manifest {
attributes("Artifact": baseName, "Group": rootProject.group, "Build-Version": version)
}
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task reportsZip(type: Zip, dependsOn: projectReport) {
from dependencyReport.outputFile.parent
classifier = 'reports'
}
artifacts {
archives sourcesJar
archives reportsZip
}
}
This publishes the jars just fine (individually) for each subproject. Now, I want to build and publish a jar that is an aggregate of all of the subproject jars. I tried this in the root project build.gradle:
subprojects.each { subproject ->
evaluationDependsOn(subproject.path)
}
task allJar(type: Jar, dependsOn: subprojects.jar) {
baseName = 'myproject-all'
subprojects.each { subproject ->
from subproject.configurations.archives.allArtifactFiles.collect {
zipTree(it)
}
}
}
artifacts {
archives allJar
}
When I try to build this, I get the following error:
Could not find method archives() for arguments [task ‘:allJar’] on root project
I am at a loss to what I am missing. Do I need to add this artifact to the configuration somehow?