Gradle multi-project builds and IDEA, are modules not automated? - intellij-idea

I was doing some experimenting with Gradle and created a multi-project build, with multiproject_test dependent on two projects ChildA and ChildB. I put this simple test project on GitHub.
https://github.com/thomasnield/gradle_multiproject_test
Everything seems to be working great on the command line and Eclipse. Everything was compiling and the dependencies were being recognized and used. But when I imported the project into IDEA it did not create the dependencies. It seems like I had to manually create the modules although it did import the source code from the child projects.
My question is do I have to specify these module declarations separately in the build.gradle script for IDEA? Why would it not even compile the dependencies?
UPDATE
Solution proposed below worked great. IDEA handled the build.gradlescript much more gracefully than the idea plugin.

Loading a Gradle project to build an IDEA project by using the idea plugin does not always work well. The recommended way to load a Gradle project in IDEA is to import the build.gradle file from the root project.
More detailed instructions can be found in IDEA documentation here.

Related

IntelliJ IDEA: Unable to create a Gradle project

I'm facing difficulties in setting up a gradle project. During setting up of the Gradle settings in the wizard,
I am not able to use the default recommended gradle wrapper because it downloads the Gradle and the network connectivity is very bad. So I go with the local gradle distribution which I have installed in my Ubuntu. On refreshing of the gradle project after creation, I always get stuck to this error. When I run the gradle build command through the terminal on the empty project, It works fine.
I have also tried the troubleshooting solutions given by the IDE. But, that made no improvements. Need assistance to solve this problem.
Comment if any additional info required.
As no-one else has chipped in, an approach that should work is to use the Gradle Idea Plugin instead of relying on the build in support Gradle in Idea. In my experience the plugin supports a wider range of Gradle project structures than Ideasupports directly. So you would
Create a Gradle project outside Idea and confirm it all works on from the command line.
Add the Idea plugin to the project
Run 'gradle cleanIdea idea' to generate the Idea project files.
Open up the newly generated project files from Idea and off you go.

Cannot add framework support in IntelliJ 14 Ultimate

I found a pretty old post with this question but unfortunately he didn't get any help. I hope someone can assist me.
I created a repo at GitHub. After cloning it to my computer I tried to add the following framework support: Maven, JSF, EJB, CDI, etc. I know I could add the files manually. But, I want to use what the IDE has to offer.
However, the only framework showing up is SQL, which is different from this post from stackoverflow and from their documentation.
Has anyone had this same problem and got it working?
Intellij reacts to changes in your Maven pom.xml file. Maven does not react to changes in your IntelliJ project module settings.
The steps that you should follow here are
Close IntelliJ
In a command shell, clone your Github repository.
Using an editor external to IntelliJ such as VI or Notepad, create a pom.xml in the root directory. Better yet, use a Maven Archetype to generate your pom.xml.
Now open IntelliJ. Choose File, New, Project From Existing Sources. Navigate to your pom.xml and follow the prompts.
I recommend checking Search for projects recursively and Import Maven projects automatically.
Finish the project creation.
Now, add dependencies to your pom.xml via the dependencies tag. See Maven Dependencies. Intellij will automatically react to dependencies that you add as long as it can see a Maven Repository on your local machine or on your network or on the Internet.
I know it is a little bit to late but I just post it because it is still an possible issue: You need to open YourProjectName.iml and make sure that the type (<module type="JAVA_MODULE" version="4">) is JAVA_MODULE and not something else!(In my case it was WEB_MODULE)

Gradle dependencies not added as libraries in IntelliJ

I created an intellij Gradle project for some groovy code. Gradle correctly resolved the dependencies and has them added in the Project Structure's modules tab, however they are not loaded in the Libraries tab... Because of this it is impossible to compile the project, it gives me errors on missing libraries. What am I doing wrong?
I'm not an expert on this, having only just discovered a solution to this problem myself, but I found that using the idea Gradle plugin resolved the same issue for me.
So, in build.gradle add:
apply plugin: 'idea'
Then run:
gradle idea
and Gradle will create the .iml files for your project, which Intellij will understand and use to import the libraries. I'd recommend creating a backup of your project first, because if there are other things in your .iml files that Intellij needs, I suspect everything will break! I find them a bit of a mystery, personally.

Intellij IDEA code completion does not suggest classes coming from maven dependencies

This may sound stupid but here I go (there's no silly question after all, right?): I'm working on a JAVA Maven module with IntelliJ IDEA and the code completion feature works fine suggesting classes from both my module and the JDK.
However, the code completion feature does not seem to be aware of classes coming from Maven dependencies my module depends on.
For instance, my module depends on Maven dependencies such as joda-time.
The code completion popup does not suggest classes such as LocalDate.
Here's my code completion configuration:
What am I missing?
Thanks in advance.
Found the solution:
Clicked on File > Invalide caches/restart
Chose Invalidate and Restart
After restarting IntelliJ rebuild indexes from scratch and code completion works like a charm.
If it is a Gradle or Maven Project As shown in the picture, you may need to import your project build.gradle file if Gradle or maven bom.xml file if Maven. It will sync your project and may download required files from gradle or maven server.
#SenzMate Iot Intelligence

Re-factoring not working in eclipse Kepler with gradle plugin?

I have setup a gradle java multi-project in Eclipse Kepler. I have the build working great. The problem is, when I try to re-factor rename a class in one of the projects, the re-factor only occurs in that one project, and does not properly cascade to the other projects. My other projects become filled with compile errors due to the previously named class references.
Is there a way to make this re-factoring work across gradle projects?
Figured it out. The solution was to enable dependency management on each of the related projects.
To do this, right-click on the project in the package explorer:
gradle -> enable dependency management
You will need to do this to all the projects which depend on the project containing the class you want to re-factor.