Gradle: can I publish my own local cache to Gradle?

I know that I can use the maven plugin in combination with mavenLocal() to set the artifact and use it locally.

However, exploring this a little further, I notice that this means that artifacts are set to the Mavens ~/.m2 , but at the same time, Gradle's own cache lives in ~/.gradle/caches in a different format.

This seems wasteful to me, a) works with two local caches and b) must add mavenLocal() to all projects. I was wondering if there is a way to post an artifact to Gradle ~/.gradle/caches ?

+8
source share
1 answer

Note that the local Maven repository is not (in fact) a cache, and that the Gradle cache is not a repository. Gradle uses its cache only for caching remote artifacts, it should not copy artifacts received from local Maven repositories. In turn, you cannot publish artifacts to the Gradle cache .

So the approach to publishing and using mavenLocal() should not be as wasteful as you think. In addition, you do not need to add mavenLocal() to all multiproject projects individually. You can simply use something like allprojects { repositories { mavenLocal() } } in your root project. Or, if you want to use mavenLocal() in all of your independent Gradle projects, you can even try adding it to ~/.gradle/init.gradle .

+14
source

All Articles