Unable to use Intellij with a generated sources folder Ask Question

Unable to use Intellij with a generated sources folder Ask Question

Related question How to configure IntelliJ IDEA and/or Maven to automatically add directories with Java source code generated using jaxb2-maven-plugin?

I have a custom plugin that generates sources under target/generated-sources (Note no toolname here). So I get sources like target/generated-sources/com/mycompany...etc.

This format cannot be changed at all, so will I be able to configure Intellij into adding it as a source folder. As of now, I can see that Intellij has added target/generated-sources/com as the source folder.

Please note that I do not have the option of configuring the plugin !

UPDATE 1: I do not agree with the fact that I MUST put my generated sources under a tool name folder. It may be a good convention, but if I have only one generator there is no need for me to put it there? Again, in my pom.xml I have a resources section which clearly indicates that target/generated-sources should be treated as a source folder. This works perfectly fine in Eclipse so I have no idea why Intellij would not respect my settings.

TL;DR -> When I put target/generated-sources in the resource section of pom.xml why is Intellij overzealous to add target/generated-sources/com to the classpath?

ベストアンサー1

I'm using Maven (Spring Boot application). Solution is:

  1. Right click project folder
  2. Select Maven
  3. Select Generate Sources And Update Folders

Then, IntelliJ automatically imports generated sources to project.

おすすめ記事