如何在gradle中创建传递依赖还使用依赖关系的原始源?

时间:2015-02-25 16:13:24

标签: maven gradle dependency-management

我有一个库,我称之为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

build.gradle的{​​{1}}如下所示:

Museum

据推测,这是因为dependencies { compile ('com.thisclicks.core:core:' + project.CORE_LIB_VERSION+ '+@aar') { transitive = true } } 库在core的{​​{1}}中被指定为transient = true,但它没有正确的搜索位置对于build.gradle的Maven存储库。有没有办法让这些搜索位置成为瞬态以及依赖本身?

1 个答案:

答案 0 :(得分:2)

不是自动,不是。传递依赖性不会引入存储库信息,只会引入工件本身。如果您希望此功能正常工作,则必须将repositories { }项目中的core块添加到Museum项目中。

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