简体   繁体   English

如何确定在生成过程中使用了哪个确切的依赖版本

[英]How to determine during the build which exactly version of dependency is used

I want to display exact versions of my app's dependencies in the "About" screen. 我想在“关于”屏幕中显示应用程序依赖项的确切版本。 In build.config I'm using wildcards like compile 'com.google.guava:guava:16.0.+' for dependencies, but the exact version used will be, say, 16.0.1 . build.config我使用通配符,例如build.config compile 'com.google.guava:guava:16.0.+'作为依赖项,但是使用的确切版本为16.0.1 Is there a way to get all the dependencies listed with their actual versions and, for example, put them into BuildConfig file so that I can read them in app's runtime? 有没有一种方法可以获取所有列出的依赖项及其实际版本,例如,将它们放入BuildConfig文件中,以便我可以在应用程序的运行时中读取它们?

It sounds like you are looking for the dependencyReport task from the project reports plugin 听起来您好像正在从项目报告插件中寻找dependencyReport任务

Otherwise you could do something like this: 否则,您可以执行以下操作:

task buildConfig << {
   new File("$buildDir/BuildConfig").withWriter { out ->
        configurations.runtime.resolvedConfiguration.resolvedArtifacts.each { dep -> 
            out.writeLine(dep.moduleVersion.id.toString()) 
      }
   }
}

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

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