- 注册账号
到
https://bintray.com注册账号,然后进入Your profile,查看API Key。下面3步配置上传信息时会用到
- build.gradle引用插件
在项目下的build.gradle引入插件需要的库
classpath
'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
classpath
'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
此处需注意:在网上看的blog写的是引用
classpath 'com.github.dcendents:android-maven-plugin:1.2',但是我build的时候会报Cause: org/gradle/api/publication/maven/internal/DefaultMavenFactory错误,
搜索过后发现应该是gradle的版本高了,就替换成现在这个引用路径(不要只改版本号哦)
在你需要上传的lib的build.gradle引用插件
apply
plugin
:
'com.github.dcendents.android-maven'
apply
plugin
:
'com.jfrog.bintray'
- 在build.gradle配置自动上传的信息
在项目的local.properties中配置你的账号信息
bintray.user
=你自己的账号
bintray.apikey
=你自己的API Key
在你需要上传的lib的build.gradle中,配置上传到中央库的lib信息(可以复制,替换里面的信息成自己的)
def
siteUrl =
'https://github.com/happyjosh/XXXRecyclerView'
//
项目的主页
def
gitUrl =
'https://github.com/happyjosh/XXXRecyclerView.git'
// Git
仓库的
url
version =
"1.0.0"
//
显示的版本号,每次版本更迭需要同步更新
group =
"com.jph"
// Maven Group ID for the artifact
,一般填你唯一的包名
install {
repositories.
mavenInstaller
{
// This generates POM.xml with proper parameters
pom {
project {
packaging
'aar'
// Add your description here
name
'A recyclerview can load more'
//
项目描述
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
'jph'
//
填写开发者基本信息
name
'jph'
email
'jiangpenghui@live.cn'
}
}
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
}
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"
//
发布到
Bintray
的那个仓库里,默认账户有四个库,我们这里上传到
maven
库
name =
"xxxrecyclerview"
//
发布到
Bintray
上的项目名字
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = [
"Apache-2.0"
]
publish =
true
}
}
- 命令行上传中央仓库
在Android Studio的Terminal下执行命令
- 首先build项目生成arr文件
gradle build
- 执行上传
gradle bintrayUpload
上传成功后,进入网站流可以查看到你的lib了
到此,你的项目就已经上传成功了。
- 关联的jcenter
虽然已经上传成功了,不过我们现在Android Studio开发一般只引用了jcenter的仓库,所以需要关联到jcenter
send过后等消息就是了。个人经验的话,反正不超过一天。。就ok了
PS:弄的时候,是参照
http://www.kuqin.com/shuoit/20150524/346208.html这个来的,如果没看懂得同学,可以去看看这个。