As of May 1st 2021 JCenter will be shutting down. Please migrate to MavenCentral.
You can refer to MavenCentral-Publisher for a gradle plugin to simplify the process.
A gradle script to easily upload Android libraries to JCenter for distribution.
Reference: For a full article explaining the whole process check this Medium post written by Yegor Zatsepin
In order to upload the library, the next steps must be followed:
-
Setup Bintray
i. Sign in or create an account to Bintray (A free open-source account can be created here)
ii. Create a new repository selecting
Maven
as typeiii. Create a new package in the repository
-
Setup the Android library
i. Add the following lines to your
local.properties
fileImportant: Make sure it is listed in your
.gitignore
file to avoid uploading itbintray.user=USERNAME bintray.apikey=API_KEY
Where
USERNAME
is your Bintray username andAPI_KEY
can be retrieved from https://bintray.com/profile/editii. Add the following lines in your project's level
build.gradle
filebuildscript { //... dependencies { //... classpath "com.github.dcendents:android-maven-gradle-plugin:$maven_version" classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintray_version" } }
iii. Add the following lines in your library's level
build.gradle
. Replace the variable names with the appropriate values for your libraryNote: Your library will be finally published as
publishedGroupId:artifact:libraryVersion
Only the mandatory parameters are listed in this example. For a full list of all the available parameters, as well as a brief explanation of each, see the Parameters section
ext { bintrayRepo = 'BINTRAY_REPOSITORY_NAME' bintrayName = 'BINTRAY_PACKAGE_NAME' publishedGroupId = 'PUBLISHED_GROUP_ID' artifact = 'ARTIFACT' libraryVersion = 'LIBRARY_VERSION' gitUrl = 'GIT_URL' developerName = 'DEVELOPER_NAME' developerEmail = 'DEVELOPER_EMAIL' licenseId = 'LICENSE_ID' licenseName = 'LICENSE_NAME' licenseUrl = 'LICENSE_URL' }
iv. Add the following line in your library's level
build.gradle
apply from: 'https://raw.githubusercontent.com/Sarquella/JCenter-Uploader/master/jcenter_uploader.gradle'
-
Package and upload
Finally run the following two commands to upload the library to Bintray
./gradlew install
./gradlew bintrayUpload
-
bintrayRepo
: Name of the Bintray repo created at 1.ii -
bintrayName
: Name of the Bintray package created at 1.iii -
organizaton
[Optional]: Organization's Bintray username. In case the repo's owner is an organization instead of the username provided at 2.i -
publishedGroupId
: Library's group name (e.g., com.company.library) -
artifact
: Library's concrete artifact name -
libraryVersion
: Library's current version (e.g., 1.0.0) -
libraryDescription
[Optional]: Short description about the library -
gitUrl
: Version control url (e.g., https://github.com/<username/.git) -
siteUrl
[Optional]: Library's website url -
developerName
: Library's developer name -
developerEmail
: Library's developer email -
licenseId
: Library's license id (e.g., Apache-2.0) -
licenseName
: Library's license name (e.g., The Apache Software License, Version 2.0) -
licenseUrl
: Library's license url (e.g., http://www.apache.org/licenses/LICENSE-2.0.txt) -
overrideExisting
[Optional]: Boolean describing if the script should fail (false
) or not (true
) when trying to publish an already existing library's version, overriding it. Default isfalse
Copyright 2019 Adrià Sarquella Farrés
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.