Gatonito
Gatonito

Reputation: 1894

How to use gradle run with Intellij IDEA?

I have the following build.gradle file:

apply plugin:'application'

mainClassName = "MyMain"

allprojects {
    sourceCompatibility = 1.7
    targetCompatibility = 1.7
}

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.jsoup:jsoup:1.8.3'
}

So when I do gradle run it works perfectly, it uses jsoup and so.

Now, I've imported this project at my Intellij Idea IDE, I created a gradle build run/debug configuration, so when I press the green arrow 'run', it's building the application, but not running it, so I guess it's executing gradle build.

I've searched for an way to run the application, and the Intellij Idea says that I must create a new Application run/debug configuration. I did it, told where my main class was, but when I click run, it tries to make the source code, and claims that it can't find Jsoup for compiling.

How can I mimic gradle run in intellij idea's IDE?

Upvotes: 13

Views: 52689

Answers (5)

sakshi
sakshi

Reputation: 1

If coverage is not showing up and your test cases are passing, go to file->settings>build,execution,deployment>gradle/maven>check--build and run using idea and check--run test using idea. apply and rerurn your test cases. Make sure in edit configuration you have selected default coverage as idea.

Upvotes: 0

Radek Riedel
Radek Riedel

Reputation: 310

You need to delegate IDE build/run actions to Gradle

Idea preferences (screenshot)

Upvotes: 17

Alexiy
Alexiy

Reputation: 2040

Do not forget to click "Refresh all Gradle projects" in that tool window each time you change the build script.

Upvotes: 2

Grasshopper
Grasshopper

Reputation: 1769

Look for the Gradle Tool Window. The rest is self-explanatory :)

Upvotes: 4

Matt R
Matt R

Reputation: 734

Open the gradle window in Intellij. View->Tool Windows->Gradle.

On the right hand side you will see a list of all your gradle tasks. Double click to run or right click and assign a shortcut to any of them.

Upvotes: 13

Related Questions