Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I specify the latest commit version in Gradle

I'm using Gradle in my Android project,and I have added some dependencies in build.gradle file.For some reasons,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'm specifying CircularReveal's version to be 1.1.0@aar,and I know currently it has fixed some bugs but have 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 it be done in Gradle? Any help would be greatly appreciated.

like image 842
tounaobun Avatar asked Jun 01 '15 02:06

tounaobun


2 Answers

You can not do this directly from Gradle, but there are Gradle plugins and tools you can use to achieve this.

You can do this using Jitpack, an external tool. All you need to do is specify Jitpack as a repository:

repositories {
    maven {
        url "https://jitpack.io"
    }
    // Define your other dependency repositories, if any
}

Then include your dependency:

dependencies {
    compile 'com.github.ozodrukh:CircularReveal:25aeca505d'
    // Include your other dependencies, if any
}

You can also use use the gradle-git-repo-plugin from Layer, but I haven't tried this one yet. An advantage(?) of this plugin is that it clones the repository on your local machine and adds it as a dependency from there.

like image 153
ugo Avatar answered Sep 16 '22 15:09

ugo


Ugo response is probably the correct one, here's an alternative for some specific cases:

dependencies {
    ...
    compile 'com.github.ozodrukh:CircularReveal:1.1.+@aar' 
    // or 1.+ or even just +
}

That puts you on the latest version, no matter which one it is. Now, if you repository builds on a CI environment and deploys snapshots to Sonatype or a similar service, you can do

repositories {
    maven {
        url "https://project.sonatype.io"
    }
}

And along with the other change you'll end up in the -SNAPSHOT versions. This behaviour reports warnings on build because your builds will not be reproducible, but that's a given if you're targeting CI versions.

like image 38
MLProgrammer-CiM Avatar answered Sep 18 '22 15:09

MLProgrammer-CiM