Environment:
Linux + JDK 11 + Gradle 5.0
I have several gradle projects which must build from sources without Internet connection/ For example this one git clone --depth 1 --branch 3.0.0 https://github.com/bobbylight/RSyntaxTextArea.git
for that first of all I built this project online then copy ~/.gradle to $PROJECT_DIR/grdl , next I want to test this build offine. I perform gradle --stop
, clear whole ~/.gradle directory then turn off Internet and run following script:
cp -r ./grdl/* ~/.gradle
cd RSyntaxTextArea
gradle --offline clean build
And everything builds good until I move these files to a different Linux+JDK11+Gradle 5.0
offline machine. When I run same script there I have following errors:
./build.sh
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':RSyntaxTextArea'.
> Could not resolve all artifacts for configuration ':RSyntaxTextArea:classpath'.
> Could not download coveralls-gradle-plugin.jar (org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.8.2): No cached version available for offline mode
> Could not download httpmime.jar (org.apache.httpcomponents:httpmime:4.3): No cached version available for offline mode
> Could not download org.eclipse.jgit.jar (org.eclipse.jgit:org.eclipse.jgit:3.6.0.201412230720-r): No cached version available for offline mode
> Could not download http-builder.jar (org.codehaus.groovy.modules.http-builder:http-builder:0.7.1): No cached version available for offline mode
> Could not download httpclient.jar (org.apache.httpcomponents:httpclient:4.3): No cached version available for offline mode
> Could not download jsch.jar (com.jcraft:jsch:0.1.50): No cached version available for offline mode
> Could not download JavaEWAH.jar (com.googlecode.javaewah:JavaEWAH:0.7.9): No cached version available for offline mode
> Could not download json-lib-jdk15.jar (net.sf.json-lib:json-lib:2.3): No cached version available for offline mode
> Could not download nekohtml.jar (net.sourceforge.nekohtml:nekohtml:1.9.16): No cached version available for offline mode
> Could not download xml-resolver.jar (xml-resolver:xml-resolver:1.2): No cached version available for offline mode
> Could not download httpcore.jar (org.apache.httpcomponents:httpcore:4.3): No cached version available for offline mode
> Could not download commons-beanutils.jar (commons-beanutils:commons-beanutils:1.8.0): No cached version available for offline mode
> Could not download commons-logging.jar (commons-logging:commons-logging:1.1.3): No cached version available for offline mode
> Could not download commons-codec.jar (commons-codec:commons-codec:1.6): No cached version available for offline mode
> Could not download commons-collections.jar (commons-collections:commons-collections:3.2.1): No cached version available for offline mode
> Could not download ezmorph.jar (net.sf.ezmorph:ezmorph:1.0.6): No cached version available for offline mode
> Could not download commons-lang.jar (commons-lang:commons-lang:2.4): No cached version available for offline mode
> Could not download xercesImpl.jar (xerces:xercesImpl:2.9.1): No cached version available for offline mode
> Could not download xml-apis.jar (xml-apis:xml-apis:1.3.04): No cached version available for offline mode
I have four of five gradle projects with similar problem. Surprisingly, one went offline fine on both machines, this one - git clone --depth 1 --branch 0.27 https://github.com/JFormDesigner/FlatLaf.git
. I think that I don't understand gradle cache properly. Could you help me to build gradle projects without Internet? It could be any version of Gradle but I tied to Linux + JDK 11.
I think you are hitting this issue: https://github.com/gradle/gradle/issues/1338
That is, cache items are non relocatable. Copying the whole ~/.gradle
folder may not be enough, especially if ~
resolves to a different path than in the original machine (i.e. different user). The full path needs to be exactly the same (with Gradle 5.0).
The issue suggests however that version 6.1 makes the cache relocatable, so perhaps you'll have more luck with a recent version (7.2 is the latest at this point in time).
EDIT: The release notes and these docs confirm that the cache can be copied across deployments as of version 6.1.1.