Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle - getting the latest release version of a dependency

What would be the easiest way to tell Gradle the following:

Retrieve 'junit' dependency and take its latest 'release' version.

Managing Maven and Ivy repositories is sort of new to me. I tried the following steps and they result in Could not resolve dependency ... error:

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

  • Write compile "junit:junit:latest.release" with repository set the following way:

    ivy {     // I also tried 'http://maven.org' and other possible variants.                url "http://repo1.maven.org"      layout "maven" } 
  • Attempted 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]" } 

Maybe I misunderstand something. Why would getting the latest version of the dependency be such a hard task?

like image 257
Yippie-Ki-Yay Avatar asked Apr 29 '12 07:04

Yippie-Ki-Yay


People also ask

How do I get the latest version of dependency in Gradle?

You can use the version string “latest. integration” to achieve this. This is a dynamic version that tells Gradle to use the very latest version of a dependency.

How do I know if Gradle dependency has new version?

Go to Android Studio -> Preferences -> Plugins (for Mac) and File -> Settings -> Plugins (for windows) and search “Check for Dependency updates plugin”. Install it and restart android studio. You will be able to see Dependencies tab on the right which will show if any dependency has a new update available.

How do I override the dependency version of Child Gradle?

To override the version of a transitive dependency in Gradle, exclude it from the declared dependency that pulls it in, and then explicitly declare the version that you prefer to use in your build. gradle.

How do I mention Gradle version in build Gradle?

First install Gradle on your machine, then open up your project directory via the command line. Run gradle wrapper and you are done! You can add the --gradle-version X.Y argument to specify which version of Gradle to use.


2 Answers

It can be quite useful sometimes to get the latest release - if for example you release often your own dependencies.

You can get the latest version like

compile "junit:junit:+" 

or better specify at least the major version like

compile "junit:junit:4.+" 
like image 121
jmruc Avatar answered Sep 22 '22 12:09

jmruc


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

like image 39
Peter Niederwieser Avatar answered Sep 25 '22 12:09

Peter Niederwieser