Androidstuio quick release of open source projects to Jcenter/bintray

Source: Internet
Author: User
Tags jfrog jcenter

Androidstuio quick release of open source projects to Jcenter/bintray

Copyright NOTICE: Reprint Please specify this article to the blog from Zhangjie: http://blog.csdn.net/yanzhenjie1003

QQ Exchange Group 1:46,505,645
QQ Exchange Group 2:46,523,908
Group resources are limited, please do not repeat add group, thank you.

Objective

Recently made two open source projects, one is the Android network framework Nohttp, and volley, okhttp as the client request, more relevant information please Baidu OH; the other is the Android Web server framework Andserver, A framework for building a Web server on Android, similar to Java Servlet , for more information, see this blog post.
Why do you want to say that this paragraph, one is to give their own propaganda, and the other is that both frameworks support Gradle a word rely on use, someone asked me, my open source project how to support Andtoidstudio Gradle compile rely on it? So write a blog tutorial here.

The necessary preparatory work
    • Androidstudio, Gradle and their own open source projects this must have.
    • Jcenter is Bintray under a warehouse, so Bintray account must, no classmate see below how to apply.
    • The network must be unblocked to be able to access the https://bintray.com
How to apply for Bintray account

No Bintray account of the students to Bintray official website application, enter the page and click on the upper right corner of the Sign In login, if there is an account of the person can directly login, no account of the students click on the following Sign Up registration account, operation process:

The first step, login or register the entrance

Click the Sign In button to log in or register.

Step two, log in or go to the registration page

Have an account login directly, or use a third-party account (Github, twwiter,google+) login, if you do not have an account, click Sign Up Register:

Step three, register your account and activate

According to the prompt to enter the relevant information registration, e-mail address gray is often important, be sure to fill out their most commonly used, recover passwords and so on, after registration will receive an activation of the mail, according to the prompt activation is good.

Fourth step, get your apikey.

Apikey is our release of the project to Jcetner must be used, to get the apikey after the save and so on to use, the steps are as follows:
  

4.1 Open the Personal configuration page and click [Edit]

Get Apikey must first login, login success, the upper right corner of the original display of Sign In their own user name, the mouse point to the user name when there is a drop-down menu, we need to click Your Profile , the page appears on the left side of your avatar and user name below there is a [Edit], shown:

4.2 Enter login password copy apikey

Click on the new page after the edit, select [API Key] on the left, will come out the following page, enter your login password click on the below the submit will show a apikey, shown:

After entering the password, click Submit to display the following, the mouse selected text after copying and saving (note Do not click on revoke it, this is to revoke the meaning of this apikey):

Configuration Items Gradle and local.properties

We upload the project to Jcenter using Gradle task automatically, so only need to configure a good gradle a word to complete the upload, the following is the configuration in the project.
Before we begin, let's take a picture of andserver, for example:

(i) Gradle files for configuration items

Our project will generally have multiple gradle configuration files, the first step is to configure the project's Gradle, not module/library gradle, that is, the [project's gradle] labeled files, Your project should only be different from the code under the Dependencies node:
  This is before the modification:

