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?
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.
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.
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.
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.
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.+"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With