无法使用gradle-bintray-plugin上传aar:仅上传jar文件

问题描述 投票:1回答:1

使用来自here的建议我无法将我的Android aar上传到我的Bintray帐户。我使用gradlew bintrayUpload获得了“Build successfull”,但只有jar文件和pom文件在bintray中可见。这是我的顶级gradle文件

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.3'
    }
}
plugins {
    id "com.jfrog.bintray" version "1.7.3"
}
allprojects {
    repositories {
        jcenter()
    }
}
apply plugin: 'maven-publish'
apply plugin: 'java'
apply plugin: 'maven'

publishing {
    publications {
        MyPublication(MavenPublication) {
            from components.java
            groupId 'com.android.me.mylibrary'
            artifactId 'demo-lib'
            version '1.0.1'     
        }
    }
}

这是我的gradle文件

apply plugin: 'com.android.library'
bintray {
    user = user
    key = key
    publications = ['MyPublication'] //When uploading Maven-based publication files
    //configurations = ['archives']
    pkg {
        repo = repo
        name = 'demo-lib'
        userOrg = userorg
        labels = ['aar', 'android', 'example']
        version {
            name = '1.0.1'
        }
    }
}
android {
    compileSdkVersion 26
    buildToolsVersion "27.0.2"
    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 26
        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:26.+'
    testCompile 'junit:junit:4.12'
}

有什么遗失的吗?我也尝试使用示例脚本here,但结果是一样的。最好的祝福...

android gradle android-library bintray
1个回答
0
投票

是的,实际上有些东西丢失了。您不上传工件。您上传artifactId但不上传工件。

因为有很多过时的教程,我实际上在here上发了一篇关于此的帖子。您还需要做的是遵循pom.xml的maven规范,我发现您没有。

在版本4中,它们也需要:

        pom.withXml {
            def root = asNode()
            root.appendNode('description', "libraryDescription")
            root.appendNode('name', "libraryName")
            root.appendNode('url', "siteUrl")
            root.children().last() + pomConfig
        }

也可以在pomConfig中使用它:

def pomConfig = {
    licenses {
        license {
            name "licenseName"
            url "licenseUrl"
            distribution "repo"
        }
    }
    developers {
        developer {
            id "developerId"
            name "developerName"
            email "developerEmail"
        }
    }
    scm {
        url "gitUrl"
    }
}

希望能帮助到你!!!

© www.soinside.com 2019 - 2024. All rights reserved.