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!
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 {
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.
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 ;-)
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