Is it possible to list/search or (access as groovy object) all artifacts what are in gradle artifact cache?


(Eugen Eisler) #1

Is it possible to list/search (or access as groovy object) all artifacts what are in gradle artifact cache?

Or maybe there is a way to index gradle artifact cache and then search agains it, like it is possible with “maven-indexer” for maven repositories?

Also, a workaround would be if “mavenLocal” will updated automatically with all resolved/downloaded dependencies. Then I can just search in maven repository structure, (file system structure).

Thanks


(Peter Niederwieser) #2

There is currently no special support for this, but you could traverse the file system. (Note that the Gradle cache layout is not public and may change at any time.) What use case do you have in mind for searching the cache?

Maven repository indices are typically used for searching remote repositories. In contrary to Maven’s local repository, the Gradle cache is literally just a cache; you cannot publish to it, and it is not meant to be used directly.


(Eugen Eisler) #3

We are building package management system (for our java based assemblies/artifacts) based on gradle.

In “-offline” mode, we need a way to display what packages are available for installation. For remote mode, we can use nexus web interfaces or use maven-indexer-cli.

First, we wanted to use maven and it would be not a problem to search in local repository (e.g. with maven-indexer-cli or just by search in file system), but we decided to use gradle because it is mutch powerfuller and easer to extend.

Yes, we can traverse gradle cache by file system, but it would be most worse approach, because the gradle artifacts cache is much more complex that maven local cache.

Therefore, I was looking in gradle source code some objects/utils to get all artifacts what are available in the cache, but I didn’t found a good start point. Do you have some hints, short sample code for that?


(Peter Niederwieser) #4

Yes, we can traverse gradle cache by file system, but it would be most worse approach, because the gradle artifacts cache is much more complex that maven local cache.

As long as you just need the artifacts (Jars, POMs, etc.), it’s pretty simple and not very different from a Maven repo (see ~/.gradle/caches/artifacts-13/filestore). Remember that the structure is still (slowly) evolving (there is already artifacts-14) and not considered public. I’m afraid that you could run into problems with Gradle writing into the cache while you are trying to read from it, but I don’t know the details. Similar problems might exist with a Maven repo.

Do you have some hints, short sample code for that?

Sorry, I don’t. And I don’t recommend to go that way because it’s an internal API that may change any day.


(Peter Niederwieser) #5

By the way, although I don’t know what exactly you are trying to do, have you considered using a local Nexus or Artifactory?


(Eugen Eisler) #6

Thanks. Local Nexus or Artifactory is to “havy” for us, it shall be just a command line tool or desktop ui.