簡體   English   中英

將android模塊上傳到bintray並鏈接到jcenter

[英]Uploading android module to bintray and linking to jcenter

嗨,所以我正在關注Gradle Bintray插件的github網站https://github.com/bintray/gradle-bintray-plugin#readme教程,但是我不太了解出版物部分。 誰能幫我這個? 我目前正在研究Bintray版本1.7.3。

更新:我能夠在Bintray中成功上傳。 但是我現在的問題是在其他項目中下載它時。 同步gradle時出現錯誤:
-找不到android-dbpatcher.jar(sirqo:android-dbpatcher:0.0.1)。
-錯誤:在以下位置搜索:
http://sirqo.bintray.com/Android-DBPatcher/sirqo/android-dbpatcher/0.0.1/android-dbpatcher-0.0.1.jar

Update2:僅供參考,這是我在模塊中的gradle.build

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner     "android.support.test.runner.AndroidJUnitRunner"

    }
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-  core:2.2.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})
    compile 'com.android.support:appcompat-v7:25.0.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.volley:volley:1.0.0'
}

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
}

group = 'xxxx'
version = '0.0.1'

install {
    repositories.mavenInstaller {
        pom.project {
            name 'android-dbpatcher'
            description 'A library for updating SQLite database in android.'
            url 'https://sirqo.bintray.com/Android-DBPatcher'
            inceptionYear '2016'

            packaging 'aar'
            groupId 'xxxx'
            artifactId 'android-dbpatcher'
            version '0.0.1'

            licenses {
                license {
                    name "The Apache Software License, Version 2.0"
                    url "http://www.apache.org/licenses/LICENSE-2.0.txt"
                    distribution "repo"
                }
            }

            developers {
                developer {
                    id  'xxxx'
                    name 'xxxxx'
                    email 'xxxxxx@gmail.com'
                }
            }
        }
    }
}

Properties bintrayProperties = new Properties()
    bintrayProperties.load(project.rootProject.file('bintray.properties').newDa    taInputStream())

bintray {
    user = bintrayProperties.getProperty('user')
    key = bintrayProperties.get('key')
    configurations = ['archives']
    pkg {
        repo = 'Android-DBPatcher'
        name = 'android-dbpatcher'
        userOrg = 'xxxx'
        vcsUrl = 'https://github.com/sirqo/android-dbpatcher'
        publish = true
        version {
            name = '0.0.1'
            desc = 'Android SQLite Database Patcher'
            released = new Date()
            vcsTag = 'v0.0.1'
        }
    }
}

所以我想通了。 作為參考,我將分享我的代碼。

對於我的項目gradle.build

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

plugins {
    id "com.jfrog.bintray" version "1.7.3"
}

allprojects {
    repositories {
        jcenter()
    }

}

task clean(type: Delete) {
    delete rootProject.buildDir
}

對於我的模塊gradle.build

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
apply plugin: 'com.jfrog.bintray'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
        compile fileTree(dir: 'libs', include: ['*.jar'])
        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:25.0.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.volley:volley:1.0.0'
}

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
}

group = 'xxxx' //bintray org/group name
version = '0.0.1' //version

install {
    repositories.mavenInstaller {
        pom.project {
            name 'xxxxx' //package name
            description 'A library for updating SQLite database in android.'
            url 'xxxxx'
            inceptionYear '2016'

            packaging 'aar'
            groupId 'xxxx' //group/org id
            artifactId 'xxxx' //your android module name
            version '0.0.1'

            licenses {
                license {
                    name "The Apache Software License, Version 2.0"
                    url "http://www.apache.org/licenses/LICENSE-2.0.txt"
                    distribution "repo"
                }
            }

            developers {
                developer {
                    id  'xxxxx' //developer username
                    name 'xxxxxx' //developer name
                    email 'xxxxxx@gmail.com' //developer email
                }
            }
            scm {
                connection 'xxxxxx' // YOUR GIT REPO
                developerConnection 'xxxxxx' // YOUR GIT REPO
                url 'xxxxxxx' // YOUR SITE

            }
        }
    }
}

Properties bintrayProperties = new Properties()
bintrayProperties.load(project.rootProject.file('bintray.properties').newDataInputStream())

bintray {
    user = bintrayProperties.getProperty('user')
    key = bintrayProperties.get('key')
    configurations = ['archives']
    pkg {
        repo = 'xxxxxx' //Bintray repository
        name = 'xxxxxx' //Bintray Package name
        userOrg = 'xxxxx'
        licenses = ['Apache-2.0']
        vcsUrl = 'xxxxxxxx'
        publish = true
        version {
            name = '0.0.1' //version
            desc = 'xxxxxx' //Description
            released = new Date()
            vcsTag = 'v0.0.1'
        }
    }
}

之后,在您的android studio中打開下面的android終端,然后輸入以下命令

./gradlew安裝

  • 如果存在一些錯誤,可以在命令后附加--debug並重新輸入命令以跟蹤錯誤

//如果沒有其他失敗,請發出此命令。/gradlewbintrayUpload *再次出現錯誤時,可以使用命令並附加--debug來跟蹤它。

畢竟,您將收到電子郵件或其他內容,然后可以繼續在其他項目中下載您的庫。 編碼愉快!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM