Gradle in Ubuntu for Launchpad
Solution 1
Apparently its possible to add a PPA as a dependency to a PPA and thus including Gradle.
https://help.launchpad.net/Packaging/PPA/BuildingASourcePackage#Dependencies
Solution 2
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.
So make sure that you have Java JDK installed, then head to Gradle's Website to download Gradle, and any other info that you may need.
Or, just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
sudo apt-get install gradle
Source:Gradle
Solution 3
sudo add-apt-repository ppa:cwchien/gradle
sudo apt-get update
This is correct answer, but before make sudo apt-get install gradle
, do:
sudo apt-cache search gradle
and next install latest version from new repo. In my case it:
sudo apt-get install gradle-1.9
it work's! (if you don't tell, what version you need, it install gradle(1.4) from main repo, and error will be with you...).
Solution 4
gradlew, the Gradle Wrapper, seems to be the best method: https://docs.gradle.org/2.11/userguide/gradle_wrapper.html
It is a script generated by Gradle which can automatically:
- download a required Gradle version if missing
- use it when required
You will then always use ./gradlew command
from the root of the project instead of your system's gradle
.
How to generate the wrapper is explained on the docs and at: https://stackoverflow.com/questions/25769536/how-when-to-generate-gradle-wrapper-files
Solution 5
sdkman
I faced a similar issue recently where i needed gradle just for one project:
Using apt wasn't very appealing as that meant tons of extra dependencies which i would certainly forget to uninstall afterwards. Also i needed a fairly recent gradle build.
I went with sdkman package manager instead which is pretty neat for java development:
You get bleeding edge versions of packages installed directly to your home directory without interfering with ubuntu system-wide setup. After i'm done i can just delete the user i created for the task and everything is back as before.
To install sdkman and gradle:
$ curl -s "https://get.sdkman.io" | bash
Open new terminal
$ sdk install gradle
Related videos on Youtube
Marlinc
Updated on September 18, 2022Comments
-
Marlinc almost 2 years
It appears that Ubuntu doesn't have new versions of Gradle in their repositories for some reason. I need it for a project that will be build by Launchpad.
What should I do about this?
-
Marlinc almost 11 yearsWell I could use that on my local machine but would that work on Launchpad? How would I tell it to download Gradle before starting the build.
-
Mitch almost 11 yearsI don't think that you can do that. I think that you need to build locally, and then add to Launchpad.
-
Mitch almost 11 yearsWhy did you unaccept? :)
-
Marlinc almost 11 yearsBecause that would not work on Launchpad. In Launchpad you're able to add a PPA for build dependencies. So I added it and specified it as a build dependency on my package. I've added that as a answer to this question so others can see it too.
-
catch23 over 10 yearswhere is gradle home after running this commands?
-
Mitch over 10 years@nazar_art Take a look at stackoverflow.com/questions/18495474/…
-
IgorGanapolsky about 9 yearsI have a problem: "gradle is already the newest version."
-
IgorGanapolsky about 9 yearsBut I get a message: "gradle-1.9 is already the latest version". Hence it doesn't let me install gradle.
-
IgorGanapolsky about 9 years@Mitch I cannot install gradle, even though my system says that gradle is newest version!
-
Mitch about 9 yearsWhy do you want to install, if its already installed, and its at the newest version?
-
catch23 about 7 yearsGradle is installed to
/usr/lib/gradle/{your-version}