简体   繁体   English

Gradle 本地依赖项不可见

[英]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?为什么当我调用gradle dependencies我看不到这个库作为依赖项? Command gradle dependencies --configuration compile returns this:命令gradle dependencies --configuration compile返回这个:

:dependencies

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

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

Dependencies downloaded from repository (maven/ivy) are visible.从存储库 (maven/ivy) 下载的依赖项是可见的。 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关于文件依赖的Gradle 文档解释了

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') 作为解决方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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