Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mark a directory as a generated-test-source root in IntelliJ?

I'm trying out Dagger2 in Intellij 2016.1 (but not with gradle) on ubuntu.

Intellij creates dagger's generated sources in either ./out/production/<ProjectModule>/generated/ or ./out/test/<ProjectModule>/generated_tests/ depending on if it was generated from a source or test directory, respectively.

But from what I tell, I can only mark those directories as either sources root, test sources root, or generated sources root; there is no option for generated test sources root, say.

Why is this important? Because the generated test sources depend on my test sources. If they are marked as a generated sources root then Intellij cannot find the dependencies.

Note: I don't think they should be marked as test sources root because then Intellij tries to compile those again; unless there is some way of preventing this of which I am unaware.

So is there a way to mark this directory as a generated test sources root or something equivalent?

like image 684
Michael Deardeuff Avatar asked Jul 25 '16 06:07

Michael Deardeuff


People also ask

How do I mark a folder as source root in IntelliJ?

From the main menu, select File | Project Structure Ctrl+Alt+Shift+S and click Project Settings | Modules. Select the necessary module and then open the Sources tab in the right-hand part of the dialog. Click Add Content Root and specify the folder that you want to add as a new content root.

How do I mark a directory as a test source root?

To mark a diectory as "generated test sources root", open the "Project Structure" dialog at Project Settings > Modules and click on the little "P" next to your folder of choice, and select the "For generated resources" button.

How do I create a source folder in IntelliJ?

In the Project tool window ( Alt+1 ), right-click the node in which you want to create a new directory and select New | Directory. Alternatively, select the node, press Alt+Insert , and click Directory. Name the new directory and press Enter .


1 Answers

To mark a diectory as "generated test sources root", open the "Project Structure" dialog at Project Settings > Modules and click on the little "P" next to your folder of choice, and select the "For generated resources" button.

Project Structure

like image 122
Justin Kaeser Avatar answered Nov 15 '22 10:11

Justin Kaeser