1

I have a somewhat atypical folder structure where my java sources are in 2 different source folder,

src/main/java
src/main/some-generated-code

IntelliJ does not recognize some-generated-code as a source folder and this obviously leads to all sorts of red-warnings in the IDE.

One way to fix this obviously is to go to the Project explorer right click on some-generated-code and "Mark Directory As Sources". This works fine. However I have multiple projects with the same structure and I was wondering if it is possible to by default have any folder with the structure src/main/some-generated-code designated as a "Source" folder.

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
Moiz Raja
  • 5,612
  • 6
  • 40
  • 52

1 Answers1

1

Do this:

-Right click on the project in Intellij
-Click on "Open Module Settings"
-You'll see something like the below image.
-To assign a folder as a source, click on it and then click Sources

-enter image description here

sparrow
  • 450
  • 5
  • 13
  • I'm not sure why this was down-voted. It worked for me. One thing to note is that a previously created folder may not show up in this dialog. I just right-clicked the main project address and clicked "add folder" from the drop-down menu. This made the folder appear, and allowed me to set it as a source. – LuminousNutria Dec 20 '18 at 20:35
  • Please have a look at https://stackoverflow.com/q/74203874/4134215 – Taimoor Khan Oct 27 '22 at 07:19