Configuring the Bintray plugin

We have configured the required configuration properties to get our project published to Bintray. However, the plugin allows for more configuration. We can see the configuration properties in the following table:

Name

Description

user

This sets the Bintray username.

key

This sets the API key.

configurations

This defines the configuration list with deployable files.

publications

This defines the list of publications to be deployed.

filesSpec

Use CopySpec to define the arbitrary files to be published, which are not part of a publication or configuration.

dryRun

This allows you to execute all tasks without deploying them.

publish

Should version be published after upload, instead of publishing it via the web browser.

pkg.repo

This is the name of the repository.

pkg.name

This is the name of the package.

pkg.userOrg

This is the optional organization name when the repository belongs to an organization.

pkg.desc

This is the description of the package.

pkg.websiteUrl

This is the URL of the website belonging to the project.

pkg.issueTrackerUrl

This is the URL of the issue-tracking system used for the project.

pkg.vcsUrl

This is the URL of the version control system used.

pkg.licenses

This is the list of licenses valid for this project.

pkg.labels

This is the list of labels describing what the project is about.

pkg.publicDownloadNumbers

This shows how many times published files are downloaded.

pkg.attributes

This is the map of custom attributes for package.

pkg.version.name

This is the custom Bintray version.

pkg.version.desc

This is the description specific to this version.

pkg.version.released

This is the date of release.

pkg.version.vcsTag

This is the tag for this version in the version control system.

pkg.version.attributes

These are the custom attributes for this version package.

pkg.version.gpg.sign

This is set to true to use GPG signing.

pkg.version.gpg.passphrase

This is the passphrase for GPG signing.

pkg.version.mavenCentralSync.sync

This is set to true to sync with Maven Central.

pkg.version.mavenCentralSync.user

This is the user token to sync with Maven Central.

pkg.version.mavenCentralSync.password

This is the password for the user syncing with Maven Central.

pkg.version.mavenCentralSync.close

By default, the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behavior off (by putting 0 as value) and release the version manually.

In the following example build file, we will use some of these configuration properties:

// Define Bintray plugin.
buildscript {
  repositories {
    jcenter()
  }

  dependencies {
    classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
  }
}

// Apply plugin to project.
apply plugin: 'com.jfrog.bintray'

apply plugin: 'maven-publish'
apply plugin: 'java'

version = '1.0.2.RELEASE'
group = 'book.gradle'

repositories {
  jcenter()
}

dependencies {
  compile 'org.springframework:spring-context:4.1.4.RELEASE'
}

publishing {
  publications {
    sample(MavenPublication) {
      from components.java
    }
  }
}

bintray {
  user = bintrayUsername
  key = bintrayApiKey
  publications = ['sample']

  publish = true

  pkg {
    repo = 'book-sample'
    name = 'full-sample'

    desc = 'Sample package for Gradle book.'

    websiteUrl = 'https://github.com/mrhaki/gradle-dep-book/'
    issueTrackerUrl = 'https://github.com/mrhaki/gradle-dep-book/issues'
    vcsUrl = 'https://github.com/mrhaki/gradle-dep-book.git'

    licenses = ['Apache-2.0']

    labels = ['book', 'sample', 'Gradle']

    publicDownloadNumbers = true

    version {
      desc = 'Fixed some issues.'
      released = new Date()
    }

  }

}

It is good to see that if we define the vcsUrl and licenses configuration properties, the plugin will automatically create the package in our repository. So, we don't have to use the web browser to create a new package. Instead, we can use the configuration in our build script to automatically create a package. Also, notice that the package is automatically published, unlike in the first example in which it was in an unpublished state.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.190.217.253