Step-by-step teaching you to upload an open source project to Jcenter

Source: Internet
Author: User
Tags jfrog jcenter

Recently idle to look at the use of Jcenter, but also want to use the high frequency of their own things into the library, and then through the compile to use, improve the development efficiency, originally thought quite simple, but the online introduction of the relatively vague, many blogs are older, not applicable, spent my day's time, Or go a lot of detours, here record down, hope to help small partners, now feel is quite simple.
The first step: first is to register, this is the biggest pit I stepped on, resulting in my day has not uploaded successfully. Online said are to go to Jcenter website registration on can, in fact, English good best to see English documents, step by step to operate.
Personal correct registered address: Https://bintray.com/signup/oss
Personal correct registered address: Https://bintray.com/signup/oss
Personal correct registered address: Https://bintray.com/signup/oss
Important things to say three times, be sure to go to this site to register.
Open the interface is like this, be sure to choose me to mark this, the default is the first one, this is the pit, so be sure to see clearly re-registration.


Write a picture description here

Note: It is not feasible to use a regular mailbox (qq,163 these are not good), preferably using Google Mail or Outlook mailbox.
After the registration is completed the interface is like this, see:


Write a picture description here

However, if you register after the interface is the following:


Write a picture description here

If you don't see the new Repository, you're wrong to register and step on my first pit. After deleting the account information, re-register it.
After registration We click Add New Repository to create a new warehouse.
Note: The names and types of Maven silos created are written in Maven as shown in:


Write a picture description here

Then we started to get user and key, and as for why, we'll say it later:


Write a picture description here
Write a picture description here

So that our jcenter work is done, and then prepare our upload of open source projects, this is relatively simple, I casually said.
The first step: Create a new project, and then under this project to create a new Android library module, its own open source Library is developed in this module, such as:


Write a picture description here

Step Two:
In this new module, develop your own open source project, and then, in the original project can directly refer to the module in the code. However, when you run the error, you need to add the following code to the Build.gradle of the project:
Compile project (': Commonutillibrary ')

Inside the single quotation mark, is the module name that you create yourself.
Then, re-run the entire project, you can also compile the module.
Step Three:
Write the Build.gradle file of the project, remember, it is engineering.
First open the project's Build.gradle file, must be the project's build file, and then add the following code inside:
Buildscript {
repositories {
Jcenter ()
}
dependencies {
Classpath ' com.android.tools.build:gradle:2.3.1 '
Classpath ' com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2 '
Classpath ' com.github.dcendents:android-maven-gradle-plugin:1.5 '
}
}
Remember, some of the code is preserved, not added.
Note: Here sync sometimes reports Error: (2, 0) No service of type Factory ... Such errors are mainly due to this line:
Classpath ' com.github.dcendents:android-maven-gradle-plugin:1.5 '
If the error, you go to the official web site to see the latest plug-in version number, changed it can be.
The complete build.gradle should look like this when you have finished adding:


Write a picture description here

Then open the Build.gradle file for the module that will be uploaded, adding the following code:
Apply plugin: ' Com.github.dcendents.android-maven '
Apply plugin: ' Com.jfrog.bintray '

def siteurl = ' https://github.com/caijin199410/CommonUtil.git '//the homepage of the project This is a description, can be easily filled
def giturl = URL of ' https://github.com/caijin199410/CommonUtil.git '//git repository This is a description, can be filled in casually
Group = "Com.abrahamcaijin"//Here is GroupID, must fill in the general fill your unique package name, corresponding to Com.squareup.okhttp3:okhttp : COM.SQUAREUP.OKHTTP3 part of 3.4.1

