gradle-versions-plugin


Source link: https://github.com/ben-manes/gradle-versions-plugin

Gradle Versions Plugin

In the spirit of the Maven Versions Plugin, this plugin provides a task to determine which dependencies have updates.

Usage

This plugin is available from Bintray's JCenter repository. You can add it to your top-level build script using the following configuration:

plugins block:

plugins {

id 'com.github.ben-manes.versions' version '0.17.0' 
}

or via the

buildscript block:

apply plugin: 'com.github.ben-manes.versions'  buildscript {

repositories {

  jcenter()

}

 dependencies {

  classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'

}
 
}

The current version is known to work with Gradle versions up to 4.3.

Tasks

dependencyUpdates

Displays a report of the project dependencies that are up-to-date, exceed the latest version found, have upgrades, or failed to be resolved. When a dependency cannot be resolved the exception is logged at the info level.

Revisions

The revision task property controls the resolution strategy of determining what constitutes the latest version of a dependency. The following strategies are supported:

  • release: selects the latest release
  • milestone: select the latest version being either a milestone or a release (default)
  • integration: selects the latest revision of the dependency module (such as SNAPSHOT)

The strategy can be specified either on the task or as a system property for ad hoc usage:

gradle dependencyUpdates -Drevision=release

The latest versions can be further filtered using Component Selection Rules. For example to disallow release candidates as upgradable versions a selection rule could be defined as:

dependencyUpdates.resolutionStrategy = {

componentSelection {
 rules ->
  rules.all {
 ComponentSelection selection ->

 boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any {
 qualifier ->

selection.candidate.version ==~ /(?i).*[.-]${
qualifier
}
[.\d-]*/

 
}

 if (rejected) {

selection.reject('Release candidate')

 
}

  
}

}
 
}

Report format

The task property outputFormatter controls the report output format. The following values are supported:

  • "plain": format output file as plain text (default)
  • "json": format output file as json text
  • "xml": format output file as xml text, can be used by other plugins (e.g. sonar)
  • a Closure: will be called with the result of the dependency update analysis (see example below)

You can also set multiple output formats using comma as the separator:

gradle dependencyUpdates -Drevision=release -DoutputFormatter=json,xml

Last, the task property outputDir controls the output directory for the report file(s). The directory will be created if it does not exist. The default value is set to build/dependencyUpdates

gradle dependencyUpdates -Drevision=release -DoutputFormatter=json -DoutputDir=/any/path/with/permission

This displays a report to the console, e.g.

------------------------------------------------------------ : Project Dependency Updates (report to plain text file) ------------------------------------------------------------  The following dependencies are using the latest integration version:  - backport-util-concurrent:backport-util-concurrent:3.1  - backport-util-concurrent:backport-util-concurrent-java12:3.1  The following dependencies exceed the version found at the integration revision level:  - com.google.guava:guava [99.0-SNAPSHOT <- 16.0-rc1]  - com.google.guava:guava-tests [99.0-SNAPSHOT <- 16.0-rc1]  The following dependencies have later integration versions:  - com.google.inject:guice [2.0 -> 3.0]  - com.google.inject.extensions:guice-multibindings [2.0 -> 3.0] 

Json report

{

  "current": {

"dependencies": [

 {

  "group": "backport-util-concurrent",

  "version": "3.1",

  "name": "backport-util-concurrent"

 
}
,

 {

  "group": "backport-util-concurrent",

  "version": "3.1",

  "name": "backport-util-concurrent-java12"

 
}

],

"count": 2
  
}
,
  "exceeded": {

"dependencies": [

 {

  "group": "com.google.guava",

  "latest": "16.0-rc1",

  "version": "99.0-SNAPSHOT",

  "name": "guava"

 
}
,

 {

  "group": "com.google.guava",

  "latest": "16.0-rc1",

  "version": "99.0-SNAPSHOT",

  "name": "guava-tests"

 
}

],

"count": 2
  
}
,
  "outdated": {

"dependencies": [

 {

  "group": "com.google.inject",

  "available": {

"release": "3.0",

"milestone": null,

"integration": null

  
}
,

  "version": "2.0",

  "name": "guice"

 
}
,

 {

  "group": "com.google.inject.extensions",

  "available": {

"release": "3.0",

"milestone": null,

"integration": null

  
}
,

  "version": "2.0",

  "name": "guice-multibindings"

 
}

],

"count": 2
  
}
,
  "unresolved": {

"dependencies": [

 {

  "group": "com.github.ben-manes",

  "version": "1.0",

  "reason": "Could not find any version that matches com.github.ben-manes:unresolvable:latest.milestone.",

  "name": "unresolvable"

 
}
,

 {

  "group": "com.github.ben-manes",

  "version": "1.0",

  "reason": "Could not find any version that matches com.github.ben-manes:unresolvable2:latest.milestone.",

  "name": "unresolvable2"

 
}

],

"count": 2
  
}
,
  "count": 8 
}

