简体   繁体   中英

Gradle local dependencies are not visible

In my project I use some local dependencies:

dependencies {
    compile files('lib/mylib.jar')
}

Why when I call gradle dependencies I can't see this library as a dependency? Command gradle dependencies --configuration compile returns this:

:dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

compile - Compile classpath for source set 'main'.
No dependencies

Dependencies downloaded from repository (maven/ivy) are visible. For example:

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.guava:guava:14.0.1'
}

will show:

:dependencies

------------------------------------------------------------
Root project
------------------------------------------------------------

compile - Compile classpath for source set 'main'.
\--- com.google.guava:guava:14.0.1

BUILD SUCCESSFUL

I should also add that dependencies are not shown but project compiles properly.

Gradle documentation on file dependency explains

File dependencies are not included in the published dependency descriptor for your project. However, file dependencies are included in transitive project dependencies within the same build. This means they cannot be used outside the current build, but they can be used with the same build.

使用 api(name: 'mylib', ext: 'jar') 作为解决方法。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM