简介
本文介绍如何发布一个简单的项目到Bintray
注册账号和生成Maven库的步骤省略,不过注意Maven库的名字最好取maven。
上传的主项目的gradle的配置
上传的插件用的是 com.novoda:bintray-release:0.3.4
如果项目中包含中文注释或中文字符,最好添加
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
}
不然会报错
项目Gradle配置
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.novoda:bintray-release:0.3.4'
}
}
allprojects {
repositories {
jcenter()
}
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
上传的Module的gradle的配置
添加
apply plugin: 'maven'
apply plugin: 'com.novoda.bintray-release'
publish {
userOrg = 'anotherme17'//bintray.com用户名
groupId = 'com.anotherme17'//jcenter上的路径
artifactId = 'common-adapter'//项目名称
publishVersion = '0.0.1'//版本号
desc = 'An CommonAdapter for ListView or RecyclerView'//描述,不重要
website = 'https://github.com/anotherMe17/CommonAdapterSample'
//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
}
apply plugin: 'com.android.library'
apply plugin: 'maven'
apply plugin: 'com.novoda.bintray-release'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
minSdkVersion 15
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
checkReleaseBuilds false
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
}
publish {
userOrg = 'anotherme17'//bintray.com用户名
groupId = 'com.anotherme17'//jcenter上的路径
artifactId = 'common-adapter'//项目名称
publishVersion = '0.0.1'//版本号
desc = 'An CommonAdapter for ListView or RecyclerVIew'//描述,不重要
website = 'https://github.com/anotherMe17/CommonAdapterSample'
//网站,不重要;尽量模拟github上的地址,例如我这样的;当然你有地址最好了
}
执行
在控制台输入以下代码
./gradlew clean build bintrayUpload
-PbintrayUser=hyman
-PbintrayKey=xxxxxxxxxxxxxxxxxxxxxx
-PdryRun=false
user就是用户名,key就是我们刚才的让你保存的key,PdryRun是一个配置参数,当为true的时候,会运行所有的环节,但是不会上传