简体   繁体   English

检查是否在gradle中正确添加了依赖项

[英]Check if a dependency is correctly added in gradle

I added this dependency to my build.gradle: 我将此依赖项添加到了build.gradle中:

repositories { mavenCentral() }
dependencies { compile ('org.smali:dexlib2:2.1.1') }

And I'm sure that exists: https://repo1.maven.org/maven2/org/smali/dexlib2/2.1.1/dexlib2-2.1.1.pom 而且我确定存在: https : //repo1.maven.org/maven2/org/smali/dexlib2/2.1.1/dexlib2-2.1.1.pom

I tried with: 我尝试过:

gradle buildDependents
gradle buildNeeded
gradle build

everything complete successfully but the jar wasn't downloaded and I can't import the classes. 一切都成功完成,但jar尚未下载,我无法导入类。

How can I check if I added the right dependency? 如何检查我是否添加了正确的依赖关系?

gradle dependencies gradle依赖

Am I running the right command for download the dependencies? 我是否运行正确的命令来下载依赖项?

there isn't a command for download the dependencies, it's an automated task during build 没有用于下载依赖项的命令,这是构建过程中的自动化任务

---edit--- - -编辑 - -

$ gradle dependencies
:dependencies

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

archives - Configuration for archive artifacts.
No dependencies

compile - Compile classpath for source set 'main'.
\--- org.smali:dexlib2:2.1.1
     +--- com.google.guava:guava:18.0
     +--- org.smali:util:2.1.1
     |    +--- com.google.guava:guava:18.0
     |    +--- commons-cli:commons-cli:1.2
     |    \--- com.google.code.findbugs:jsr305:1.3.9
     \--- com.google.code.findbugs:jsr305:1.3.9

default - Configuration for default artifacts.
\--- org.smali:dexlib2:2.1.1
     +--- com.google.guava:guava:18.0
     +--- org.smali:util:2.1.1
     |    +--- com.google.guava:guava:18.0
     |    +--- commons-cli:commons-cli:1.2
     |    \--- com.google.code.findbugs:jsr305:1.3.9
     \--- com.google.code.findbugs:jsr305:1.3.9

runtime - Runtime classpath for source set 'main'.
\--- org.smali:dexlib2:2.1.1
     +--- com.google.guava:guava:18.0
     +--- org.smali:util:2.1.1
     |    +--- com.google.guava:guava:18.0
     |    +--- commons-cli:commons-cli:1.2
     |    \--- com.google.code.findbugs:jsr305:1.3.9
     \--- com.google.code.findbugs:jsr305:1.3.9

testCompile - Compile classpath for source set 'test'.
+--- org.smali:dexlib2:2.1.1
|    +--- com.google.guava:guava:18.0
|    +--- org.smali:util:2.1.1
|    |    +--- com.google.guava:guava:18.0
|    |    +--- commons-cli:commons-cli:1.2
|    |    \--- com.google.code.findbugs:jsr305:1.3.9
|    \--- com.google.code.findbugs:jsr305:1.3.9
\--- junit:junit:4.11
     \--- org.hamcrest:hamcrest-core:1.3

testRuntime - Runtime classpath for source set 'test'.
+--- org.smali:dexlib2:2.1.1
|    +--- com.google.guava:guava:18.0
|    +--- org.smali:util:2.1.1
|    |    +--- com.google.guava:guava:18.0
|    |    +--- commons-cli:commons-cli:1.2
|    |    \--- com.google.code.findbugs:jsr305:1.3.9
|    \--- com.google.code.findbugs:jsr305:1.3.9
\--- junit:junit:4.11
     \--- org.hamcrest:hamcrest-core:1.3

(*) - dependencies omitted (listed previously)

BUILD SUCCESSFUL

Look like everything is just fine and that the jar's are downloaded into gradle cache. 看起来一切都很好,罐子被下载到了gradle缓存中。

To see where the files are located locally, you can always resolve the configuration and display the file locations. 要查看文件在本地的位置,您始终可以解析配置并显示文件位置。 Eg like this 例如这样

task showJarLocations {
    doLast {
        configurations.compile.resolve().each { file ->
            println file.canonicalPath
        }
    }
}

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

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