Search code examples
javamavenkotlingradlegradle-kotlin-dsl

How to include maven repository with id in gradle?


I am trying to use SimpleNativeHooks in my kotlin gradle project. I use the kotlin gradle dsl, but SimpleNativeHooks can not be found and downloaded. The error I get is:


    :KJ:launch:test: Could not find org.repeats.simplenativehooks:simplenativehooks:0.0.1.
    Required by:
        project :KJ:launch
    
    Possible solution:
     - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

The code I am currently using for the repo is:

dependencyResolutionManagement {
  repositories{
    maven {
      url = java.net.URI("https://raw.github.com/repeats/SimpleNativeHooks/maven-export/")
    }
  }
}

But on the github README, the maven example includes a few others as well. I'm wondering if the reason I'm getting an error in my gradle build is because I haven't properly converted that maven code into gradle, maybe because I missed some of those fields (like the repo id, which I don't know how to include in gradle).


Solution

  • This URL is not a fair maven repository (it returns 400: Invalid request after 301: Permanent redirect), so you need to give Gradle a hint, where to look for artifacts metadata - in this case, there is pom.xml in the root :

    maven {
        url = uri("https://raw.github.com/repeats/SimpleNativeHooks/maven-export/")
        metadataSources {
            mavenPom()
        }
    }