Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android studio - Gradle - GitHub Repo

Does anyone have an idea if it's possible to use a github repo as a dependency, without it being published to maven central.

Let's say I'm developing an android library that has it's own github repo. I'd like to be able to "compile" this library has gradle dependency, in my android studio project, without having to publish to maven central (at least for the moment).

In other words : I want to use a dependency that is not on maven central. It's a straight github repo (an android library that also uses gradle).

I'd like my build.gradle to do something like this :

dependencies {
  // Google Play Services (normal dependency)
  compile "com.google.android.gms:play-services:5.2.08"

  // The library I want to pull from github
  compile "path_to_my_github_repo"
}

Thanks!

like image 838
Mathbl Avatar asked Sep 19 '14 11:09

Mathbl


People also ask

How do I add a repository to Gradle?

We can add a Maven repository to our project by using its url address or its location by adding that particular code snippet in our Gradle build script. To add a Maven repository by using its url, add the following code snippet to the 'build. gradle' file: repositories {

What is Gradle in GitHub?

Gradle has been designed to support build automation across multiple languages and platforms including Java, Scala, Android, Kotlin, C/C++, and Groovy, and is closely integrated with development tools and continuous integration servers including Eclipse, IntelliJ, and Jenkins.


1 Answers

You can do that with Jitpack with Maven, Gradle and sbt.

However, I would strongly suggest to use binary artifact instead so that you are guaranteed that it is the same upon each build of your application, you control the artifact storage and you are using the official release of a project and not some downstream build. It will also make your builds much faster and more stable.

Publishing to the Central Repository is free, easy and well documented at e.g. http://central.sonatype.org/pages/producers.html and specifically for Gradle at http://central.sonatype.org/pages/gradle.html. You can also find lots of real world examples on the Nexus community site.

If you do not control the project you want to consume, I would suggest to send these pointers to the project and maybe even help them with a pull request ;-)

like image 68
Manfred Moser Avatar answered Oct 09 '22 03:10

Manfred Moser