我正在按照本教程 https://antoniocappiello.com/2015/11/11/publish-your-library-to-jcenter-in-3-steps/ 发布我的第一个库,并且我设法解决了除最后一步之外的每一步遇到的问题。

在执行 ./gradlew install 之后,然后当我运行 ./gradlew bintrayUpload

它成功构建但不上传我的文件。我有一个选项,我可以开始在 bintray 中手动上传文件,但这就是 ./gradlew bintrayUpload 的用途。

所以也许,我的 gradle 设置是错误的。

这是我的顶级 build.gradle

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

    buildscript {
        repositories {
            jcenter()
            maven {
                url  "http://dl.bintray.com/myUsername/myLibraryName"
            }
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:1.3.0'
            classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.2'
            classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'

            // NOTE: Do not place your application dependencies here; they belong
            // in the individual module build.gradle files
        }
    }

    allprojects {
        repositories {
            jcenter()
        }
    }

我的模块 build.gradle
apply plugin: 'com.android.library'


android {
    compileSdkVersion 23
    buildToolsVersion "23.0.0"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    repositories {
        mavenCentral()
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

apply from: 'install.gradle'
apply from: 'bintray.gradle'

我的 Install.gradle 文件
apply plugin: 'com.github.dcendents.android-maven'

group = 'com.libraryname.v1' // CREATE A GROUP ID FOR YOUR LIBRARY

install {
    repositories.mavenInstaller {
        pom {
            project {
                packaging 'aar'
                groupId 'com.libraryname.v1' // CREATE A GROUP ID FOR YOUR LIBRARY
                artifactId 'ArtifactId' // THE NAME OF YOUR MODULE

                name 'myLibraryName' // YOUR LIBRARY NAME
                description 'my library description.' // YOUR LIBRARY DESCRIPTION
                url 'https://github.com/username/myLibraryName' // YOUR SITE

                licenses {
                    license {
                        name 'The Apache Software License, Version 2.0'
                        url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
                    }
                }
                developers {
                    developer {
                        id 'MyID' //YOUR ID
                        name 'MyName' //YOUR NAME
                        email '[email protected]' //YOUR EMAIL
                    }
                }
                scm {
                    connection 'https://github.com/username/myLibraryName.git' // YOUR GIT REPO
                    developerConnection 'https://github.com/username/myLibraryName.git' // YOUR GIT REPO
                    url 'https://github.com/username/myLibraryName' // YOUR SITE

                }
            }
        }
    }
}

我的 bintray.gradle
apply plugin: 'com.jfrog.bintray'

version = '0.0.1' //YOUR LIBRARY VERSION

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
}

// Bintray


bintray {

    Properties properties = new Properties()
    properties.load( new FileInputStream("local.properties"))

    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")
    pkg {
        repo = 'libraryName'
        name = 'com.libraryName.v1' //YOUR PACKAGE NAME
        desc = 'my library description.' // YOUR LIBRARY DESCRIPTION
        websiteUrl = 'https://github.com/username/libraryName' // YOUR SITE
        vcsUrl = 'https://github.com/username/libraryName.git' // YOUR GIT REPO
        licenses = ["Apache-2.0"] // A LIST OF YOUR LICENCES
        publish = true
        publicDownloadNumbers = true
    }
}

最佳答案

bintray 闭包缺少一行 configurations = ['archives']

关于android - gradlew bintrayUpload 命令不会将文件上传到 bintray,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39616595/

10-12 01:46