UploadToBintray
UploadToBintray copied to clipboard
[Example] Awesome library built to demonstrate the process of publishing android libraries via JCenter/Bintray
Upload to JCenter/Bintray
This repository is no longer maintained
Jcenter has been sunset. It is encouraged to publish to MavenCentral.
Show some :heart:
Base repository to demonstrate the process of uploading an aar
/jar
to JCenter/Bintray.
Blog Post : Guide to publishing your Android Library via Jcenter/Bintray
The process is as follows
-
Create an Android project or open an existing one in Android Studio
-
Init the project with git and also create a repo on Github for the same. Each step here onwards represent a commit and should be pushed to github.
-
Create and add a new module and choose
Android Library
.Goto
File>New>New Module..
and selectAndroid Library
. -
Implement your library code inside the library module you created in the last step.
-
Next add the library module as a dependency to the app module.
- Goto
File>Project Structure..
- Select
app
module in the sidebar - Select the
Dependencies
tab - At the bottom is a
+
icon, click that and selectModule dependency
and select yourlibrary
module. - Press
apply
orok
.
- Goto
-
Once project is synced, add the required plugins to classpath in build.gradle file at root project level, as shown below
dependencies { classpath 'com.android.tools.build:gradle:4.1.1' .. // Required plugins added to classpath to facilitate pushing to Jcenter/Bintray classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4' classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' ..
-
Next, apply the
bintray
andinstall
plugins at the bottom of build.gradle file at library module level. Also add the ext variable with required information as shown belowapply plugin: 'com.android.library' ext { bintrayRepo = 'maven' bintrayName = 'awesomelib' // Has to be same as your library module name publishedGroupId = 'com.github.nisrulz' libraryName = 'AwesomeLib' artifact = 'awesomelib' // Has to be same as your library module name libraryDescription = 'Android Library to make any text into Toast with Awesome prepended to the text' // Your github repo link siteUrl = 'https://github.com/nisrulz/UploadToBintray' gitUrl = 'https://github.com/nisrulz/UploadToBintray.git' githubRepository= 'nisrulz/UploadToBintray' libraryVersion = '1.1' developerId = 'nisrulz' developerName = 'Nishant Srivastava' developerEmail = '[email protected]' licenseName = 'The Apache Software License, Version 2.0' licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt' allLicenses = ["Apache-2.0"] } .. .. // Place it at the end of the file apply from: 'https://raw.githubusercontent.com/nisrulz/JCenter/master/installv1.gradle' apply from: 'https://raw.githubusercontent.com/nisrulz/JCenter/master/bintrayv1.gradle'
-
Edit your
local.properties
bintray.user=<your_bintray_username> bintray.apikey=<your_bintray_apikey>
-
Now lets setup Bintray before we can push our artifact to it.
-
Register for an account on bintray.com and click the activation email they send you.
-
Add a new Maven repository and click Create New Package
-
You should now have a maven repository. For instance:
https://bintray.com/nisrulz/maven
-
Now once you have your maven repo setup , click on Edit
and see that you have selected the option
GPG sign uploaded files using Bintray's public/private key pair.
and then click Update.
-
-
Once everything is configured, run the below in your terminal in your root of the project
./gradlew clean build install bintrayUpload
-
Now once your project is up on bintray, simply hit Add to Jcenter button to sync with JCenter.
-
Your code is available
-
through the private repo at bintray
repositories { google() jcenter() maven { url 'https://dl.bintray.com/<bintray_username>/maven' } } dependencies { compile 'com.github.<bintray_username>:<library_module>:1.1' }
i.e for the sample lib in this repo ,
awesomelib
repositories { google() jcenter() maven { url 'https://dl.bintray.com/nisrulz/maven' } } dependencies { compile 'com.github.nisrulz:awesomelib:1.1' }
-
through JCenter if you have received the mail with confirmation
-
-
Few things to note when you received the final email.
-
Goto your maven repo at bintray and verify that you have Jcenter under the Linked to section
-
Now you would also want to sync the artifact to MavenCentral, for that you need to hit the Maven Central tab and sync
-
Once you hit sync you would see as below. Wait for few hours for the sync to occur.
-
You can use the lib now as follows
dependencies { compile 'com.github.<bintray_username>:<library_module>:1.1' }
i.e for the sample lib in this repo ,
awesomelib
dependencies { compile 'com.github.nisrulz:awesomelib:1.1' }
-
Let the world know of your AwesomeLib :smile:
-
Add a readme that explains how to integrate and use your Awesome library
-
Add a license block as in this repo
-
Also include the Bintray badge provided by Bintray in your readme
-
Promote your lib on social media so that others can know about it.
-
Always add a working sample app in your project that demonstrates your library in use.
-
Add screenshots if possible in your readme
-
If you appreciate my work, consider buying me a cup of :coffee: to keep me recharged :metal: [PayPal]
License
Copyright 2016 Nishant Srivastava
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.