2

PLEASE NOTE: THIS IS NOT A DUPLICATE. I want Gradle's IDEA plugin to correctly configure my IntelliJ IDEA CE project for me. I am not interested in any solution that involves manually tuning IntelliJ to find my JDK. This is a Gradle IDEA plugin feature that can and should work.

If you can find another question that involves correctly getting the Gradle IDEA plugin to configure IntelliJ (running on a Mac) so that it can find JDK 8+, then please by all means, mark this as a dupe and provide a link to that question. Otherwise, do not vote this as a dupe (it's not!).


Mac 10.9.5 here. Java 8 is my default JRE/JDK, and I just installed Groovy 2.4.6 and Gradle 2.13 via sdkman. I then installed IntelliJ IDEA CE.

On my terminal, I created a test-proj directory, and then inside that directory I issued the following Gradle command:

gradle init --type groovy-library

Gradle executed successfully, giving me a Groovy project skeleton. I then edited the generated build.gradle to contain the IDEA plugin:

apply plugin: 'idea'

And then I ran:

gradle wrapper
./gradlew clean idea

This generated the Gradle Wrapper for me, and I then used the IDEA plugin to generate IntelliJ project files for me. I then opened my brand-spanking-new IntelliJ IDE and went to Open my test-proj.

The project opened and everything appeared to be OK. But then I started coding and noticed that JRE classes such as String were not showing up as resolvable. So I went to File >> Project Structure and see this:

enter image description here

So it appears that IntelliJ can't find my default Java 8 JDK. I know the OS can find both the JRE and the JDK, based on the console ouput of java -version and javac -version. But something, between sdkman, Gradle or IntelliJ is preventing the IDE from finding Java. Any ideas?

smeeb
  • 27,777
  • 57
  • 250
  • 447
  • Possible duplicate of [how can i set the jdk in intellij 9 on mac](http://stackoverflow.com/questions/2993601/how-can-i-set-the-jdk-in-intellij-9-on-mac) – Jolta May 18 '16 at 15:27
  • Refer to the Intellij documentation: https://www.jetbrains.com/help/idea/2016.1/configuring-global-project-and-module-sdks.html?origin=old_help – Jolta May 18 '16 at 15:27
  • Thanks @Jolta but **this is not a duplicate!!!** Unlike that other question and the helpdoc link you posted, I want **Gradle** to configure my IDEA project files for me. I have *absolutely* no interest whatsoever in manually configuring anything in the IDE. Gradle can and should be doing all of this for me. So again, its not an IntelliJ config question, it s a glitch between OSX, Gradle, IDEA and possibly sdkman. Please do not flag this as a dupe! – smeeb May 18 '16 at 15:33
  • Not a dupe, how else can I say this?!? – smeeb May 18 '16 at 15:43
  • It might be not a duplicate but is not a programming question either. Anyway, probably you have to set your JAVA_HOME environment variable, see [this blog](http://codepulsive.blogspot.com.au/2013/05/setting-environment-variables-in-os-x.html) Also, try opening a ticket with [IntelliJ support](https://intellij-support.jetbrains.com/hc/en-us/requests/new?ticket_form_id=66731), they are very attentive and will follow up with you until you get the right answer. And finally don't forget to answer your own question when you find the solution. :) – OscarRyz May 18 '16 at 15:59
  • JAVA_HOME is set, and if *any* questions about Gradle or IntelliJ are off-topic here, my name is Julius Caesar. – smeeb May 18 '16 at 16:00
  • What does your name has to do with this? pfff Anyway, your attitude towards the people trying to help you is not the best. I've just did what you've described and it [works as expected](http://i.stack.imgur.com/yCZvX.png) – OscarRyz May 18 '16 at 16:11
  • Ugghhh, the old "you attitude towards others falsely accusing your question as a dupe" defense, that moldy chestnut... – smeeb May 18 '16 at 16:38
  • Uh? what are you talking about? sigh, anyway, I would really recommend you open a ticket with intellj support, they are really good at it. – OscarRyz May 18 '16 at 17:04

1 Answers1

0

I had the same problem, although i got it running by removing the .idea folder and reimporting the project by pointing to my build.gradle file. In the import dialog i selected the .ipr structure instead of using the idea "folder based structure" (default)

When executing gradle idea it will then generate an .ipr file in your project root configuring your project. In my case the jdk was set properly and my modules were initialized correctly.

The reason behind using the .ipr files is, that the gradle idea plugin can't work with the directory based structure. See also:

Since i figured this out today i'm not sure how good this is working. Or what are the differences between directory based and .ipr based (.ipr based seems older?).

Community
  • 1
  • 1