如何准确而使用依赖版本的编译过程中确定 [英] How to determine during the build which exactly version of dependency is used

查看:166
本文介绍了如何准确而使用依赖版本的编译过程中确定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在关于屏幕来显示我的应用程序的依赖关系的确切版本。在 build.config 我使用通配符,比如编译com.google.guava:番石榴:16.0 +的依赖,但所用的确切版本,比方说, 16.0.1 。有没有办法让他们实际的版本上市,例如所有的依赖,把它们放到 BuildConfig 文件,这样我可以在应用程序的运行时间阅读?

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. 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?

推荐答案

这听起来像你正在寻找从的 dependencyReport 任务=HTTP:/ /www.gradle.org/docs/current/userguide/project_reports_plugin.html相对=nofollow>项目报告插件

It sounds like you are looking for the dependencyReport task from the project reports plugin

否则你可以做这样的事情:

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()) 
      }
   }
}

这篇关于如何准确而使用依赖版本的编译过程中确定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