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 cust
Solved it by removing the "Excluded" in the module setting (right click on project, "Open module settings").
Go to Project Structure - Modules - Source Folders and find the target/generated-sources/antlr4/com/mycompany
- click Edit properties and set Package prefix to com.mycompany
.
This is exactly the reason why we can set Package prefix on source dirs.
Different but related problem here
Whoever wrote that plugin screwed up big time. That's not the way to do it!
Any workaround would be a huge hack, make the plugin developer aware of his bug.
Sorry, that's the only thing to do.
OK here's a hack, directly after your plugin's execution, use the antrun plugin to move the directory somewhere else:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>process-sources</phase>
<configuration>
<target>
<move todir="${project.build.directory}/generated-sources/toolname/com"
overwrite="true">
<fileset dir="${project.build.directory}/generated-sources/com"/>
</move>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
In this example, toolname
should be replaced by anything that uniquely identifies the plugin that created the code and com
stands for the root of the created packages. If you have multiple package roots, you probably need multiple <move>
tasks.
But if the plugin adds the folder as source folder, then you're screwed.
I'm using Maven (SpringBoot application) solution is:
Then, Intellij automatically import generated sources to project.
You can just change the project structure to add that folder as a "source" directory.
Project Structure → Modules → Click the generated-sources
folder and make it a sources
folder.
Or:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>test</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/target/generated-sources</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>