当前位置: 首页>>技术教程>>正文


在Ubuntu Gradle for Launchpad

, , , ,

问题描述

由于某种原因,Ubuntu似乎没有在其存储库中安装新版本的Gradle。我需要它用于将由Launchpad构建的项目。

我该怎么办?

最佳解决思路

Gradle requires a Java JDK to be installed. Gradle requires a JDK 1.5 or higher. Gradle ships with its own Groovy library, therefore no Groovy needs to be installed. Any existing Groovy installation is ignored by Gradle.

Gradle uses whichever JDK it finds in your path (to check, use java -version). Alternatively, you can set the JAVA_HOME environment variable to point to the install directory of the desired JDK.

因此,请确保安装了Java JDK,然后前往Gradle’s Website下载Gradle以及您可能需要的任何其他信息。

或者,只需按键盘上的Ctrl + Alt + T即可打开终端。打开时,运行以下命令:

sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle

来源:摇篮

次佳解决思路

sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update

这是正确答案,但在制作sudo apt-get install gradle之前,请执行以下操作:

sudo apt-cache search gradle

然后从新的repo安装最新版本。就我而言:

sudo apt-get install gradle-1.9

有用! (如果你不说,你需要什么版本,它从主回购安装gradle(1.4),错误将与你…)。

第三种解决思路

显然它可以添加PPA作为PPA的依赖,因此包括Gradle。

https://help.launchpad.net/Packaging/PPA/BuildingASourcePackage#Dependencies

第四种思路

Gradlew,Gradle Wrapper,似乎是最好的方法:https://docs.gradle.org/2.11/userguide/gradle_wrapper.html

它是由Gradle生成的脚本,可以自动:

  • 如果丢失,请下载所需的Gradle版本

  • 在需要时使用它

然后,您将始终使用项目根目录中的./gradlew command而不是系统的gradle

如何生成包装器在docs和https://stackoverflow.com/questions/25769536/how-when-to-generate-gradle-wrapper-files上进行了解释

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/1121.html,未经允许,请勿转载。