Skip to content

Instantly share code, notes, and snippets.

@jitpack-io
Created December 7, 2015 13:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jitpack-io/380e88da1a5b3efe695b to your computer and use it in GitHub Desktop.
Save jitpack-io/380e88da1a5b3efe695b to your computer and use it in GitHub Desktop.
JitPack repository in Gradle
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.RepositoryHandler
apply plugin:JitPackRepositoryPlugin
class JitPackRepositoryPlugin implements Plugin<Gradle> {
void apply(Gradle gradle) {
gradle.allprojects { project ->
project.repositories.metaClass.jitpack = { String org = null, String subPattern = null, def closure = null ->
delegate.maven {
url "https://jitpack.io"
}
}
}
}
}
@jitpack-io
Copy link
Author

Copy this script to $HOME/.gradle/init.gradle

Then you can use jitpack repository in all your buildfiles with this syntax:

repository {
    jitpack()
}

@VigneshPeriasami
Copy link

This registers jitpack only to project repositories, any idea how to get this working for buildscript repositories, couldn't get it to work for the following code.

buildscript {
  repositories {
     jitpack()
  }
}

Adding the following line to $HOME/.gradle/init.gradle will do the work

apply from: "https://gist.githubusercontent.com/jitpack-io/380e88da1a5b3efe695b/raw/5b824f213dc1aeeed8e1c3e914135d93c3fcca4d/init.gradle"

@jitpack-io
Copy link
Author

@vignesh-iopex Thanks for the tip! Not sure how to make it work with buildscript repositories. It's probably a matter of finding the right api so might be an idea to ask in Gradle forums.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment