Search code examples
mavengradlejitpack

Maven with Url Argument Not Allowed in build.gradle repositories


I'm trying to include a jitpack library in my kotlin project via Maven, but the syntax i'm told to follow in the docs to include it in my project doesn't work. Specifically, when I try to add maven() in my project-level gradle file:

repositories {
    mavenCentral()
    jcenter()
    maven(url = "https://jitpack.io") {
        name = "jitpack"
    }
}

I get this error in my intelliJ IDE: maven' in 'org.gradle.api.artifacts.dsl.RepositoryHandler' cannot be applied to '(java.lang.String, groovy.lang.Closure<java.lang.String>). Something seems to be wrong with the inclusion of a url as a parameter in the maven() call.

I've tried to change up the syntax to the match the example shown in the gradle docs:

repositories {
    mavenCentral()
    jcenter()
    maven {
        url = uri("https://jitpack.io")
        name = "jitpack"
    }
}

But I still can't access the lib in my code after implementing the dependency in my module-level gradle file.

Is there a conflict with using mavenCentral() and maven() together? It seems like the issue is solely about the syntax of using a url as a param to maven(). What can I do to fix this and gain access to the jitpack lib I need?


Solution

  • The solution was to add the maven call to my project-level build.gradle file instead of at the app level.

    Like this:

    Module level build.gradle

    repositories{
        //added maven repo here instead of the app-level build.gradle file
        maven { url = "https://jitpack.io"}
    }
    ...
    dependencies {
        ...
        implementation "com.github.Dwolla:dwolla-v2-kotlin:0.2.0"
    }