2

Sorry for the long title.

I'm trying to isolate our functional test code from our integration test code, and have gotten it to work using gradle tasks. It's 95% working in intellij, too, except that every time I do a "gradle idea", i have to add the functional test code.

It's currently not an option to separate it into its own repository or change the directory structure.

The directory structure looks like

* MainProject/build.gradle
* MainProject/WEB-INF/src(java source code)
* MainProject/(lots of html files)
* MainProject/WEB-INF/functionalTest(groovy source code)
* MainProject/functional-gradle/build.gradle

and I want intellij to automatically detect that the functionalTest test source code belongs to functional-gradle, even though it looks like it should be a part of MainProject(but is not included in any of the MainProject build.gradle sourceSets).

Other considerations : I would like it to be a gradle subproject and not part of the main build.gradle as a different sourceset because our current build process isn't very standard, and it'd be nice to start with a clean gradle slate and isolate the gradle tasks that are needed for the functional tasks(there are a lot of them). This would make it easier to eventually pull out into its own repository.

The picture below shows the intellij field i want to be auto-populated : the sub project module's test source folder.

intellij subproject

the important part of the gradle sutff

sourceSets {
    test{
        groovy{
            srcDir '../WEB-INF/catTest'}
    }
}
  • If you want it as a gradle subproject, have you got a settings.gradle file in the root? – Ben Green Jun 03 '16 at 15:00
  • Thanks for the response. Yep. The Gradle side of it all works so far, it's just that intellij doesn't seem to know how to handle that the test code for the subproject isn't inside that subproject's main folder(functional-gradle) – Raptor Dzuricsko Jun 03 '16 at 15:32
  • Hi, sorry for the late response. So, if you run the gradle tasks from the command line, does it correctly run? As in, do you know if this is a problem with intellij set up or gradle set up? – Ben Green Jun 06 '16 at 08:05
  • no worries! thanks for responding at all. Yep, if i run the gradle tasks from the command line it runs correctly. It's a problem that I can't get intellij to do it correctly, automatically, without having to manually add the subproject as a Test Source Directory. We have to run gradle idea pretty frequently and I don't want to add a step for new developers to get set up to run this test code – Raptor Dzuricsko Jun 06 '16 at 15:07
  • Why do you need to have the project as being specific test source? If the project just contains tests, then the subproject with the actual source code doesn't need to know about it at all. If it contains code needed for other subprojects to be tested, can't you just add it as a `testCompile` dependency? Apologies if I am missing something. – Ben Green Jun 07 '16 at 08:19
  • Hey Ben, The sub-project just contains tests - the code snippet was from the subproject's build.gradle. I was thinking about how to interpret your comment and figured out I could just move the subproject build.gradle into the subproject's folder, which would solve all my problems ever. Thanks so much for your time and line of thought on this. – Raptor Dzuricsko Jun 07 '16 at 19:40
  • 1
    No problem. Happy to help :) – Ben Green Jun 07 '16 at 19:48

1 Answers1

2

Getting Intellij IDEA (13+) to recognize Gradle module interdependencies

I looked at Radim's answer and it looks like there's gradle docs on how to set up the ide's IML file. https://docs.gradle.org/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html

Going to play around with that and will report back once I've got something working for my use case.

EDIT: I gave up and moved the build.gradle from the external folder on the root to inside the functional testing directory. Intellij picked this up right away.

Community
  • 1
  • 1