Using file artifacts

Instead of an archive task, we can also use a file as an artifact. Gradle tries to extract the extension and classifier properties from the filename. We can also configure these properties ourselves when we add the file as a publication artifact.

In the following example build file, we use the src/files/README and src/files/COPYRIGHT files as publication artifacts:

apply plugin: 'maven-publish' publishing { publications { documentation(MavenPublication) { // Use file name as a publication artifact. artifact 'src/files/README' artifact('src/files/COPYRIGHT') { // Each file artifact must have a // unique classifier and extension. classifier = 'metaInformation' } // Alternative syntax is with // the Map notation: // artifact source: ...

Get Gradle Dependency Management now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.