GradleCopy is a Qt framework based tool to copy Gradle caches to Android local "m2repository" directory which saves me from redownloading them (again and again).
- First, ensure you have
ANDROID_HOMEenvironment-variable, pointing to your Android-SDK directory. - Create the
init.gradlefile in your%UserProfile%/.gradledirectory, and open it (in your prefered text-editor). - Then, simply copy below and paste in
init.gradlefile (replacing any previous content):
def offlineRepoDir = "${System.getenv("ANDROID_HOME")}\\extras\\m2repository"
def repositoryClosure = {
maven { url uri(offlineRepoDir) }
// google()
// mavenCentral()
}
rootProject {
buildscript {
ext.machineOfflineRepoDir = offlineRepoDir
}
allprojects {
buildscript {
repositories(repositoryClosure)
}
repositories(repositoryClosure)
}
}
settingsEvaluated { settings ->
settings.pluginManagement {
buildscript {
repositories(repositoryClosure)
}
repositories(repositoryClosure)
}
}
-
Download
GradleCopyif you didn't already, and launch it. -
Uncheck the
Test Runoption (to skip listing what will be done). -
At last, click the
Copybutton and done! -
But sometimes Gradle only downloads
.pomfiles, and fails to fetch related.jarfiles:-
To fix that: Gradle will not even try to download related
.jarfiles (as long as your offline repo contains related.pomfile). -
First, click the "
Generate Missing Jar List" option from theCopybutton's dropdown menu. -
In the resulted window, click the "
Download" button (which downloads what is missing, instead of relaying solely on Gradle). -
Then in the same window, click "
Disable incomplete lib" option from theDownloadbutton's dropdown menu (which renames any.pomfile with no.jarfile beside it, inside your offlinem2repositorydirectory only). -
Previous step (the rename) can be undone by clicking "
Restore incomplete lib" option (from the same menu).
Note that because some older packages are no longer available for download, both of said downloading and renaming should be done.
-
Platform: broken Windows, but should also work for MacOS and Linux as well (once compiled).
Note:
All codes are based and meant to be Apache 2.0 License but it does use the Qt4 framework under the LGPL or GPL license, so if you rewrite this using another framework it is pure Apache 2.0 License