Gradle 构建无法从自定义 Maven 存储库中获取依赖项 [英] Gradle build failing to get dependency from custom maven repository

查看:48
本文介绍了Gradle 构建无法从自定义 Maven 存储库中获取依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照 链接 在 BitBucket 上创建了一个自定义 maven 存储库.尝试使用 Gradle 在我的 android 项目中使用依赖项时,出现以下错误

I have created a custom maven repo on BitBucket following the link. When trying to use the dependencies in my android project using Gradle I am getting following error

Executing tasks: [:app:compileDebugJava]

Configuration on demand is an incubating feature.
Relying on packaging to define the extension of the main artifact has been deprecated and is scheduled to be removed in Gradle 2.0
Checksum missing at https://bitbucket.org/test/maven-repo/raw/master/repository/com/test/com/testCommon/1.0/testCommon-1.0.pom.sha1 due to: For input string: "<!"
Download https://bitbucket.org/test/maven-repo/raw/master/repository/com/test/com/testCommon/1.0/testCommon-1.0.pom

[Fatal Error] testCommon-1.0.pom:2:10: Already seen doctype.

Checksum missing at https://bitbucket.org/test/maven-repo/raw/master/repository/com/android/support/support-v4/20.0.0/support-v4-20.0.0.pom.sha1 due to: For input string: "<!"
Download https://bitbucket.org/test/maven-repo/raw/master/repository/com/android/support/support-v4/20.0.0/support-v4-20.0.0.pom

[Fatal Error] support-v4-20.0.0.pom:2:10: Already seen doctype.

Checksum missing at https://bitbucket.org/test/maven-repo/raw/master/repository/com/android/support/support-annotations/20.0.0/support-annotations-20.0.0.pom.sha1 due to: For input string: "<!"
Download https://bitbucket.org/test/maven-repo/raw/master/repository/com/android/support/support-annotations/20.0.0/support-annotations-20.0.0.pom

[Fatal Error] support-annotations-20.0.0.pom:2:10: Already seen doctype.

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
   > Could not resolve com.test.com:testCommon:1.0.
     Required by:
         SettingsAid:app:unspecified
      > Could not parse POM https://bitbucket.org/test/maven-repo/raw/master/repository/com/test/com/testCommon/1.0/testCommon-1.0.pom
         > Already seen doctype.

我更改了链接.但是打开链接直接返回校验和.

I have changed the link. But opening the link directly returns the checksum.

下面是我的 build.gradle

Below is my build.gradle

apply plugin: 'com.android.application'
apply plugin: 'maven'
android {
    compileSdkVersion 19
    buildToolsVersion "20.0.0"

    defaultConfig {
        applicationId "com.test.sampleapp"
        minSdkVersion 11
        targetSdkVersion 19
    }

    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}
repositories {
    mavenCentral()
    maven {
        credentials {
            username "test@gmail.com"
            password "test"
        }
        url "https://bitbucket.org/test/maven-repo/raw/master/repository/"
    }
}
dependencies {
    compile 'com.android.support:appcompat-v7:20.+'
    compile 'com.test.com:testCommon:1.0'
    compile files('libs/GoogleAdMobAdsSdk-6.4.1.jar')
}

我不确定我在这里做错了什么.我也关注了这个链接.谁能帮我解决这个问题.

I am not sure what I am doing wrong here. I have also followed this link. Can anybody help me in fixing this.

更新 1:

当我检查 ~.gradle 文件夹时,即使在提供凭据后,它也没有登录并保存整个页面.当我将 repo 从 private 更改为 public 时,代码开始工作.但我不想公开我的回购.如何让 gradle 使用传递过来的登录凭据?

When I checked ~.gradle folder, even after giving the credentials it is not logging in and saving the full page. When I changed my repo from private to public the code started working. But I do not want to make my repo public. How to make gradle to use the login credentials passed?

谢谢.

推荐答案

我和我的团队使用 Bitbucket REST API 解决了这个问题,你可以在这个答案中找到更多细节:https://stackoverflow.com/a/30117276/4877779

My team and I solved it using the Bitbucket REST API, you could find more details in this answer: https://stackoverflow.com/a/30117276/4877779

这篇关于Gradle 构建无法从自定义 Maven 存储库中获取依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