Andreas Selenwall
Andreas Selenwall

Reputation: 5785

IntelliJ automagically mark a target sub directory as "source"

I use IntelliJ since a few months back now for my Java development. I using IntelliJ as IDE and build my projects using Maven. A couple of my Maven projects generates code which my other Maven projects depends upon, the generated code ends up in a target/src-generated directory with "Maven-subdirectories" main/java, main/resource etc. Is it possible to make IntelliJ automagically mark the target/src-generated/main/java directory as source?

Thanks in advance.

Upvotes: 3

Views: 3343

Answers (1)

CrazyCoder
CrazyCoder

Reputation: 401965

Please refer to the IntelliJ IDEA Maven FAQ:

In order to get generated sources automatically imported as source folders configure corresponding plugins so that they put them into target/generated-sources/<subdir>, where subdir is any folder name you prefer. The subdir folder is necessary to distinguish sources from different tools and also to exclude some special generated sources (e.g. groovy stubs).

Please note that even if you manually configure some source folders under target/generated-sources of this folder itself, IDEA will rewrite them according to your pom.xml.

Any time you want to generate sources you simply execute the corresponding goal, bound for generation (usually generate-sources, generate-test-sources). After that IDEA will pick up new folders and set them up. Generated test sources/resources should be placed in target/generated-test-sources/<subdir>.

Upvotes: 4

Related Questions