Android quickly releases open-source projects to jcenter
In most cases, you want to make your open-source projects more convenient for users to use. A good way for the Android platform is to upload the files to the jcenter, and then addcompile
Reference.
For articles uploaded to the jcenter, It is not technical, and there are already many good articles for reference. Before I write it, I also gave a rough look at Baidu.
Currently, many articles usegradle-bintray-plugin
This plug-in is used for uploading. Most articles are intended for common open-source projects (that is, it does not contain compile-time annotations ). For compilation annotationsmodule
Upload may be troublesome.
This article is intended for usebintray-release
This plug-in is more personalgradle-bintray-plugin
It is much more convenient.
Usebintray-release
Publish a general project to jcenterbintray-release
Release the annotation project to jcenter during compilation
1. Upload a common project to jcenter
OK. First, you should have a project to be uploaded.
We will simulate a simple project here.
We can see that our basw.ls is an Android library mainly used to store some tools. Now we want to upload them to jcenter.
So, you should already have an Android library in the pending upload status.
(1) register a bintray.com account
Why do you need to register this account?jcenter()
A repository under bintray.
Our upload process is, from your Androd Studio to your bintray repository, and finally to the jcenter repository.
Go to https://bintray.com/and register the account number. After the registration is complete, you need to activate the email address. You can also select a third-party login.
After the registration is complete, log on. These two steps can be done by non-professional players.
After Logon:
After logging in, you can clickYour Profile
->Edit
Then you can see the interface.
Click the API Key to view your key string. Place this copy aside and use it for later upload.
(2) Introduce build. gralde of the bintray-release project
Add in build. gradle of your projectbintray-release
The classpath of the project is the build. gradle of the project, not the module.UploadJcenterTest/build.gradle
.
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.2.3' classpath 'com.novoda:bintray-release:0.3.4' }}
Build. gralde of moudle to be uploaded
The module you want to upload.UploadJcenterTest/basetools/build.gradle
.
Apply plugin: 'com. android. library 'apply in: 'com. novoda. bintray-release '// Add android {// remain unchanged} dependencies {// remain unchanged} // Add publish {userOrg = 'hyman' // bintray.com username groupId = 'com. hybrid' // jcenter path artifactId = 'basathls' // project name publishVersion = '1. 0.0 '// version desc = 'Oh hi, this is a nice description for a project, right? '// Description, not important website = 'https: // github.com/hyman/bas#ls'//website, not important}
Just write the code above, and the details are marked and annotated. Assuming that according to the above writing, the final introduction method is as follows:
compile 'com.hyman:basetools:1.0.0
After completing the preceding configuration, you are ready to upload the file.
Upload
Upload is simple. Just execute the following code.
./gradlew clean build bintrayUpload -PbintrayUser=hyman -PbintrayKey=xxxxxxxxxxxxxxxxxxxxxx -PdryRun=false
User is the user name, key is the key we just asked you to save, dryRun is a configuration parameter, when it is true, it will run all the links, but will not upload.
OK. The following code is compiled and run. You can choose to run the program on the Terminal panel of Android Studio, as shown in.
Click Terminal at the bottom. Note that your current path is under the current project, and then enter to run.
Then wait. When the operation is complete, you can seeBUILD SUCCESSFUL
There is no problem. If there is any problem, troubleshoot it according to the log.
Now the upload is complete ~~~
You can accessHttps://bintray.com/your user name /maven
, You can see:
When you see the uploaded project, you can click to view some information about the library, but note that it cannot be directly referenced at this time.
Click to enter the database, follow, and clickAdd To jcenter
Then write the description of your database and click send.
OK, it is over now, but it cannot be referenced directly at present. You need to wait for the bintray staff to review it. After the review is passed, a site Message will be sent to you, andAdd to Jcenter
That button takes an hour. In addition, you can access the website based on the groupId you uploaded.Https://jcenter.bintray.com/your groupid
Example https://jcenter.bintray.com/com/hyman/
If it can be referenced, you can see the following:
Finally, the whole process is very simple:
Apply for an account to introduce bintray-release, and fill in the relevant publish information in the module to be uploaded to call the Upload Command
Add to Jcenter
Submit for review
Basically, it is step-based. What we need to fill out is just a few pieces of information in publish.
OK. Next, let's take a look at the project annotated during compilation.
Ii. Upload the annotation project to jcenter during compilation
If you do not need this requirement for the time being, you do not need to read it because it is not a technical article. If you know that there is something to write here, you can add it to your favorites. If you need it, you can just check it back.
In fact, it is also very simple, just follow the steps.
Here we will look for a project for demonstration.
Why is the project annotated during compilation special?
Because it generally involves multiple moudle, for examplecompilter
,permission-annotation
,permission-lib
.
When we upload the three modules, We need to upload them. This does not involve module-related knowledge.
Actually usebintray-release
The upload process is also very simple.
Project build. gradle
First, build. gradle for the project, that isMPermissions/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 ()} // Add ext {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-000000']}
As long as you focus on the added part, the ext at the bottom is mainly used to upload multiple modules for unified management.
Module build. gradle
The rest iscompilter
,permission-annotation
,permission-lib
The processing of these three modules is actually consistent:
Apply plugin fill in publish information
Apply plugin: 'com. android. library 'apply plugin: 'bintray-release' // Add android {} dependencies {} // Add publish {artifactId = 'mpermission-api' userOrg = rootProject. userOrg groupId = rootProject. groupId uploadName = rootProject. uploadName publishVersion = rootProject. publishVersion desc = rootProject. description website = rootProject. website licences = rootProject. licences}
The configurations of the three modules are the same. The only difference is thatartifactId
Different modules should have different names.
After configuring all the modules to be uploaded, run the Upload Command as above.
./gradlew clean build bintrayUpload -PbintrayUser=hyman -PbintrayKey=xxxxxxxxxxxxxxxxxxxxxx -PdryRun=false
You can select the Terminal panel of Android Studio, as shown in.
OK, and the steps are the same as those of the above common project.Add to Jcenter
And then wait.
If the review succeeds, you will find that all three modules will be synchronized to the jcenter, such as accessinghttp://jcenter.bintray.com/com/zhy/
:
For compiler, apt plug-ins need to be introduced, which are 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 on uploading. I will not go into details about other aspects.
How to Usebintray-release
Upload the open-source project to jcenter and you will be able to save your time ~