Account: https://bintray.com/google
Contact: emailremoved@
Bintray is a download center with REST automation & support for RPM & Debian packages. It is often used to distribute Android libraries via Maven or/and jCenter repositories.
Here are the detailed steps to distribute your Android library via Maven or/and jCenter:
Create and setup your Bintray account
- Log into your corporate Bintray account
Click on "Add a new repository" button to create your repo
Private access could be used while you are preparing the final release in order to hide it from non-authorized users. But to download and use the package, your username and private API key should be included inside 'local.properties' file linked to your sample app's 'build.gradle.'
When you are ready to open your package to the World, change an access to Public.Name (aka <repo_name>) is an important part, since it can't be changed in future. And it will be the first part of your repository's public url.
E.g.: https://bintray.com/google/<repo_name>/<your_library_package>For Type just select "Maven"
Check the option: “GPG sign uploaded files using Bintray's public/private key pair”.
Then you can click on "Add new package" button in order to fill up all the package details via web interface.
Or you can just specify them inside your 'build.gradle' file during Step 2.
Prepare your Android project
Add necessary dependencies:
// build.gradle dependencies { // You probably already have this: classpath 'com.android.tools.build:gradle:2.2.0' // So just add bintray and maven plugins: classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.6' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' }
Apply corresponding plugins:
// build.gradle apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray'
Include "install" and "bintray" targets
- Here is the detailed guide with examples from Bintray: https://github.com/bintray/gradle-bintray-plugin/blob/master/README.md
- Here is the complete 'build.gradle' from them: https://github.com/bintray/bintray-examples/blob/master/gradle-bintray-plugin-examples/android-maven-example/build.gradle
My minimal set of changes (I didn't use a github repository for this project):
// local.properties: bintray.user=USERNAME@google bintray.apikey=<your_api_key> user.id=USERNAME user.email=USERNAME@google.com // build.gradle: Properties properties = new Properties() properties.load(project.rootProject.file('local.properties') .newDataInputStream()) bintray { user = properties.getProperty("bintray.user") key = properties.getProperty("bintray.apikey") configurations = ['archives'] pkg { repo = '<repo_name>' name = '<package_name>' userOrg = 'google' desc = '<description_of_your_library>' publicDownloadNumbers = false } } install { repositories.mavenInstaller { pom.project { name '<your_library_name>' description '<description_of_your_library>' packaging 'aar' developers { developer { name 'google' id properties.getProperty('user.id') email properties.getProperty('user.email') } } } }
}
Add javadoc and source tasks if you wish your library's users are able to access them.
E.g.:// build.gradle task sourcesJar(type: Jar) { from android.sourceSets.main.java.source classifier = 'sources' } task javadoc(type: Javadoc) { source = android.sourceSets.main.java.source ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar" classpath += (project.files(android.getBootClasspath().join(File.pathSeparator)) + files(ext.androidJar)) options.links("http://linkremoved//"); failOnError false } afterEvaluate { javadoc.classpath += files(android.libraryVariants.collect { variant -> variant.javaCompile.classpath.files }) } task javadocJar(type: Jar, dependsOn: javadoc) { classifier = 'javadoc' from javadoc.destinationDir } artifacts { archives javadocJar archives sourcesJar }
Install and upload your library into Bintray
Just open the ‘Terminal’ tab inside Android Studio or anywhere else and type:
./gradlew build install bintrayUpload --info
Check that your library and files are now inside your Bintray’s repo via web interface
- Navigate to : https://bintray.com/google/<repo_name>/<your_package>
- Open tab 'Files' and check if there are *.jar, *.ask and *.pom files
Test that everything works from your sample app
In order to include your library into an Android sample app, just update 'build.gradle' of it with the following lines:
For Public repos:
// build.gradle repositories { maven { url "http://linkremoved/>" } } dependencies { compile '<your_package>:<library_name>:<version>' }
For Private ones:
// build.gradle repositories { maven { url "http://linkremoved/>" } credentials { username 'USERNAME@google' password '<your_API_key>' } } dependencies { compile '<your_package>:<library_name>:<version>' }
Then just try to use some classes and methods from your library:
- Verify that sample app compiles without errors
- Check that Android Studio correctly shows the javadoc.
Add your library to jCenter (optional)
If you wish to distribute your library via jCenter as well as via Maven, then you need to:
Check if there is a button "Add to JCenter" in the lower right corner of your package’s Bintray page: https://bintray.com/google/<repo_name>/<your_package>
- Click it if you see the button
Otherwise, write an email to emailremoved@ about your project and ask him to enable jCenter distribution for your package
Useful resources from 3rd party developers: