将 bintray 存储库链接到 Jcenter "Package should include sources as part of the package"

Linking bintray repo to Jcenter "Package should include sources as part of the package"

我有一个 bintray 存储库,我将 android aar 库上传到其中,我正在尝试 link 我的存储库到 Jcenter,以便其他人可以将其导入到他们的项目中。

当我在 bintray 中单击 Add to Jcenter 按钮时,我被带到一个 Compose message 页面,除了单击 Send 按钮外,我在此页面上没有做任何事情。当我点击按钮时,我在 bintray 中收到 n 条错误消息说

Failed to send a message: Package should include sources as part of the package

这是我的build.gradle图书馆

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'maven-publish'

task androidJavadocs(type: Javadoc) {
    failOnError = false
    source = android.sourceSets.main.java.srcDirs
    ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
    classpath += files(ext.androidJar)
    exclude '**/R.html', '**/R.*.html', '**/index.html'
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
    classifier = 'javadoc'
    from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
    classifier = 'sources'
    from android.sourceSets.main.java.srcDirs
}

publishing {
    publications {
        Production(MavenPublication) {

            artifact("$buildDir/outputs/aar/mlcamera-release.aar")
            groupId 'com.tycz'
            artifactId 'mlcamera'
            version '0.1.0'

            artifact androidJavadocsJar
            artifact androidSourcesJar

            //The publication doesn't know about our dependencies, so we have to manually add them to the pom
            pom.withXml {
                //def dependenciesNode = asNode().appendNode('dependencies')
                //Iterate over the compile dependencies (we don't want the test ones), adding a <dependency> node for each
                configurations.compile.allDependencies.each {
                    if (it.name != 'unspecified') {
                        def dependencyNode = dependenciesNode.appendNode('dependency')
                        dependencyNode.appendNode('groupId', it.group)
                        dependencyNode.appendNode('artifactId', it.name)
                        dependencyNode.appendNode('version', it.version)
                    }
                }
            }
        }
    }
}

bintray {
    // Get Bintray credential from environment variable
    user = System.getenv('BINTRAY_USER')
    key = System.getenv('BINTRAY_API_KEY')
    dryRun = false
    override = true
    publish = true
    pkg {
        repo = 'MLCamera'
        name = project.name
        userOrg = 'tyczj359'
        licenses = ['Apache-2.0']
        desc = 'A wrapper library for the new CameraX API and Firebase MLKit to create easier setup for MLKit usage'
        vcsUrl = 'https://github.com/tyczj/MLCamera.git'

        version {
            name = '0.1.0'
            released = new Date()
        }
    }
    publications = ['Production']
}

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.3"


    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 29
        versionCode 1
        versionName "0.1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles 'consumer-rules.pro'
    }

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

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    kotlinOptions {
        jvmTarget = JavaVersion.VERSION_1_8.toString()
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
    implementation 'com.google.firebase:firebase-ml-vision-barcode-model:16.0.2'
    implementation 'com.google.firebase:firebase-ml-vision-object-detection-model:19.0.3'
    implementation 'androidx.core:core-ktx:1.2.0'
    implementation "androidx.camera:camera-core:1.0.0-beta01"
    implementation "androidx.camera:camera-camera2:1.0.0-beta01"
    implementation "androidx.camera:camera-view:1.0.0-alpha08"
    implementation "androidx.camera:camera-lifecycle:1.0.0-beta01"
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

}

谁能告诉我问题出在哪里?

Bintray 有一些先决条件 link 到 Jcenter。
有些是你需要一个 public maven 存储库,sources file/s,一个 pom 文件,等等'(更多可以找到在 JFrog 的 wiki)。如果您想 Link to Jcenter.

,则需要上传这些文件

在您的 build.gradle 中,您明确上传了 .aar 并且还上传了 androidSourcesJar

从查看 build.gradle 文件看,您正在添加 sources,如果有的话,您应该会看到 error message收集文件的问题。

我的建议是更改 from:

的顺序
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
    from androidJavadocs.destinationDir
    classifier = 'javadoc'
}

task androidSourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

publishing {
    publications {
        Production(MavenPublication) {
            artifact androidJavadocsJar
            artifact androidSourcesJar
            groupId 'com.tycz'
            artifactId 'mlcamera'
            version '0.1.0'
            .
            .
            .

您可以通过示例关注 gradle-bintray-plugin README

See the section on the workaround for Android pom file dependencies.

您还可以使用这些指南: