上傳到Bintray和上傳到jcenter

資料

說明

上傳到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.]

發佈了164 篇原創文章 · 獲贊 62 · 訪問量 22萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章