【发布时间】:2018-01-15 02:32:15
【问题描述】:
我在 Cordova 中使用 cordova create hello com.example.hello HelloWorld ; cd hello ; cordova platform add android 创建了一个测试项目。
我第一次使用cordova build 构建它时,它会下载 Gradle,然后我认为是一堆 Maven 文件,其中将近 200 个。这些似乎安装在~/.gradle 中,但我不确定这是唯一的地方。示例输出:
$ cordova build
ANDROID_HOME=/opt/android
JAVA_HOME=/usr/lib/jvm/java-8-oracle/
Subproject Path: CordovaLib
Downloading https://services.gradle.org/distributions/gradle-3.3-all.zip
...............
Unzipping /home/ubuntu/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/gradle-3.3-all.zip to /home/ubuntu/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9
Set executable permissions for: /home/ubuntu/.gradle/wrapper/dists/gradle-3.3-all/55gk2rcmfc6p2dg9u9ohc3hw9/gradle-3.3/bin/gradle
Starting a Gradle Daemon (subsequent builds will be faster)
Download https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom
Download https://jcenter.bintray.com/com/android/tools/build/gradle-core/2.2.3/gradle-core-2.2.3.pom
Download https://jcenter.bintray.com/com/android/tools/build/builder/2.2.3/builder-2.2.3.pom
Download https://jcenter.bintray.com/com/android/tools/lint/lint/25.2.3/lint-25.2.3.pom
(skip about 180 more lines here)
Download https://repo1.maven.org/maven2/junit/junit/3.8.1/junit-3.8.1.jar
Download https://repo1.maven.org/maven2/nekohtml/xercesMinimal/1.9.6.2/xercesMinimal-1.9.6.2.jar
Download https://repo1.maven.org/maven2/nekohtml/nekohtml/1.9.6.2/nekohtml-1.9.6.2.jar
The JavaCompile.setDependencyCacheDir() method has been deprecated and is scheduled to be removed in Gradle 4.0.
Incremental java compilation is an incubating feature.
The TaskInputs.source(Object) method has been deprecated and is scheduled to be removed in Gradle 4.0. Please use TaskInputs.file(Object).skipWhenEmpty() instead.
:preBuild UP-TO-DATE
(build continues normally here)
现在,这可能很方便,但从拥有可重现的构建环境的角度来看绝对不可取。
如何设置 Cordova 以进行完全离线构建?它会在第一次构建之后进行离线构建,还是仍然检查(例如)Gradle 更新?
如何(以及在哪里)预安装 cordova build 查找的所有内容?有没有办法让 Cordova 将所有内容安装为与进行构建分开的步骤,并将构建作为与执行此安装分开的步骤?
我可以将~/.gradle/ 的内容存档一次,然后在进行构建之前将其解压缩(在同一台机器上或不同的机器上)并让该构建脱机运行吗?如何将~/.gradle/ 移动到(例如)Cordova 项目的子目录?
这是 Ubuntu 16.04 的全新安装,从 nodesource 安装了 node 和 npm。版本:
$ cordova --version
7.0.1
$ npm --version
3.10.10
$ node --version
v6.10.3
【问题讨论】:
标签: android node.js maven cordova gradle