Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

In our project we are using jaxb2-maven-plugin to generate Java source code from XML Schema, which causes that our Maven module requires additional source code directory (in our case target/generated/main/java). Up to date I've been using Eclipse and maven-eclipse-plugin to import all the projects into Eclipse workspace. The plugin is (somehow) able to add the directory with generated source code automatically to Eclipse' .classpath file.

Recently I try to switch to (play with?) IntelliJ IDEA 9 (so I am a newbie in this environment) and I've noticed that additional source directory is not added during IDEA's importing process...

Is there any way I can configure IDEA/Maven to make importing directory with generated source code automatically?

like image 810
kopper Avatar asked Apr 15 '10 10:04

kopper


People also ask

How does Maven integrate with IntelliJ?

In the Project tool window, right-click your project and select Add Framework Support. In the dialog that opens, select Maven from the options on the left and click OK. IntelliJ IDEA adds a default POM to the project and generates the standard Maven layout in Project tool window.

Does IntelliJ IDEA come with Maven?

IntelliJ IDEA supports a fully-functional integration with Maven that helps you automate your building process. You can easily create a new Maven project, open and sync an existing one, add a Maven support to any existing IntelliJ IDEA project, configure and manage a multi-module project.


2 Answers

Generated code, using jaxb2-maven-plugin, was missing for me in Intellij 2017.1 whereas Eclipse Neon created it. Fixed it from context menu of module by selecting 'Maven -> Generate Sources and Update Folders'.

like image 31
striker77 Avatar answered Oct 07 '22 19:10

striker77


The convention with Maven is to generate code in target/generated-sources/<tool>, for example target/generated-sources/jaxb2

Follow this convention and IDEA will add the folder as source folder (see IDEA-53198).

like image 128
Pascal Thivent Avatar answered Oct 07 '22 19:10

Pascal Thivent