- 注册账号 地址:https://bintray.com/ 可用第三方登录(github)
- 在个人资料里找到API Key 保存下,之后上传有用
- 新建 Maven Repositor 和Package
- 在项目 root gradle 添加插件
novoda 是个第三方库 更简洁 地址:https://github.com/novoda/bintray-releaseclasspath 'com.novoda:bintray-release:0.8.0'
- 在需要上传的modul的build 添加
def siteUrl = 'https://github.com/hjk6688/git.git' publish{ repoName = 'Victory'//远程仓库名字,不指明,默认是上传到maven userOrg = 'hjk6688'//bintray.com的用户名 groupId = 'com.huangjingkai'//jcenter上的路径 以后引用的话 implemetation 'com.huangjingkai.empty:1.0.0' artifactId = 'empty'//项目名称 publishVersion = '1.0.0'//版本号 desc = '空的项目'//描述,不重要 website = siteUrl//项目主页 }
执行脚本
./gradlew clean build bintrayUpload -PbintrayUser=hjk6688 // 用户名 -PbintrayKey=xxxxxxxxxxxxxxxxxxxxxx // 之前存的api key -PdryRun=false // 若为true 执行完成单不上传
- 去https://bintray.com/用户名/仓库名/ 下Add to JCenter 等待审核过后即可使用
其实碰到的问题:
1. Unable to load class ‘org.gradle.api.internal.component.Usage
解决方法: 升高novoda 库的版本
2. Unable to load class ‘org.gradle.api.internal.component.Usage
解决方法: 降低build 的版本
3. 防止乱码
tasks.withType(Javadoc) {//防止编码问题
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
options.addStringOption('charSet', 'UTF-8')
}
4.Error:Could not determine java version from '9.0.4'
切换jdk 版本
我上传成功最终的配置:
novoda 0.8
jdk9
build 4.4 build tool 3.1.0