如何将自定义 Maven 存储库添加到 gradle

编程入门 行业动态 更新时间:2024-10-20 16:19:35
本文介绍了如何将自定义 Maven 存储库添加到 gradle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我的 maven 存储库和我的 aar 文件位于那里 https://cloudbuild.myompany/nexus/content/repositories/test_kirill/com/myompany/myompany-core/2.0.0/

I have my maven repository with my aar file that is located there https://cloudbuild.myompany/nexus/content/repositories/test_kirill/com/myompany/myompany-core/2.0.0/

顺便说一下,它是私人存储库,所以当我登录时,我应该使用凭据.

By the way it is private repository so when I'm logging in I should use credentials.

当我尝试将其添加到我的依赖项时,gradle 给我错误 Failed to resolve.

When I'm trying to add this to my dependencies gradle gives me error Failed to resolve.

apply plugin: 'com.android.application'

repositories {
    mavenCentral()


    maven {
        credentials {
            username 'admin'
            password '*******'
        }
        url 'https://cloudbuild.myompany/nexus/content/repositories/test_kirill/'
    }
}

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

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

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile 'com.android.support:design:23.2.1'
    compile group: 'com.myompany', name: 'myompany-core', version: '2.0.0'
}

还有来自 2.2.0 文件夹的我的 POM 文件

Also there is my POM file from 2.2.0 folder

<project xmlns="http://maven.apache/POM/4.0.0" xmlns:xsi="http://www.w3/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache/POM/4.0.0 http://maven.apache/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.myompany</groupId>
<artifactId>myompany-core</artifactId>
<version>2.0.0</version>
<packaging>gradle</packaging>
<description>POM was created by Sonatype Nexus</description>
</project>

推荐答案

你可能想试试这个:

repositories {
    mavenCentral()

    maven {
        credentials {
            username 'admin'
            password '*******'
        }
        url 'https://cloudbuild.livegenic/nexus/content/repositories/test_kirill/'
        authentication {
            basic(BasicAuthentication)
        }
    }
}

有关更多详细信息,请参阅此讨论:https://discuss.gradle/t/maven-username-password-only-works-when-embedded-in-url-for-some-servers/2542/13

See this discussion for more detail: https://discuss.gradle/t/maven-username-password-only-works-when-embedded-in-url-for-some-servers/2542/13

这篇关于如何将自定义 Maven 存储库添加到 gradle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-04-23 03:03:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1034414.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   如何将   gradle   Maven

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!