Gradle - getting the latest version of a dependency

What would be the easiest way to tell Gradle following:

Restore the junit dependency and grab the latest release.

Managing the Maven and Ivy repositories is somewhat new to me - I followed these steps and they led to a "Could not resolve dependency ..." error :

  • Write compile "junit:junit:latest.release" with repositories installed only on mavenCentral() (however it works if I say "junit: junit: 4.10").

  • Write compile "junit:junit:latest.release" with the repository set as follows:

 ivy { // I also tried 'http://maven.org' and other possible variants. url "http://repo1.maven.org" layout "maven" } 
  • Trying to use Spring Source Ivy repository :
 ivy { artifactPattern "http://repository.springsource.com/ivy/libraries/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" ivyPattern "http://repository.springsource.com/ivy/libraries/release/[organisation]/[module]/[revision]/[artifact]-[revision].[ext]" } 

Perhaps I misunderstand something - why get the latest version of dependencies, such a difficult task, what?

+55
java maven dependencies gradle ivy
Apr 29 '12 at 7:22
source share
5 answers

Gradle does not currently support Maven RELEASE (which is rarely used and deprecated), but it supports Ivy latest.release . However, the general recommendation is to build against exact versions. Otherwise, the assembly may become a lottery.

+27
Apr 29 2018-12-12T00:
source share

It is sometimes useful to get the latest version - if, for example, you often release your own dependencies.

You can get the latest version, for example

 compile "junit:junit:+" 

or it’s better to specify at least the main version, for example

 compile "junit:junit:4.+" 
+185
Apr 29 2018-12-12T00:
source share

Open Gradle -Versions-Plugin. It does exactly what you want: https://github.com/ben-manes/gradle-versions-plugin

See the github page for installation. Basically you need to add these two lines to the build.gradle - project file:

 apply plugin: 'com.github.ben-manes.versions' buildscript { [...] dependencies { classpath 'com.github.ben-manes:gradle-versions-plugin:0.8' [...] } } [...] 

Then you can use the plugin by running this command in the terminal in your dir project:

 ./gradlew dependencyUpdates -Drevision=release 

And he will show you what dependencies are out of date!

+17
Apr 7 '15 at 12:49
source share

The latest Gradle User Guide mentions and explains versions with extra characters:

From 7.2. Declaring your dependencies :

 dependencies { compile group: 'org.hibernate', name: 'hibernate-core', version: '3.6.7.Final' testCompile group: 'junit', name: 'junit', version: '4.+' } 

... The build script also states that any junit> = 4.0 is required to compile project tests.

From 23.7. How dependency resolution works :

If the dependency is declared as a dynamic version (for example, 1. +), Gradle will allow this for the last available static version (for example, 1.2) in the repository. For Maven repositories, this is done using the maven-metadata.xml file, while for Ivy repositories this is done using a directory listing.

+6
Feb 28 '16 at 15:52
source share

If you use + for the version and want to know which version is actually used, select Project in the sidebar, and then under External Libraries you will see the actual version number.

+2
Sep 29 '17 at 22:20
source share



All Articles