{    repositories {        jcenter()    }    {        classpath ‘com.android.tools.build:gradle:2.1.2‘    }{    repositories {        jcenter()    }{    delete rootProject.buildDir}

  This is after the change:

{    repositories {        jcenter()    }    {        classpath ‘com.android.tools.build:gradle:2.1.2‘        // 添加下面两行代码即可。        classpath ‘com.github.dcendents:android-maven-gradle-plugin:1.3‘        classpath ‘com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4‘    }{    repositories {        jcenter()    }{    delete rootProject.buildDir}
(ii) Configuring the Gradle file of the library/module to be uploaded

The second step is to configure the Gradle of the module to be uploaded, rather than the gradle of the entire project, which is the file labeled [Library Gradle]:
  This is before the modification:

‘com.android.library‘android {    23    "23.0.3"    defaultConfig {//      applicationId "com.yanzhenjie.andserver.sample" // 这一行要删除,因为library不允许有applicationId。       8        23        1        ‘1.0.1‘    }}dependencies {    // 如果你的library有依赖别的jar,这里要把jar依赖进来。    compile fileTree(dir‘libs‘, includes: [‘*.jar‘])}

  This is after the change:

Apply plugin:' Com.android.library '//Add the following two lines of code here. Apply plugin:' Com.github.dcendents.android-maven 'Apply plugin:' Com.jfrog.bintray 'Android {Compilesdkversion atBuildtoolsversion"23.0.3"Resourceprefix"Andserver_res_"Defaultconfig {//ApplicationID "com.yanzhenjie.andserver.sample"//This line is to be deleted because the library is not allowed to have applicationid. Minsdkversion8Targetsdkversion atVersioncode1Versionname' 1.0.1 '}}dependencies {//If your library has dependencies on other jars, this is where the jar is dependent. Compile Filetree (dir:' Libs ', includes: [' *.jar '])}//The version number of the project reference, such as the 1.0.1 in compile ' com.yanzhenjie:andserver:1.0.1 ', is configured here. Version ="1.0.1"//define two links, which will be used below. defSiteURL =' Https://github.com/yanzhenjie/AndServer ' //Project home page. defGiturl =' [Email protected]:yanzhenjie/andserver.git ' the URL of the//Git repository. //Unique package name, such as compile ' com.yanzhenjie:andserver:1.0.1 ' in the Com.yanzhenjie is configured here. Group ="Com.yanzhenjie"Install {repositories.maveninstaller {//Generate Pom.xml and ParametersPom {Project {packaging' AAR '                //Project description, copy my words, here need to change. Name' andserver for Android '//optional, project name. Description' The Android build the framework of the Http server. '//optional, item description. URL SiteURL//Project homepage, here is the reference above defined.                 //Software Open source Agreement, now generally is Apache License2.0 bar, copy my, here do not need to modify. Licenses {license {name' The Apache software License, Version 2.0 'Url' Http://www.apache.org/licenses/LICENSE-2.0.txt '}                }//Fill in the developer basic information, copy my, here need to change. Developers {developer {ID' Yanzhenjie ' //Developer's ID. Name' Yanzhenjie ' //Developer name. Email' [email protected] ' //Developer email. }                }//SCM, copy My, there is no need to modify. SCM {Connection Giturl//Git warehouse address. Developerconnection Giturl//Git warehouse address. URL SiteURL//Project home page. }            }        }    }}//Generate a task for the jar package, no modification is required. Task Sourcesjar (type: Jar) {from android.sourceSets.main.java.srcDirs classifier =' Sources '}//Generate Jardoc task, no modification required. Task Javadoc (type: Javadoc) {Source = Android.sourceSets.main.java.srcDirs Classpath + = Project.files (Android.getbootclasspath (). Joi N (file.pathseparator))//Destinationdir = File (".. /javadoc/")FailOnErrorfalse //Ignore comment syntax error, compile if jdk1.8 is written in your comment. }//Generate Javadoc jar, no modification required. Task Javadocjar (type: Jar, Dependson:javadoc) {classifier =' Javadoc 'From javadoc.destinationdir}artifacts {Archives Javadocjar Archives Sourcesjar}//Here is read Bintray related information, we upload the project to GitHub when the Gradle file will be transmitted up, so do not put the account password information directly here, written in local.properties, here dynamic read. Properties Properties =NewProperties () properties.load (Project.rootProject.file (' Local.properties '). Newdatainputstream ()) bintray {user = Properties.getproperty ("Bintray.user")//Bintray user name. Key = Properties.getproperty ("Bintray.apikey")//Bintray just saved the apikey. configurations = [' Archives '] pkg {repo ="maven"  //upload to Maven library. Name ="Andserver"  //Publish to Bintray on the name of the project, where the name is not andserver in compile ' com.yanzhenjie:andserver:1.0.1 '. Websiteurl = SiteURL Vcsurl = Giturl licenses = ["Apache-2.0"] Publish =true //Whether it is a public project. }}

There are two special places to note:

    1. We upload the Open source project will generally be hosted on GitHub, we upload the project and module's Gradle file, so do not put the account password information directly in the Gradle file, and our local.properties files are generally not uploaded (inexperienced people may pass), So we configure the user's privacy information in the local.properties gradle dynamic read, how to read, in the last code block above is introduced.
    2. We saw in the Module/library gradle in the pkg name="andserver" , this name is our project in Bintray name, so this andserver is not compile ' com.yanzhenjie:andserver : 1.0.1 ' andserver , so where is the compile in the andserver configuration? Compile's library name is the name of Library/module , as shown in:

(iii) Configuring user privacy information for Module/libraray in Local.properties

We will configure a number of variables in the local.properties dynamic reference or read elsewhere, so that you can modify a place, other places can not change:

sdk.dir=你的sdk路径# 其实你只需要添加下面两行,第一个填你的用户名,比如我的是yolanda。bintray.user=yolandabintray.apikey=fa************************5a

Notice me here in order not to leak my apikey, use * instead of, you want to write your complete apikey oh.

Uploading items to Jcenter

Preparation work is done, the last step is to upload the operation, click on the bottom of the Androidstudio terminal, see Terminal the path shown is the root of your current project.

    1. Here if your system is configured with Gradle user environment, enter, gradle install if not configured Gradle user environment, enter gradlew install , if there is no problem, eventually you will see BUILD SUCCESSFUL .
    2. If you see the build Javadoc compile, then look at the Gradle in the task Javadoc there is no failOnError false such sentence, in the earlier writing Gradle prompted. If you add this sentence and your Javadoc will have a warning, you don't have to bird it.
    3. The last step, after the run to gradle install see BUILD SUCCESSFUL , then enter the upload command gradle bintrayUpload , wait a minute or so after the execution, will prompt SUCCESSFUL .
    4. You will see your project after the browser https://bintray.com/.

Upload done, but don't worry. You will find that dependency failure is dependent on the following code in the project Gradle:

‘compile ‘包名:模块名:1.0.0‘

The reason is that after we upload the project also need Bintray admin audit, so on the project page just click to see the details, click Add to Jcetner :

After the page to fill in the project information, to Bintray Administrator audit:

Audit pretty fast, I was submitted at night, the next morning on the bus received the approval of the mail, audit through can use Gradle compile rely on, wish you good luck oh.

Copyright NOTICE: Reprint Please specify this article to the blog from Zhangjie: http://blog.csdn.net/yanzhenjie1003

Androidstuio quick release of open source projects to Jcenter/bintray

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.