0

I have a project setup that is as follows

Project A
|
|-Sub-Project B
|-Sub-Project C
| |
| \-src
|   |
|   |-Sub-Project D
|   \-Sub-Project E
\-Sub-Project F

In order to get the project to build and Idea modules created I need to put a build.gradle file at each level, however I dont really want idea modules created for Project C and the child src directory. Is there a way to suppress these modules?

Also is there a way to specify a group for idea modules?

Klunk
  • 815
  • 7
  • 22
  • 1
    The easiest solution is to adapt `settings.gradle` so that `Sub-Project C` and `src` don't become Gradle subprojects. I don't understand the latter question (group). – Peter Niederwieser Jan 20 '14 at 17:33
  • But I will still need a build.gradle file in those directories? I was hoping to be able to remove those directories from the Intellij project view. In Intellij you can group projects together in logical views, I was hoping that there was a way to specify this grouping so the ipr generated by gradle had those groups. – Klunk Jan 21 '14 at 09:29
  • I found this post (http://forums.gradle.org/gradle/topics/skip_root_module_in_idea_project) which does pretty much all I need to do except correctly create the ipr file. I see the project how I would like to see it but Project C and src are still added as projects and Intellij gives an error that it cannot find the iml files. Project C and src are not mentioned in the settings.gradle file. How can I stop the idea plugin adding src and Project C into the ipr file? – Klunk Jan 21 '14 at 10:52

2 Answers2

1

I have found the answer to the question of not adding the projects to the ipr file. Adding the following to my top level build.gradle file only adds projects where ideaModule.enabled == true.

gradle.projectsEvaluated {
    gradle.rootProject {
        ideaModule.enabled = false
        idea {
            project {
                modulesToInclude = subprojects.findAll {it.ideaModule.enabled == true}
                modules = modulesToInclude.idea.module
            }
        }
    }
}
Klunk
  • 815
  • 7
  • 22
0

Just create Sub-Project D directly in the Sub-Project C directory (without a src directory). You can also omit build.gradle in Sub-Project C. Idea 13 imports that structure without any problems. Just remember to add only the real subprojects to the settings.gradle:

include 'Sub-Project B', 'Sub-Project D', 'Sub-Project E', ...
Marcin Zajączkowski
  • 4,036
  • 1
  • 32
  • 41
  • I am not able to change the directory structure. If this was possible I would have gone for that as it is the easiest option. Thanks – Klunk Jan 21 '14 at 09:23