2

How to copy gradle dependencies properly? Local repo is down.

I copied ~/.gradle/caches/modules-2/files-2.1/com.whatever/* from one PC to another PC but it does not pick that com.whatever dependency.

Is there any trick that needs to be done? Need to have dependencies while repo is down.

Cheers,

Witold Kaczurba
  • 9,845
  • 3
  • 58
  • 67

2 Answers2

1

The Gradle dependency cache is currently not portable, so copying ~/.gradle/caches/modules02 will only work if ~ has the same path on both machines.

If the stability of your repository is not great, you will have to setup another one, potentially file based for ease of setup, and copy into the data found in the Gradle cache respecting the structure of the repository, so something like <group_with_dots_as_file_separator>/<module>/<version>/<module>-<version>.<ext> for a Maven style repo.

Louis Jacomet
  • 13,661
  • 2
  • 34
  • 43
  • A non-portable cache is a rather [inhumane](https://www.stress.org/workplace-stress) constraint given that [Java is so bad at Internet](https://stackoverflow.com/q/26675814/86967) combined with the [transient nature of Jar repositories](https://medium.com/nerd-for-tech/the-better-maven-central-90d7e529d606). Thanks for sharing a workaround (matching the absolute path name of the cache). Luckily, you can outsmart Gradle by using a Linux symbolic link to put the cache on both paths. – Brent Bradburn Aug 26 '23 at 01:20
1

The gradle cache cannot be transferred to other machine, for resolution follow this process as suggested by James here