1.在local.properties下添加:
bintray.user = ******
bintray.apikey = 45********1f7f5779f008*******aa610c***
2.在build.gradle添加
1).添加插件
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'
2).定义版本
version = "1.0.0"
//上面添加顶部 下面添加底部
3).定义相关网站
def siteUrl = 'https://github.com/xxxxx/xxxx' // project homepage
def gitUrl = 'https://github.com/xxxxx/xxxx.git' // project git
4).定义Group
//第一部分就是group,第二部分是name, 第三部分是上面定义的version。
group = "xxx.xxxxx.xxxxx:1.0.0"
5). 定义pom并打包aar
install {
repositories.mavenInstaller {
// This generates POM.xml with proper parameters
pom {
project {
packaging 'aar'
name 'xxxx'
url siteUrl
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'xxxxx'
name 'xxxxx'
email '1825203636@qq.com'
}
}
scm {
connection gitUrl
developerConnection gitUrl
url siteUrl
}
}
}
}
}
7). 打包javadocjar和sourcejar
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"
name = "xxxxx"
// #CONFIG# project name in jcenter
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = ["Apache-2.0"]
publish = true
}
}
转载于:https://my.oschina.net/spoon2014/blog/647601