Give a warning when a dependency is outdated in Gradle

霸气de小男生 提交于 2019-12-11 02:49:31

问题


Using the Gradle build system, is it possible to give a warning during building when a newer version of a dependency is available?

I got the following dependencies for example:

dependencies {
    compile 'com.nativelibs4java:bridj:0.6.2'
    compile 'net.java.dev.jna:jna:4.1.0'
    compile 'de.vorb:jtesseract:0.0.4'
    compile 'de.vorb:jleptonica:0.0.2'
    testCompile 'junit:junit:4.11'
}

And I expect them to be updated quite often. Some are in a released version, hence it could be safe to pull updates automatically if Gradle supports that, but I rather do not. And the rest is just clearly in an alpha or beta phase and updates could break everything theoretically.

So as concrete example I'd want a warning if junit:junit:4.12 gets released for example.


回答1:


Gradle doesn't ship with this functionality out-of-the-box, but you could look out for a third-party plugin (or write your own). Quick Google search turned up https://github.com/ben-manes/gradle-versions-plugin.




回答2:


Edit 2018: versioneye is deprecated, but Android Studio 3.0 gives deprecation warnings out of the box in the editor - at least as long as your build.gradle follows a simple format, without variables. Otherwise, you can generate a simple fake build.gradle file as I wrote below, and when you open this file, the IDE will do its work.


You can use a service like Versioneye although the support for Gradle is not full, particularly if your build script is split across multiple files, uses variables etc.

With Versioneye, you can either 1) have it scan your repo (connect via GitHub/Bitbucket etc.), or 2) upload build script manually, or 3) install gradle plugin (which will however upload data to their servers).

I wrote a tool to generate a "versioneye-friendly" file to be manually uploaded to the service. You can find it in this answer.



来源:https://stackoverflow.com/questions/23905439/give-a-warning-when-a-dependency-is-outdated-in-gradle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!