Reprint please indicate the source (do not reprint delete bottom Weibo, etc information):
http://blog.csdn.net/lmj623565791/article/details/51148825;
This article is from: "Zhang Hongyang's Blog"
People in many times want to make their own open source projects can be more convenient for users to use, then for the Android platform, a good way is to upload to Jcenter, and then make the time by adding a compile reference.
For upload to Jcenter, also not calculate technical class article, and already have a lot of good articles can refer to, write before I also roughly Baidu a bit.
At present, many articles are gradle-bintray-plugin uploaded with this plugin, most of the articles are for common open source projects (that is, do not include compile-time annotations related). So for the use of compile-time annotations, because it involves multiple module , upload may be more troublesome.
This article bintray-release is ready to use this plugin, personal feeling than gradle-bintray-plugin to be more convenient.
For gradle-bintray-plugin the use of, I Baidu, you can refer to this article http://www.cnblogs.com/qianxudetianxia/p/4322331.html
So, the main content of this article is:
- Use
bintray-release to publish generic items to Jcenter
- Use
bintray-release Publish compile-time annotation items to Jcenter
First, the ordinary project to upload to Jcenter
OK, first you should have a project to upload.
So we're simulating a simple project here.
We can see that our basetools is an Android library, which is mainly used to store some tools, and we will now upload them to jcenter.
So, for you, you should already have such an Android library, in the status to be uploaded.
(1) Register bintray.com account
Why register this account because it belongs to jcenter() a warehouse owned by Bintray.
Our upload process is actually, from your Androd Studio, to your Bintray warehouse, and finally to the Jcenter warehouse.
- Enter https://bintray.com/, register your account.
- When the registration is complete, mailbox activation is required, or you can select a third-party login.
After the registration is completed, login, these two steps belong to the amateur players can handle.
After logging in:
After logging in, you can click and then you will be Your Profile Edit able to see the interface.
Click on the API key, you can see a key string, put this copy aside, one will upload to use.
(2) Introduction of Bintray-release project Build.gralde
In the Build.gradle of your project add bintray-release the classpath, note is the project Build.gradle, not the module, the diagram that starts with the article UploadJcenterTest/build.gradle .
{ repositories { jcenter() } { classpath ‘com.android.tools.build:gradle:1.2.3‘ classpath ‘com.novoda:bintray-release:0.3.4‘ }}
Build.gralde to upload Moudle
Come to the module you want to upload, the graph that starts with the article UploadJcenterTest/basetools/build.gradle .
Apply plugin:' Com.android.library 'Apply plugin:' Com.novoda.bintray-release '//AddAndroid {//remain unchanged}dependencies {//remain unchanged}//AddPublish {userorg =' Hyman '//bintray.com User NameGroupId =' Com.hyman 'the path on the//jcenterArtifactid =' Basetools '//Project namePublishversion =' 1.0.0 '//Version number desc=' Oh Hi, this was a nice description to a project, right? '//Description, not importantWebsite =' Https://github.com/hyman/basetools '//website, not important}
According to the above writing, the details are identified annotated, assuming that according to the above-mentioned writing, the final introduction of the way is:
compile ‘com.hyman:basetools:1.0.0
Once you have completed the above configuration, you are ready to upload.
Upload
Upload is simple, execute the following code to
./gradlew clean build bintrayUpload -PbintrayUser=hyman -PbintrayKey=xxxxxxxxxxxxxxxxxxxxxx -PdryRun=false
User is the username, key is what we just let you save the Key,dryrun is a configuration parameter, when True, will run all the links, but will not upload.
OK, the following collation of the above code, run can. About running, you can choose to do it in the terminal panel of Android studio, as in.
Click on the terminal at the bottom to note that your current path is under current project and then enter run.
Then wait, when the run is complete, see BUILD SUCCESSFUL There is no problem, if there is any problem, according to log under the investigation.
The upload is complete by this means ~ ~ ~
You can access https://bintray.com/你的用户名/maven it and see:
See our uploaded items, you can click to see some of the library information, but note that at this point can not be directly referenced.
Click to go to the library, follow, clickAdd To jcenter
Then write a description of your library and click Send.
OK, this is the end, but it is still not directly quoted, you need to wait for Bintray staff audit, Audit will send you a message in the station, and Add to Jcenter that button on the hour, in addition you can also be based on the groupid you upload, visit the site https://jcenter.bintray.com/你的groupId such as https://jcenter.bintray.com/com/hyman/
If you can refer to it, you can see the following:
The final summary of the whole process, in fact, is very simple:
- Apply for Account
- Introduce Bintray-release, fill in the relevant publish information in the module that need to upload
- Invoke the uploaded command
Add to JcenterSubmit an Audit
Basically is the step of things, really need us to fill in the publish inside a few information.
OK, next look at the item that uploaded the compile-time annotations.
Second, compile-time annotated project upload to Jcenter
If you do not need this demand, in fact, there is no need to look down, because it does not belong to the technical articles, understand here there is write, can be collected, meet the demand to come back to see the good.
In fact it is very simple, follow the steps to do just fine.
We look for a project here as a demonstration.
Why is it that the project annotated at compile time is special?
Because it usually involves a number of moudle, for example, involved compilter , permission-annotation permission-lib .
When we upload, these 3 module are to upload, here is not involved in why this is so divided module related knowledge.
In fact bintray-release , the use of upload process is also very simple.
Build.gradle of the project
First, for the build.gradle of the project, in the figureMPermissions/build.gradle
Buildscript {repositories {jcenter ()} dependencies {Classpath' com.android.tools.build:gradle:1.2.3 'Classpath' com.neenbedankt.gradle.plugins:android-apt:1.4 'Classpath' com.novoda:bintray-release:0.3.4 '//Add}}allprojects {repositories {jcenter ()}}//Addext {userorg =' hongyangandroid 'GroupId =' Com.zhy 'Uploadname =' Mpermission 'Publishversion =' 1.0.1 ' desc=' A easy API to use runtime permission for Android M 'Website =' Https://github.com/hongyangAndroid/MPermissions 'licences = [' Apache-2.0 ']}
As long as the focus on the added part, the bottom of ext is mainly for uploading multiple module unified management.
Module's Build.gradle
The remaining is compilter , permission-annotation and permission-lib these three modules, the processing of these three module is in fact consistent:
- Apply Plugin
- Fill in publish information
‘com.android.library‘‘bintray-release‘//添加android {}dependencies {}//添加publish { ‘mpermission-api‘ userOrg = rootProject.userOrg groupId = rootProject.groupId uploadName = rootProject.uploadName publishVersion = rootProject.publishVersion desc = rootProject.description website = rootProject.website licences = rootProject.licences}
The configuration of the 3 modules is the same, the only difference is the publish artifactId , the different module should have its different names.
After all the module configurations that need to be uploaded are complete, as above, run the upload command.
./gradlew clean build bintrayUpload -PbintrayUser=hyman -PbintrayKey=xxxxxxxxxxxxxxxxxxxxxx -PdryRun=false
You can choose to do it in the terminal panel of Android studio, as in.
OK, and then just follow the steps in the normal project above, go Add to Jcenter , wait.
If the audit succeeds, you will find that 3 module will be synchronized to the jcenter, such as Access http://jcenter.bintray.com/com/zhy/ :
In use, for compiler, you need to introduce APT's plug-in, roughly similar to the following usage:
Apply plugin: ' Com.neenbedankt.android-apt '
dependencies {
Apt ' com.zhy:mpermission-compiler:1.0.0 '
Compile ' com.zhy:mpermission-api:1.0.0 '
}
OK, of course, the focus of this article is to upload, other aspects of the details will not be described.
So how to use the bintray-release upload open source project to jcenter the introduction is complete, hope to save your time ~
Welcome to follow my Weibo:
http://weibo.com/u/3165018720
Follow the public number: Hongyangandroid
(Welcome attention, the first time to push the blog post information)
Android Quick release Open source project to Jcenter