Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you set up Gradle properly and create a new Gradle project for IntelliJ IDEA?

So, I downloaded Gradle but I don't know how to set it up correctly. After I unzipped the zip file, what do I do next? I want to use Gradle in IntelliJ IDEA. From a livestream I've seen I know that there's a settings.gradle and a build.gradle file in the project folder in IntelliJ.

Also, I've seen that they used the windows console.

First of all, how do I access gradle through the windows console and tell it to generate a new project for IntelliJ?

As you can see, I don't have any experience with Gradle. Unfortunately I can't really find out how to use it.

I want the IntelliJ project then to have LWJGL and Slick.

Additionally, I know what it says in the build.gradle file I've seen on the livestream (I only want to create my project with the same structure like theirs).

Can anybody give a detailed description of what to do to achieve all this?

like image 202
JackWhiteIII Avatar asked Mar 10 '13 16:03

JackWhiteIII


People also ask

How do I start Gradle application in IntelliJ?

From the main menu, select Run | Edit Configurations to open the run/debug configuration for your project. icon. In the list that opens, select Run Gradle task. In the Select Gradle Task dialog, specify the project and the task that you want to execute before launching the project.


3 Answers

Lets' say you unpacked gradle to d:\tools\gradle.

To add its bin directory it to the PATH in a console window, execute the following command:

set PATH=d:\tools\gradle\bin;%PATH%

The above prepends the bin path to the current value of the PATH environment variable. This will only change the path for this specific command window.

If you want to add it to the PATH globally, then go to your control panel and choose System, then Advanced parameters (it might be something a little bit different: I'm translating from my French version of Windows). Then in the Advanced system parameters tab, click the button Environment variables.... Find the Path environment variable in the list, and add the directory, separated from the others using a semicolon (;).

Note: you can also define a new environment variable called GRADLE_HOME:

set GRADLE_HOME=d:\tools\gradle

or globally, as explained above, and reference it inside the PATH variable:

set PATH=%GRADLE_HOME%\bin;%PATH%
like image 152
JB Nizet Avatar answered Oct 22 '22 22:10

JB Nizet


Just intall homebrew.

Then you can just open the terminal and install easy like:

brew install gradle

Done! It's installed!

For test just type in your terminal:

gradle -v

And you'll have something like this:

------------------------------------------------------------
Gradle 2.7
------------------------------------------------------------

Build time:   2015-09-14 07:26:16 UTC
Build number: none
Revision:     xxxxxxxxxxxxxxxxxxxxxxxxxx

Groovy:       2.3.10
Ant:          Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM:          1.8.0_60 (Oracle Corporation 25.60-b23)
OS:           Mac OS X 10.11.1 x86_64

Then, open your IntelliJ and create a new gradle project as normal, just setting the gradle's path when necessary (normally in /usr/local/Cellar when installed with homebrew or /opt when installed other ways).

Good luck!

like image 39
Leo Ribeiro Avatar answered Oct 22 '22 23:10

Leo Ribeiro


For linux Users, User SDK Man to easily manage your gradle installation and path settings for development as well as gradle update

GET SDK MAN HERE

like image 1
lightup Avatar answered Oct 22 '22 22:10

lightup