Android Studio released to Jcenter
1. Preface
Embrace open source, love open source, open source code that we think is good to gihtub, and release our library to jcenter \ mevan.
2. Preparations 2.1 prepare to apply for a repository account. Note that the model is introduced as the android library Project 2.2 plug-in.
Add it to the gradle file in the root directory
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' classpath 'com.github.dcendents:android-maven-plugin:1.2'
I personally think it is best to keep this one.
Finally, the gradle file in the root directory looks like this.
// Top-level build file where you can add configuration options common to all sub-projects/modules.buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:1.3.0' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2' classpath 'com.github.dcendents:android-maven-plugin:1.2' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files }}allprojects { repositories { jcenter() }}task clean(type: Delete) { delete rootProject.buildDir}
2.3 create a bintray. gradle file in the root directory (this name is required)
Group = PROJ_GROUPversion = PROJ_VERSIONproject.archivesBaseName = PROJ_ARTIFACTIDapply plugin: 'com. jfrog. bintray 'apply plugin: 'maven-publish 'task sourcesJar (type: Jar) {from android. sourceSets. main. java. srcDirs classifier = 'Sources '} task javadoc (type: Javadoc) {source = android. sourceSets. main. java. srcDirs classpath + = tolerations. compile classpath + = project. files (android. getBootClasspath (). join (File. pathSeparator)} task javadocJar (type: Jar, dependsOn: javadoc) {classifier = 'javadoc 'from javadoc. destinationDir} javadoc {options {encoding "UTF-8" charSet 'utf-8' author true version true links "http://docs.oracle.com/javase/7/docs/api" title tags} artifacts {archives javadocJar archives sourcesJar} def pomConfig = {licenses {license {name "The Apache Software License, version 2.0 "url" http://www.apache.org/licenses/LICENSE-2.0.txt "distribution" repo "}}developers {developer {id pair _id name pair _name email pair _email }}// there are quotation marks and spaces, otherwise, the dependency cannot be generated. The dependencies here are not build. in gradle, gradle treats it as its own dependencies and processes "dependencies" {// dependency {// groupId "com. alibaba "// artifactId" fastjson "//" version "" 1.2.6 "// same dependencies // }}publishing {publications {mavenJava (MavenPublication) {artifactId PROJ_ARTIFACTID pom {packaging 'aar'} pom. withXml {def root = asNode () root. appendNode ('description', PROJ_DESCRIPTION) root. children (). last () + pomConfig }}} bintray {Properties properties = new Properties () properties. load (project. rootProject. file ('local. properties '). newDataInputStream () user = properties. getProperty ('bintray _ user'); key = properties. getProperty ('bintray _ key '); deployments = ['archivees'] publications = ['mavenjava'] publish = true pkg {repo = 'maven 'name = PROJ_NAME desc = PROJ_DESCRIPTION websiteUrl = protected URLs = protected vcsUrl = PROJ_VCSURL licenses = ['apache-2.0 '] publicDownloadNumbers = true }}
The above files do not need to be modified. If the package you want to upload contains other third-party libraries. Declare in the following Blocks
"Dependencies" {// dependency {// groupId "com. alibaba" // artifactId "fastjson" // "version" "1.2.6" /// same as dependencies //}}
Easy to understand and clear at a glance.
2.4 configure the signature \ introduce bintray. gradle in the gralde file corresponding to the Model. The final code is as follows. If you do not understand the configuration, read this article or read gradle for android.
apply plugin: 'com.android.application'android { compileSdkVersion 23 buildToolsVersion "23.0.2" signingConfigs { config { keyAlias 'guolei' keyPassword '123456' storeFile file('guolei.jks') storePassword '123456' } } defaultConfig { applicationId "com.gl.draggridview" minSdkVersion 17 targetSdkVersion 23 versionCode 1 versionName "1.0" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.config } }}dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) //compile 'com.android.support:appcompat-v7:23.1.1'}apply from:'../bintray.gradle'
Note that bintray. gradle must be placed at the bottom of the file.
Configure BINTRAY_KEY and BINTRAY_USER, that is, the one registered at the beginning.
Guolei1130 is my User Name. view the key and click edit,
Click api key and show.
Configure local. properties in the root directory.
BINTRAY_KEY=e21c3f96df17xxxxxxxxBINTRAY_USER=guolei1130
This section corresponds to the Code in bintray. gradle. Of course, you can modify this code and write these two attributes at any location.
Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) user = properties.getProperty('BINTRAY_USER'); key = properties.getProperty('BINTRAY_KEY');
Finally, sync now.
3. Prepare 3.1 aar package before upload (upload)
Build to generate the corresponding aar package.
3.2 generate jardocjar sourcesjar
In the other task corresponding to the model, locate the above two tasks and click Generate. Generally, no error occurs.
3.3 click task in publish to generate the pom File
Click the second one.
Upload 3.4
Click the first task in. If an error occurs, troubleshoot the error. This is generally an issue related to identity authentication.
4. Imported jcenter (subject to review)
This mevan repository was uploaded just now, but we need to import it to jcenter. Click jcenter. Click "import on the" side "to filter the database to be imported and wait for the Administrator to review it.
5. Finally, let's take a look at my library.
Github address, ask for a star
The last figure proves that I just uploaded it.
That's so easy.