How to specify the latest commit version in Gradle
I am using Gradle
in my Android project and I added some dependencies to the file build.gradle
. For some reason, I want to point to the latest commit for one of my dependencies. For example:
dependencies {
...
compile 'com.github.ozodrukh:CircularReveal:1.1.0@aar'
}
I am specifying the version CircularReveal
for version 1.1.0 @aar and I know she has currently fixed some bugs but has not released it yet. How can I specify a commit in Gradle? I know some basics about Cocoapods
and it can be done like this:
pod 'AFNetworking', :git => 'https://github.com/gowalla/AFNetworking.git', :commit => '082f8319af'
Can this be done in Gradle? Any help would be greatly appreciated.
source to share
You cannot do this directly from Gradle, but there are Gradle plugins and tools that you can use to achieve this.
You can do this using Jitpack , an external tool. All you have to do is specify Jitpack as the repository:
repositories {
maven {
url "https://jitpack.io"
}
// Define your other dependency repositories, if any
}
Then list your dependency:
dependencies {
compile 'com.github.gowalla:AFNetworking:082f8319af'
// Include your other dependencies, if any
}
You can also use the gradle-git-repo-plugin from Layer, but I haven't tried that yet. The advantage (?) Of this plugin is that it clones the repository on your local machine and adds it as a dependency from there.
source to share
Ugo's answer is probably correct, here's an alternative for some specific cases:
dependencies {
...
compile 'com.github.ozodrukh:CircularReveal:1.1.+@aar'
// or 1.+ or even just +
}
This puts you in the latest version, no matter what it is. Now if the repository is built in a CI environment and deploys snapshots for Sonatype or similar service, you can do
repositories {
maven {
url "https://project.sonatype.io"
}
}
And along with other changes, you will end up in the -SNAPSHOT versions. This behavior reports build warnings because your builds will not be reproducible, but it is specified if you are targeting CI versions.
source to share