【问题标题】:How can I make a transitive dependency in gradle also use the dependency's original source?如何在 gradle 中创建传递依赖项也使用依赖项的原始源?
【发布时间】:2015-04-27 17:44:56
【问题描述】:

我有一个库,我称之为core,它是另一个项目的依赖项,称为Museum。在core的build.gradle中,我使用的是gson-fire,它以如下方式指定为依赖:

repositories {
    maven { url 'https://raw.github.com/julman99/mvn-repo/master'}
}

...

dependencies {
 compile 'com.github.julman99:gson-fire:0.11.0'
}

这工作正常 - core 已编译。但是,当我在 Museum 项目中使用它时,我得到以下信息:

A problem occurred configuring project ':Museum'.
> Could not resolve all dependencies for configuration ':Museum:_debugCompile'.
   > Could not find com.github.julman99:gson-fire:0.11.0.
     Searched in the following locations:
         file:/Users/jwir3/.m2/repository/com/github/julman99/gson-fire/0.11.0/gson-fire-0.11.0.pom
         file:/Users/jwir3/.m2/repository/com/github/julman99/gson-fire/0.11.0/gson-fire-0.11.0.jar
         http://download.crashlytics.com/maven/com/github/julman99/gson-fire/0.11.0/gson-fire-0.11.0.pom
         http://download.crashlytics.com/maven/com/github/julman99/gson-fire/0.11.0/gson-fire-0.11.0.jar
         https://repo1.maven.org/maven2/com/github/julman99/gson-fire/0.11.0/gson-fire-0.11.0.pom
         https://repo1.maven.org/maven2/com/github/julman99/gson-fire/0.11.0/gson-fire-0.11.0.jar
     Required by:
         museum:Museum:unspecified > com.jwir3.core:core:1.4.0-SNAPSHOT

Museumbuild.gradle 如下所示:

dependencies {
    compile ('com.thisclicks.core:core:' + project.CORE_LIB_VERSION+ '+@aar') {
        transitive = true
    }
}

推测这是因为core库在build.gradleMuseum中被指定为transient = true,但是它没有正确的位置来搜索gson-fire的Maven仓库。有没有办法让这些搜索位置以及依赖项本身都是瞬态的?

【问题讨论】:

标签: maven gradle dependency-management


【解决方案1】:

不是自动的,不。传递依赖不会引入存储库信息,只会引入工件本身。如果你想让它工作,你必须将repositories { } 块从core 项目添加到Museum 项目。

此外,在这种情况下不需要添加transitive = true。无论如何,这是默认设置,如上所述,与此特定问题无关。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-10
    • 2023-03-17
    • 2012-12-05
    • 2013-01-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多