Cache Maven .m2 directory across projects

We are looking into CircleCI right now and are quite impressed with the possibilities so far. The only thing we didn’t get working as of today is to share a cache of the .m2 directory between projects. We have several maven projects in separate git repositories (aka projects in CircleCI) that depend on each other. Right now we are solving this issue by deploying the projects that are needed by others to a private maven repository. This works but I would like to know if there is any way to share a cache not only between jobs in one project but across projects. Any hints are appreciated. Thank you!

If they were jobs inside a workflow, you can declare a workspace to save/restore a folder.

However, it sounds like your jobs are to run independently. There isn’t anything native in CircleCI for that, but I’d suggest creating a tarball of the cache and rsyncing it to an external server. It obviously has the delay of the network, but this can still be much faster than the build process that created the cache in the first place.

Do you know roughly how big the cache folder would get?

I imagined that the cache is limited to the workflow implementation. So we go forward with our private repo method. The folder would be around 100 MB. I will look into the tarball idea as well. Thank you!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.