I’m trying to use task configuration avoidance APIs as much as possible. I’m trying to create a maven publication from an archive task someArchiveTask
:
publishing {
publications {
create<MavenPublication>("publicationName") {
artifact(tasks.named("someArchiveTask"))
}
}
}
But I only get an error:
* What went wrong:
Cannot convert the provided notation to an object of type MavenArtifact: task ':someArchiveTask'.
The following types/formats are supported:
- Instances of MavenArtifact.
- Instances of AbstractArchiveTask, for example jar.
- Instances of PublishArtifact
- Maps containing a 'source' entry, for example [source: '/path/to/file', extension: 'zip'].
- Anything that can be converted to a file, as per Project.file()
The following seems to work:
publishing {
publications {
create<MavenPublication>("publicationName") {
artifact(tasks["someArchiveTask"])
}
}
}
but this configures someArchiveTask
immediately, thus defeating the purpose of task configuration avoidance. Is there a reason I can’t pass a TaskProvider
to artifact
?