注册
https://bintray.com/
注册一个账号。
获取API Key
https://bintray.com/profile/edit
创建与配置项目
- 修改项目目录下的
build.gradle
,添加依赖
// 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.0'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
- 修改要打包成aar的moudle下的
build.gradle
apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
version = "0.6.6" // #CONFIG# // project version
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 8
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
}
def siteUrl = 'https://github.com/hanks-zyh/AnimateCheckBox' // #CONFIG# // project homepage
def gitUrl = 'https://github.com/hanks-zyh/AnimateCheckBox.git' // #CONFIG# // project git
group = "com.hanks" // #CONFIG# // Maven Group ID for the artifact (pageckage name is ok)
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
name 'Less Code For Android' // #CONFIG# // project title
url siteUrl
// Set your license
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'hanks' // #CONFIG# // your user id (you can write your nickname)
name 'hanks' // #CONFIG# // your user name
email 'zhangyuhan2014@gmail.com' // #CONFIG# // your email
}
}
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.getBootClasspath().join(File.pathSeparator))
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
}
artifacts {
archives javadocJar
archives sourcesJar
}
//在local.properties添加bintray.user和bintray.apikey
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())
bintray {
user = properties.getProperty("bintray.user")
key = properties.getProperty("bintray.apikey")
configurations = ['archives']
pkg {
repo = "maven"
name = "AnimateCheckBox" // #CONFIG# project name in jcenter
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
}
}
执行 bintrayUpload
当bintrayUpload成功之后,
到 https://bintray.com/ 查看刚上传的项目
找到 Maven Central 标签,提示体积jcenter审核
上传到 jcenter
等邮件通知,审核通过之后可以查看
到http://jcenter.bintray.com/ 按照路径查看是否存在
如 otto 的 http://jcenter.bintray.com/com/squareup/otto/1.3.7/
然后别人就可以添加引用,从远程下载了