简体   繁体   中英

Gradle dependency from Maven local

I would like to add a maven dependency in my gradle, but what I did didn't work. In my project gradle I put the code below to give my local maven repository url

buildscript {
    repositories {
        maven { url "${System.env.HOME}/.m2/repository" }
        mavenCentral()
    }
}

Then in my app gradle I tried to add my dependency with

compile 'my.package.name:lib:version'

But I got an error and I can't figure out what to do

Error:Could not find my.package.name:lib:version.

When I launch a maven clean install, I get the path

C:\Home\.m2\repository\my\package\name\lib\version\lib-version.pom

Does someone know what I'm missing or what to do ?

  1. Add a dependency:

     dependencies { compile '<groupId>:<artifactId>:<version>' ... 
  2. Add mavenLocal() or path to repo:

     allprojects { repositories { mavenLocal() . . . } } 

    -OR-

     allprojects { repositories { maven { url uri('/Users/home/.m2/repository') } . . . } } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM