pepuch
pepuch

Reputation: 6516

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.

Upvotes: 8

Views: 2620

Answers (2)

Peter
Peter

Reputation: 167

Use api(name: 'mylib', ext: 'jar') as a workaround.

Upvotes: -1

Grzegorz Żur
Grzegorz Żur

Reputation: 49161

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.

Upvotes: 5

Related Questions