Install {
Repositories.maveninstaller {
This generates pom.xml with proper parameters
Pom {
Project {
Packaging ' AAR '
Add your description here
Name ' Commonutil '//Project description
URL SiteURL
Set your license
Licenses {
License {
Name ' The Commonutil software License, Version 1.0.0 '
URL ' http://www.apache.org/licenses/LICENSE-2.0.txt '
}
}
Developers {
Developer {
Id ' Caijinabraham '//fill in some basic information about the developer
Name ' Caijinabraham '//fill in some basic information about the developer
email ' [Email protected] '//fill in some of the developer's basic information
}
}
SCM {
Connection Giturl
Developerconnection Giturl
URL SiteURL
}
}
}
}
}
Task Sourcesjar (Type:jar) {
From Android.sourceSets.main.java.srcDirs
classifier = ' sources '
}
Task Javadoc (Type:javadoc) {
Options {
Encoding "UTF-8"
CharSet ' UTF-8 '
Author true
Version true
Links "Http://docs.oracle.com/javase/7/docs/api"
}
Source = Android.sourceSets.main.java.srcDirs
Classpath + = Project.files (Android.getbootclasspath (). Join (File.pathseparator))
}
Task Javadocjar (Type:jar, Dependson:javadoc) {
classifier = ' Javadoc '
From Javadoc.destinationdir
}
Artifacts {
Archives Javadocjar
Archives Sourcesjar
}

Properties Properties = new properties ()
Properties.load (Project.file (' local.properties '). Newdatainputstream ())
Bintray {
Userorg=properties.getproperty ("Bintray.user")
user = Properties.getproperty ("Bintray.user")//Read bintray.user inside the local.properties file
Key = Properties.getproperty ("Bintray.apikey")//Read the Local.properties file inside the Bintray.apikey
configurations = [' Archives ']
pkg {
Repo = "maven"
Name = "Commonutil"//title of the project on Jcenter, must be filled in, corresponding to com.squareup.okhttp3:okhttp:3.4.1 in Okhttp
publishversion = ' 1.0.0 '//project version number posted to Jcenter
Websiteurl = SiteURL
Vcsurl = Giturl
licenses = ["Apache-2.0"]
Publish = True
}
}

After the addition is complete, the complete build.gradle should look like this:


Write a picture description here
Write a picture description here
Write a picture description here

Finally, you need to add the following content to your local local.properties:
Bintray.user=your_bintray_username
Bintray.apikey=your_bintray_api_key


Write a picture description here

Fourth Step:
Open the command line for Android Studio:


Write a picture description here

Enter the following command:
Enter the command:
Gradlew Install
Gradlew Bintrayupload
When both commands successfully display the build successful, or do not execute the above two commands, direct compositing executes the following command:
Gradlew Clean Build Bintrayupload-pbintrayuser=bintray_username-pbintraykey=bintray_key-pdryrun=false
Remember to change the user and key to your own, and also to show the build successful.

Finally, you will publish the project to Jcenter:
Upload Open Source Library to jcenter a lot of ways, can Baidu, here to see my on can, open Jcenter homepage, into their new MAVEN warehouse inside, you can see yourself pushed up the open source project, as shown:


Write a picture description here
Write a picture description here

Then you need to wait for the approval to pass, typically 5-6 hours. You can use it by configuring your own private warehouse address before auditing is passed.


Write a picture description here

Then, at the root of the project, Build.gradle Configure the address:


Write a picture description here

Then add dependencies in the Build.gradle of the module that you are using:
Dependencies can be added to the project:
Compile ' com.abrahamcaijin:comonutil:1.0.0 '

Note: If you are prompted to rely on unsuccessful, you can then add @arr, audit through the later can be removed after the @arr, temporarily found that the OS system upload does not need to join the successful, Windows system upload need to join the @arr
Compile ' com.abrahamcaijin:comonutil:[email protected] '

Then now is the 1.0.0 version, what do I want to add and iterate about later?
This is very simple, when your library code changes, only need to change the above configuration inside the publishversion, run Gradlew clean build bintrayupload-pdryrun=false, you can update the version number. So, the whole process is over.
Well, now you can rely on your open source library in your project, it's that simple! Have not understood the contact me.

Reprinted from: http://blog.csdn.net/u014727709/article/details/71104201
Welcome to start, welcome comment, please correct me

Step-by-step teaching you to upload an open source project to Jcenter

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.