在Bitbucket上发布一个android库作为maven工件问题

时间:2017-02-09 08:09:18

标签: android maven gradle bitbucket pom.xml

我正在尝试使用this article

在Bitbucket存储库上将Android库发布为Maven工件

这是我的第一份工作,请解释简单明了 什么是 POM wagon-git deployerJar 以及最终如何解决此错误:< / p>

我得到 ERROR

  

错误:找不到参数的方法deployerJar()[ar.com.synergian:wagon-git:0.2.3]       对象类型为org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler。

我的项目级别 build.gradle

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        maven { url "https://raw.github.com/synergian/wagon-git/releases"}
    }
}

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

我的应用级别(库)build.gradle

apply plugin: 'com.android.library'

android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 2
        versionName "1.1"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.google.firebase:firebase-messaging:9.2.1'
    compile 'com.google.firebase:firebase-crash:9.2.1'
    compile 'com.google.android.gms:play-services:9.2.1'
}

apply from: 'uploadArchives.gradle'

和库madule中创建的uploadArchives.gradle文件:

apply plugin: 'maven'

configurations {
    deployerJar
}

dependencies {
    deployerJar "ar.com.synergian:wagon-git:0.2.3"
}

uploadArchives {
    configuration = configurations.archives
    repositories.mavenDeployer {
        pom.groupId = "com.example"
        pom.artifactId = "myLibraryName"
        pom.version = "1.0"
        configuration = configurations.deployerJar
        repository(url: "git:master://git@bitbucket.org:myTeam/myLibraryName.git"){
            authentication(userName: "my_bitbucket_username", password: "my_bitbucket_password")
        }
        pom.project {
            name "myLibraryName"
            packaging "aar" //POM_PACKAGING
            description "Some Description"
            url "https://bitbucket.org/myTeam/myLibraryName"
            scm {
                url "https://bitbucket.org/myTeam/myLibraryName"
                connection "https://my_bitbucket_username@bitbucket.org/myTeam/myLibraryName.git"
                developerConnection "https://my_bitbucket_username@bitbucket.org/myTeam/myLibraryName.git"
            }
            licenses {
                license {
                    name "The Apache Software License, Version 2.0"
                    url "http://www.apache.org/licenses/LICENSE-2.0.txt"
                    distribution "myLibraryName"
                }
            }
            developers {
                developer {
                    id "my_bitbucket_username"
                    name "my_bitbucket_name"
                    email "my_email"
                }
            }
        }
    }
}

感谢

4 个答案:

答案 0 :(得分:1)

最后我找到了解决方案

除去build.gradle

之外的所有apply from: 'uploadArchives.gradle'杂质

并将uploadArchives {object}的值移至gradle.properties,如下所示:

GROUP=com.example

并使用如下:

uploadArchives {
    configuration = configurations.archives
    repositories.mavenDeployer {
        pom.groupId = GROUP
        ...
    }
}

并在uploadArchies.gradle

的末尾添加此内容
allprojects {
    repositories {
        mavenCentral()
        maven { url "https://raw.github.com/synergian/wagon-git/releases"}
    }
}

答案 1 :(得分:0)

POM缺少项目对象模型,是Maven的基本工作单元。

https://en.wikipedia.org/wiki/Zero-width_non-joiner

wagon-git是具有组ID ar.com.synergian

的工件的名称

据我所知,deployerJar

的名称不在范围内

答案 2 :(得分:0)

我在同一个问题上运行了文章的逐步说明,那就是旅行车库在指令上链接。 为了使工作正常,您只需要替换configurationsdependencies部分的排序。 configurations应该先行。在您的示例中,这也会导致与声明在声明之前声明使用此配置类似的流程。

答案 3 :(得分:0)

我对新的Bitbucket API 2.0有疑问。 我正在使用:

repository(url: 'git:releases://https://' + USERNAME + ':' + PASSWORD + '@bitbucket.org/' + COMPANY + '/' + REPOSITORY_NAME + '.git')

代替

repository(url: "git:master://git@bitbucket.org:myTeam/myLibraryName.git"){
    authentication(userName: "my_bitbucket_username", password: "my_bitbucket_password")
}

效果很好!