Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Defining a custom Publication

xrigau edited this page Nov 6, 2014 · 1 revision

You can define your own publications and use them for uploading artifacts. You'll need to change the value of the publications property to use your publication. At the moment the bintray gradle plugin only understands publications of type MavenPublication. The default maven publication is created by this plugin and is defined as:

project.publishing {
  publications {
    maven(MavenPublication) {
      groupId project.publish.groupId
      artifactId project.publish.artifactId
      version project.publish.version

      artifacts.all(project).each {
        delegate.artifact it
      }

      from artifacts.from(project)
    }
  }
}

The artifacts that are uploaded by default are:

  • A jar or an aar with the compiled version of the library.
  • A jar with the sources of the library.
  • Another jar with the javadoc from the sources.

If you want to define your own publication in an Android library project, you could make use of the AndroidArtifacts class. There's also a JavaArtifacts class that can be used for projects that use the java gradle plugin.

These classes provide a from() method that will return a SoftwareComponent with the necessary dependencies of your package which will be added to the pom. The Artifacts classes also provide methods to generate the 3 artifacts (jars & aars) mentioned above, so you can easily create your own publication (of course, with a different name) and use it for upload.