DEV Community

Rytis
Rytis

Posted on

Setting up Intellij to close previously running build

Hello there, I've been struggling with this problem for 2 days now and I am completely lost.

So I've upgraded to most recent IntelliJ Idea and it turns out that they've changed the default "Build and Run" option to be Gradle (under Preferences > Build, Execution, Deployment > Build Tools > Gradle. Which is totally fine by me, if not that annoying feature where it now starts up as many instances of the program as you click run.

It used to be like this:

  1. I punch in a few lines of code
  2. Ctrl + R to build and run (under Mac, Windows has another shortcut)
  3. Old instance of my program terminates
  4. New instance of my program launches
  5. Go to step 1 and repeat ad infinitum

And now it's like this

  1. Ctrl + R to build and run
  2. Gradle builds the program
  3. Program starts up, but the build keeps spinning

Build only stops when I close the program manually. If I press Ctrl + R again, a new build launches with a new instance of the program and I find myself running 15 instances of slightly different programs more times than not.

So ideally I would like the build to be marked as complete when the actual build finishes and not when I close program. Also I would like to run only one instance of the program at a time and if I build a new one, I want old one to close down.

By the way, Parallel run is not checked under run configurations.

Another Problem

Now I could just change "Build and Run" option to be IntelliJ and be happy with the old functionality that I liked before. The problem is - when I do this it suddenly can't find any of my resources. The resource folder is marked as resource root. I can also find my resources moved to build/resources/main/. But getClass().getResource("/asd.fxml") always returns null.

I also cannot change anything in File > Project Structure as applying any changes starts throwing all kinds of errors, and the structure is managed through Gradle anyway.

I'll buy a pizza for anyone who helps me with either of the problems.

Top comments (0)