【问题标题】:Maven with Url Argument Not Allowed in build.gradle repositoriesbuild.gradle 存储库中不允许使用 Url 参数的 Maven
【发布时间】:2020-12-28 18:08:42
【问题描述】:

我正在尝试通过 Maven 在我的 kotlin 项目中包含一个 jitpack library,但是我在文档中被告知要在我的项目中包含它的语法不起作用。具体来说,当我尝试在我的项目级 gradle 文件中添加 maven() 时:

repositories {
    mavenCentral()
    jcenter()
    maven(url = "https://jitpack.io") {
        name = "jitpack"
    }
}

我在我的 intelliJ IDE 中收到此错误:maven' in 'org.gradle.api.artifacts.dsl.RepositoryHandler' cannot be applied to '(java.lang.String, groovy.lang.Closure<java.lang.String>)。在 maven() 调用中包含 url 作为参数似乎有问题。

我已尝试将语法更改为与gradle docs 中显示的示例相匹配:

repositories {
    mavenCentral()
    jcenter()
    maven {
        url = uri("https://jitpack.io")
        name = "jitpack"
    }
}

但是在我的模块级 gradle 文件中实现依赖后,我仍然无法访问代码中的 lib。

同时使用 mavenCentral() 和 maven() 有冲突吗?似乎问题仅在于使用 url 作为 maven() 的参数的语法。我可以做些什么来解决这个问题并获得对我需要的 jitpack 库的访问权限?

【问题讨论】:

    标签: maven gradle jitpack


    【解决方案1】:

    解决方案是将 maven 调用添加到我的项目级 build.gradle 文件而不是应用级。

    像这样:

    模块级build.gradle

    repositories{
        //added maven repo here instead of the app-level build.gradle file
        maven { url = "https://jitpack.io"}
    }
    ...
    dependencies {
        ...
        implementation "com.github.Dwolla:dwolla-v2-kotlin:0.2.0"
    }
    

    【讨论】:

      猜你喜欢
      • 2016-11-26
      • 2014-01-01
      • 2020-01-15
      • 2015-08-16
      • 1970-01-01
      • 2011-09-30
      • 2013-04-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多