Module ... is not backed by gradle
Asked Answered
B

10

94

I'm using IntelliJ IDEA Pro 13.1.2. Never used any versions below 13.

When trying to run build.gradle from IDE I get the message:

Module is not backed by gradle

I can run this script from the command line just fine.

The "root" directory has both .gradle and gradle sub-directories and, in general its structure is very similar to another module from the same project where I can run its build from IDE without problems.

Any suggestions on further troubleshooting?

Barros answered 7/5, 2014 at 19:52 Comment(4)
Sounds like you didn't set up the IDE project via "Import Project" and then pointing to a Gradle project. You can also try to link the IDE project to a Gradle project in the "Gradle" window. Not sure what you mean by "run build.gradle from IDE".Knudson
Yes, it was not set-up in "Gradle" window. I built this module as new IDEA module, never imported it. Now it works. Thank you. If you care to post the same as an answer I would gladly accept it.Barros
In IntelliJ 2016 you can accomplish this by closing the project and reimporting it, pointing intellij specifically at the build.gradle file.Villainage
This can happen when you did not import the project as a Gradle project. To solve this: Close the project. Delete its .idea folder. Reopen the project using IntelliJ.Dillman
K
59

If you didn't set up the IDE project via "Import Project" and then pointing to a Gradle project, you may have to link the IDE project to the Gradle project. This can be done in the "Gradle" window.

Knudson answered 7/5, 2014 at 20:44 Comment(7)
Much obliged. Thanks again.Barros
Stupid question - for a non-gradle project, how do I find the "Gradle" window? It doesnt seem to be available via ctrl+shift+a -> "Gradle" (enter). Nor can I see any relevant facets (other than Groovy, which doesnt help either)Albuminuria
Tools > Grails > Change SDK Version did the trick for me. Edit: IntelliJ 14.1 - OS X 10.9.5Cayser
There is no Grails in the Tools menu. IntelliJ 14.1.4. OS X 10.10.5.Gastrocnemius
Also a restart of intellij might be a good idea since at startup build.gradle is identified and the project is set up.Anguish
@MicahZoltu still true for Idea 15.0.1Innervate
The simpliest way is just to click File/Open... and to select the build.gradle file.Sunrise
S
49

The answer that worked for me is to restart IntelliJ - at startup build.gradle is identified and the project is set up.

The only thing that worked for me was to use the menu File > Close Project and reopen it. IDEA popped up a dialog saying "Import project from Gradle files" or something to that effect.


Dead ends: Below is a list of dead ends, so don't waste your time with them. I kept seeing "module is not backed by gradle" despite following all these proposed solutions:

  1. There was no Gradle tool window, so I couldn't synchronize the project
  2. Clicking File > Open gradle.build opens the file for editing and doesn't solve the issue
  3. Creating a run configuration that runs gradle has no effect, even after I saw a build/ folder created
  4. Runing ./gradlew from the commandline only creates files for gradle and doesn't fix IntelliJ
Scowl answered 25/1, 2016 at 5:35 Comment(2)
Only your advice actually helps me.Cradle
Ever since I created this answer, it has consistently been upvoted.Scowl
I
13

I fixed this problem by clicking in the Menu

--> "Run" 
--> "Edit Configurations" 
--> [+] The little plus in the top left corner 
--> "Gradle"

With the new created run configuration it worked. I hope this will help some of you.

Individualist answered 15/1, 2016 at 17:2 Comment(0)
B
9

Tools > Grails > Change SDK Version

Boron answered 1/8, 2015 at 23:14 Comment(2)
Worked great for me on ubuntu with intellij 14Lushy
Worked for me (OS X 10.10.5, Grails 2.4.4 app with grails and groovy installed using sdkman). Saw the problem as a result of the recent conversion of gvm to sdkman, so part of the issue was correcting the global library path for grails in the IDEA settings.Snuggle
P
5

Like others have said, none of the other answers worked for me. The only thing that worked was:

Close the project, then import it as a Gradle project.

Paillette answered 13/4, 2017 at 14:50 Comment(0)
A
4

For a non-gradle project, you can also remove the module from the project and re-import it. This will help avoid the message "module is not backed by gradle".

Admass answered 19/3, 2015 at 9:7 Comment(0)
E
3

I'm using android studio, intellij. Try this:

  • Tools > Android > (sync project with gradle files)
  • Run gradle build
Eyelid answered 20/3, 2016 at 17:25 Comment(0)
S
0
  1. Do not select the project directory when importing
  2. Select the gradle file to import as a Gradle project
  3. I always use Local Gradle Distribution and Offline work to build, then switch back.
  4. It will auto build and you will see the gradle task in task window.

Hope it works for you.

Stercoricolous answered 24/7, 2017 at 2:47 Comment(0)
G
0

This problem happened for me because I chose a different name for my project than my artifactID. In order to prevent this problem to happen, make sure your project name is the same as your artifactID.

Greenstone answered 11/3, 2018 at 11:30 Comment(0)
E
0

You may have originally created the project via File->New->Project From Version Control. This doesn't seem to always set the project up as a Gradle project, even if there is a build.gradle in the root directory. To solve this:-

  1. Close IntelliJ.
  2. Delete the .idea folder in the project.
  3. Start IntelliJ and select 'Open'.
  4. Navigate to the project folder and open it.

The project will be recognised as Gradle and be set up as such.

Edlyn answered 2/5, 2018 at 2:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.