Book Image

Gradle Dependency Management

By : Hubert Klein Ikkink
Book Image

Gradle Dependency Management

By: Hubert Klein Ikkink

Overview of this book

Table of Contents (14 chapters)
Gradle Dependency Management
About the Author
About the Reviewers

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: 'src/files/README'
      // artifact source: 'src/files/COPYRIGHT',
      //          extension: 'metaInformation'