XML report

<response>
<count>8</count>
<current>
  <count>2</count>
  <dependencies>

 <dependency>

<name>backport-util-concurrent</name>

<group>backport-util-concurrent</group>

<version>3.1</version>

 </dependency>

 <dependency>

<name>backport-util-concurrent-java12</name>

<group>backport-util-concurrent</group>

<version>3.1</version>

 </dependency>
  </dependencies>
</current>
<outdated>
  <count>2</count>
  <dependencies>

 <outdatedDependency>

<name>guice</name>

<group>com.google.inject</group>

<version>2.0</version>

<available>

  <release>3.0</release>

</available>

 </outdatedDependency>

 <outdatedDependency>

<name>guice-multibindings</name>

<group>com.google.inject.extensions</group>

<version>2.0</version>

<available>

  <release>3.0</release>

</available>

 </outdatedDependency>
  </dependencies>
</outdated>
<exceeded>
  <count>2</count>
  <dependencies>

 <exceededDependency>

<name>guava</name>

<group>com.google.guava</group>

<version>99.0-SNAPSHOT</version>

<latest>16.0-rc1</latest>

 </exceededDependency>

 <exceededDependency>

<name>guava-tests</name>

<group>com.google.guava</group>

<version>99.0-SNAPSHOT</version>

<latest>16.0-rc1</latest>

 </exceededDependency>
  </dependencies>
</exceeded>
<unresolved>
  <count>2</count>
  <dependencies>

 <unresolvedDependency>

<name>unresolvable</name>

<group>com.github.ben-manes</group>

<version>1.0</version>

<reason>Could not find any version that matches com.github.ben-manes:unresolvable:latest.release.</reason>

 </unresolvedDependency>

 <unresolvedDependency>

<name>unresolvable2</name>

<group>com.github.ben-manes</group>

<version>1.0</version>

<reason>Could not find any version that matches com.github.ben-manes:unresolvable2:latest.release.</reason>

 </unresolvedDependency>
  </dependencies>
</unresolved> </response>

Custom report format

If you need to create a report in a custom format, you can set the dependencyUpdates tasks's outputFormatter property to a Closure. The closure will be called with a single argument that is an instance of com.github.benmanes.gradle.versions.reporter.result.Result.

For example, if you wanted to create an html table for the upgradable dependencies, you could use:

... dependencyUpdates {

outputFormatter = {
 result ->
  def updatable = result.outdated.dependencies
  if (!updatable.isEmpty()){

 def writer = new StringWriter()

 def html = new groovy.xml.MarkupBuilder(writer)

  html.html {

body {

  table {

 thead {

tr {

  td("Group")

  td("Module")

  td("Current version")

  td("Latest version")

}

 
}

 tbody {

updatable.each {
 dependency->

  tr {

 td(dependency.group)

 td(dependency.name)

 td(dependency.version)

 td(dependency.available.release ?: dependency.available.milestone)

  
}

}

 
}

  
}

}

 
}

 println writer.toString()
  
}

}
 
}
 

Resources

A tiny, thread safe memory cache implementation which uses a LRU policy.

An uncaught exception handler library.

Android library to place labels next to another. If there is not enough space for the next label, it will be added in a new line.

Handler-based Eventbus for Android.

Android DI, DDD, Specification Pattern, Repository Pattern, IoC.

This project aims to provide a working dual toggle button implementation.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes