资料
说明
上传到bintray之后,可以一键上传到jcenter
基本用法
配置gradle
工程最外层的build.gradle
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0-rc03'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
//https://github.com/novoda/bintray-release 找最合适的版本就好上传了
classpath 'com.novoda:bintray-release:0.9.2'
}
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.3.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.0-rc03'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.novoda:bintray-release:0.9.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
}
tasks.getByPath(":commonlite:javadocRelease").enabled = false
tasks.getByPath(":commonlite:javadocRelease").enabled = false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
需要上传的库build.gradle
apply plugin: 'com.android.library'
apply from: 'https://gitee.com/WhatINeed/gradles/raw/master/common_androidx.gradle'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.novoda.bintray-release' // must be applied after your artifact generating plugin (eg. java / com.android.library)
publish {
//repo = "flanneryzj"
userOrg = 'adrianandroid' //bintray注册的用户名
groupId = 'com.istarshine.common' //compile引用时的第1部分groupId
artifactId = 'commonlite' //compile引用时的第2部分项目名
publishVersion = '0.0.1' //compile引用时的第3部分版本号
desc = '基本库'
website = 'https://github.com/AdrianAndroid/commonlib'
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
//# [新版Bintray-极简上传Library到JCenter](http://blog.csdn.net/wzgiceman/article/details/53707042)
// > chmod a+x gradlew
// > ./gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME -PbintrayKey=BINTRAY_KEY -PdryRun=false
//
//./gradlew clean build bintrayUpload -PbintrayUser=adrianandroid -PbintrayKey=xxxxxxxxx -PdryRun=false
android {
compileSdkVersion project.ext.compileSdkVersion
buildToolsVersion project.ext.buildToolsVersion
defaultConfig {
minSdkVersion project.ext.minSdkVersion
targetSdkVersion project.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
android {
lintOptions {
abortOnError false
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation project.ext.deps.xappcompat
implementation project.ext.deps.picasso
implementation project.ext.deps.gson
implementation project.ext.deps.okhttputils
implementation project.ext.deps.systembartint //顶部的状态栏
implementation project.ext.deps.jsoup //顶部的状态栏
implementation project.ext.deps.rxjava2
implementation project.ext.deps.recyclerview
implementation project.ext.deps.core_ktx
implementation project.ext.deps.kotlin_stdlib_jdk7
}
repositories {
mavenCentral()
}
上传的命令
apply plugin: 'com.novoda.bintray-release'
publish {
//repo = "flanneryzj"
userOrg = 'adrianandroid' //bintray注册的用户名
groupId = 'com.istarshine.common' //compile引用时的第1部分groupId
artifactId = 'commonlite' //compile引用时的第2部分项目名
publishVersion = '0.0.1' //compile引用时的第3部分版本号
desc = '基本库'
website = 'https://github.com/AdrianAndroid/commonlib'
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
//# [新版Bintray-极简上传Library到JCenter](http://blog.csdn.net/wzgiceman/article/details/53707042)
// > chmod a+x gradlew
// > ./gradlew clean build bintrayUpload -PbintrayUser=BINTRAY_USERNAME -PbintrayKey=BINTRAY_KEY -PdryRun=false
//
//./gradlew clean build bintrayUpload -PbintrayUser=adrianandroid -PbintrayKey=xxxxxx -PdryRun=false
成功界面
在这里插入代码片
注意的事项
一定要选择最合适的bintray-release版本
//https://github.com/novoda/bintray-release 找最合适的版本就好上传了
classpath 'com.novoda:bintray-release:0.9.2'
UTF8编码的问题
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
options.addStringOption('encoding', 'UTF-8')
}
javadoc问题
tasks.getByPath(":commonlite:javadocRelease").enabled = false
出现的问题
2: Task failed with an exception.
- What went wrong:
Execution failed for task ‘:bintrayPublish’.
Could not publish ‘adrianandroid/maven/commonlite/0.0.1’: HTTP/1.1 403 Forbidden [message:Files from version ‘0.0.1’ can’t be published. Files can only be published within 365 days f
rom the version publish date.]