The Gradle Bintray Plugin allows you to publish artifacts to Bintray.
Please follow the below steps to add the Gradle Bintray Plugin to your Gradle build script.
To apply the plugin, please add one of the following snippets to your build.gradle
file:
plugins {
id "com.jfrog.bintray" version "1.2"
}
- Currently the "plugins" notation cannot be used for applying the plugin for sub projects, when used from the root build script.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
}
}
apply plugin: 'com.jfrog.bintray'
- If you have a multi project build make sure to apply the plugin and the plugin configuration to every project which its artifacts you wish to publish to bintray.
Add the below "bintray" closure with your bintray user name and key.
bintray {
user = 'bintray_user'
key = 'bintray_api_key'
...
}
In case you prefer not to have your Bintray credentials explicitly defined in the script, you can store them in environment variables or in external user properties and use them as follows:
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
...
}
Mandatory parameters:
- repo - existing repository in bintray to add the artifacts to (for example: 'generic', 'maven' etc)
- name - package name
- licenses - your package licenses
- vcsUrl - your VCS URL
Optional parameters:
- userOrg – an optional organization name when the repo belongs to one of the user's orgs. If not added will use 'BINTRAY_USER' by default
bintray {
user = 'bintray_user'
key = 'bintray_api_key'
pkg {
repo = 'generic'
name = 'gradle-project'
userOrg = 'bintray_user'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/bintray/gradle-bintray-plugin.git'
}
}
Mandatory parameters:
- name - Version name
Optional parameters:
- desc - Version description
- released - Date of the version release. Can accept one of the following formats:
- Date in the format of 'yyyy-MM-dd'T'HH:mm:ss.SSSZZ'
- java.util.Date instance
- vcsTag - Version control tag name
- attributes - Attributes to be attached to the version
pkg {
version {
name = '1.0-Final'
desc = 'Gradle Bintray Plugin 1.0 final'
released = new Date()
vcsTag = '1.3.0'
attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin']
}
}
The plugin supports three methods to create groups of artifacts: Configurations, Publications and Copying specific files using filesSpec. All three methods used to group artifacts to be uploaded to Bintray.
The Maven Publications or Configurations should be added to the Gradle script, outside of the bintray closure. They should however be referenced from inside the bintray closure.
- Please note that Ivy Publications are not supported.
Maven Publications - the representation/configuration of how Gradle should group and publish files in Maven format
Below you can find an example for Maven Publication that can be added to your Gradle script:
publishing {
publications {
MyPublication(MavenPublication) {
from components.java
groupId 'org.jfrog.gradle.sample'
artifactId 'gradle-project'
version '1.1'
}
}
}
This Publication should be referenced from the bintray closure as follows:
bintray {
user = 'bintray_user'
key = 'bintray_api_key'
publications = ['MyPublication']
}
- Example project for using Maven Publications.
Configurations - the following example uses the archives Configuration by applying the java plugin:
apply plugin: 'java'
and the Configuration should be referenced from the bintray closure as follows:
bintray {
user = 'bintray_user'
key = 'bintray_api_key'
configurations = ['archives']
}
- Example project for using Configurations.
FilesSpec is following Gradle's copySpec which is used by the copy task
Below you can find an example for uploading arbitrary files from a specific folder ('build/libs') to a directory ('standalone_files/level1') under the build version in bintray using filesSpec.
filesSpec should be referenced from the bintray closure as follows:
bintray {
user = 'bintray_user'
key = 'bintray_api_key'
filesSpec {
from 'build/libs'
into 'standalone_files/level1'
}
}
- Example project for using filesSpec.
gradle bintrayUpload
The Gradle Bintray plugin can be configured using its own Convention DSL inside the build.gradle script of your root project. The syntax of the Convention DSL is described below:
bintray {
user = 'bintray_user'
key = 'bintray_api_key'
configurations = ['deployables'] //When uploading configuration files
// - OR -
publications = ['mavenStuff'] //When uploading Maven-based publication files
// - AND/OR -
filesSpec { //When uploading any arbitrary files ('filesSpec' is a standard Gradle CopySpec)
from 'arbitrary-files'
into 'standalone_files/level1'
rename '(.+)\\.(.+)', '$1-suffix.$2'
}
dryRun = false //Whether to run this as dry-run, without deploying
publish = true //If version should be auto published after an upload
//Package configuration. The plugin will use the repo and name properties to check if the package already exists. In that case, there's no need to configure the other package properties (like userOrg, desc, etc).
pkg {
repo = 'myrepo'
name = 'mypkg'
userOrg = 'myorg' //An optional organization name when the repo belongs to one of the user's orgs
desc = 'what a fantastic package indeed!'
websiteUrl = 'https://github.com/bintray/gradle-bintray-plugin'
issueTrackerUrl = 'https://github.com/bintray/gradle-bintray-plugin/issues'
vcsUrl = 'https://github.com/bintray/gradle-bintray-plugin.git'
licenses = ['Apache-2.0']
labels = ['gear', 'gore', 'gorilla']
publicDownloadNumbers = true
attributes= ['a': ['ay1', 'ay2'], 'b': ['bee'], c: 'cee'] //Optional package-level attributes
//Optional version descriptor
version {
name = '1.3-Final' //Bintray logical version name
desc = //Optional - Version-specific description'
released = //Optional - Date of the version release. 2 possible values: date in the format of 'yyyy-MM-dd'T'HH:mm:ss.SSSZZ' OR a java.util.Date instance
vcsTag = '1.3.0'
attributes = ['gradle-plugin': 'com.use.less:com.use.less.gradle:gradle-useless-plugin'] //Optional version-level attributes
//Optional configuration for GPG signing
gpg {
sign = true //Determines whether to GPG sign the files. The default is false
passphrase = 'passphrase' //Optional. The passphrase for GPG signing'
}
//Optional configuration for Maven Central sync of the version
mavenCentralSync {
sync = true //Optional (true by default). Determines whether to sync the version to Maven Central.
user = 'userToken' //OSS user token
password = 'paasword' //OSS user password
close = '1' //Optional property. By default the staging repository is closed and artifacts are released to Maven Central. You can optionally turn this behaviour off (by puting 0 as value) and release the version manually.
}
}
}
}
- As an example, you can also refer to these sample projects.
Gradle Compatibility:
When using Gradle publications or when using filesSpec
for direct file uploads, you'll need to use Gradle 2.x; Otherwise, the plugin is compatible with Gradle 1.12 and above.
JVM Compatibility: Java 6 and above.
As an example, you can also refer to these sample projects.
This plugin is available under the Apache License, Version 2.0.
(c) All rights reserved JFrog