Submit your own Open source project to Jcenter

Source: Internet
Author: User
Tags jfrog maven central jcenter

Begin

Recently wrote an open source control, which is about the label flow control (get the label from the server side, and then put the label into a container adaptively). Now that the control is finished, you want to submit it to MAVEN's central repository or jcenter. However, I am not familiar with Maven, and the project written in Android Studio submitted to Maven's central warehouse is indeed more cumbersome, so decided to use Jcenter.

Apply for Account

Close with the project submitted to the Jcenter, there is a tutorial on the net written very well, I basically also refer to the above to do, but also encountered some pits on the way, so I think it is necessary to narrate. First of all you have to do is to apply for Bintray account, it is jcenter custodian, after the registration is completed, you need to come to this interface, remember your account name and API key, I generally put it in the Local.properties file. Because we'll use it later, after that, your first step is almost done.

//local.propertiessdk.dir=/Applications/ADT/sdkbintray.user = fyalesbintray.apikey = *************************
Configure the project's Build.gradle file and the Build.gradle file for the module you want to submit

Let's look at the Build.gradle file:

buildscript {    repositories {        jcenter()    }    dependencies {        classpath ‘com.android.tools.build:gradle:1.1.0‘        classpath ‘com.github.dcendents:android-maven-plugin:1.2‘        classpath ‘com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0‘        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }}allprojects {    repositories {        jcenter()    }}

The warehouse we use here is jcenter and not mavencentral. And we need to introduce the official two plugins android-maven-plugin and gradle-bintrayl-plugin so that we can submit the project to Jcenter.

The next step is to configure the module's Build.gradle file.

 Apply plugin: ' com.android.library ' Apply plugin: ' Com.github.dcendents.android-maven ' Apply plugin: ' Com.jfrog.bintray '//version number to be submitted to the warehouse versions = "1.0.0" Android {compilesdkversion buildtoolsversion "21.1.2" default Config {minsdkversion targetsdkversion versioncode 1 Versionname "1.0"} Buildtyp Es {release {minifyenabled false proguardfiles getdefaultproguardfile (' Proguard-android.txt '), ' Proguard-rules.pro '}}}dependencies {compile filetree (dir: ' Libs ', include: [' *.jar ']) compile ' com . android.support:appcompat-v7:21.0.2 '}def siteurl = ' https://github.com/fyales/tagcloud '//project home def giturl = ' https:        Github.com/fyales/tagcloud.git '//git repository Urlgroup = "com.fyales.android" Install {repositories.maveninstaller {                Pom {project {packaging ' AAR ' name ' Android tagcloud '//Project description    URL SiteURL Licenses {                License {name ' The Apache software license, Version 2.0 ' ur                    L ' Http://www.apache.org/licenses/LICENSE-2.0.txt '}} developers {                        Developer {ID ' fyales '//fill in some basic information name ' Fyales '                    Email ' [email protected] '}} SCM {            Connection giturl developerconnection giturl URL SiteURL} }}}}task Sourcesjar (Type:jar) {from android.sourceSets.main.java.srcDirs classifier = ' sources '} Task Javadoc (type:javadoc) {Source = Android.sourceSets.main.java.srcDirs Classpath + = Project.files (android.getbo  Otclasspath (). 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. Rootproject.file (' local.properties '). Newdatainputstream ()) bintray {user = Properties.getproperty ("Bintray.user") K EY = Properties.getproperty ("Bintray.apikey") configurations = [' archives '] pkg {repo = "maven" name        = "Tagcloud"//Published to Jcenter on the project name Websiteurl = SiteURL Vcsurl = giturl licenses = ["Apache-2.0"] Publish = True}}

This string of code has done three things.

    • Generate Javadoc
    • Generate Jar
    • Configure information for our project

Here I would like to remind you that generating javadoc and jars is a required option. At first I thought it was unnecessary to do this, so I didn't write the command to generate the Javadoc and jar, so I received the official email from Bintray (another item in the mail):

Bintray (bintray) has sent you a direct message from Bintray:Hi, Jcenter hosts java applications that follows maven convention.In addition to the .aar and pom files in the path: /com/fyales/parser/1.0.0, your version should include a sources jar, and optionally a javadoc jar. Your files should be under a maven path layout.(see https://bintray.com/docs/usermanual/uploads/uploads_includingyourpackagesinjcenter.html)Once those files are added, we‘ll be glad to include your package in JCenter.Regards,Bintray Support

There's a pit down here. I wrote the Javadoc command at the beginning of the run failed, which is because I like to write in my comments like this

Because Javadoc inside does not have @date, so will parse the failure, everybody also must pay attention to ....

Once you've done this, you can run the following command to submit your project to Bintray.

./gradlew bintrayUpload
The final step

Once the submission is complete, you can apply your project to Jcenter, click on the Include My package, enter your project name in the popup interface to confirm it, and when the audit passes, you can use your own project directly.

dependencies {    compile ‘com.fyales.android:library:1.0.0‘}
Other points of attentionBuild failed (failure reason cannot call Getbootclasspath () before Settargetinfo () was called.)

Solution: Upgrade the Gradle version to 1.2

Summarize

Jcenter compared to Maven Central is very convenient, and in the software development process, sometimes also need to know it, but also know why.

Slogan: Make things interesting!

Reference

Publish projects to the Jcenter warehouse using Gradle

Submit your own Open source project to Jcenter

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.