Gradle downloading dependency into cache instead of maven repository

余生长醉 提交于 2019-12-19 05:17:28

问题


I am trying to maintain the same repository on my filesystem for maven and gradle. But I am running into some problems.

I have the following in my build.gradle file.

repositories {
    mavenLocal()
    mavenCentral()
}

dependencies {
    compile group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.3.9'
    runtime group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.3.9'
    runtime 'org.xerial:sqlite-jdbc:3.8.7'
}

GRADLE_HOME is D:\Programming\Java\gradle-2.2.1
GRADLE_USER_HOME is D:\Programming\Java\.m2

My gradle home is the same as my Maven repository.

But when the dependencies are downloaded via gradle they are being downloaded into the GRADLE_USER_HOME\cache instead of the repository folder. What configuration am I missing?

EDIT I have checked the chapter on dependency management of the book Gradle In Action. Nothing. I have checked the dependency management on gradle's website but it also just says that cache is used.

It seems that there is no such option available in gradle. Can someone confirm?


回答1:


There is no setting to change that. There is no gradle repository as such. Also, it seems like a bad idea to have gradle use the repository's folder as dependency cache because of the clutter.

If you are trying to publish artifacts built by gradle to said maven repository, you should probably take a look at the maven-publish plugin.

If you are trying to use artifacts from that repository in your build, the way to go would be to add mavenLocal() to your repositories and then just use the compile function in your dependencies.




回答2:


Yes, I read the source code and just confirmed There is no setting to change that.

Here is my solution:

  1. install a local maven repository manager like Nexus.

  2. config gradle using that repository.



来源:https://stackoverflow.com/questions/27752463/gradle-downloading-dependency-into-cache-instead-of-maven-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!