Generate sources with xjc works but refuses to add as generated sources root...
Hi,
I have a maven java project with an xjc step to generate sources. If I do a maven clean then press the "Generate Sources And Update folders For All Projects" button in the Maven view, it generates the sources (a /target/generated-sources/jaxb folder appears with all the generated sources underneath in the correct packages), but the Update Folders part of the step does not seem to work. The folder is not marked as a Generated Sources Root directory, and compilation fails.
I can manually add the folder as a Generated Sources Root (Mark Directory As... Generated Sources Root), which incidentally also marks a nested jaxb folder which is a java package as a Generatied Sources Root folder as well, which I don't want, and which I can then Mark Directory As... Unmark as Sources Root, but after these corrections, the build in IntelliJ works. A reimport of the maven project kills these manual fixes though, making it a rather unworkable workaround.
I've also played with the maven-build-helper-plugin to manually mark the directory as a source directory, but this doesn't help.
The maven build always works suggesting that the maven configuration is fine.
Does anybody have a clue how to get this working?
Please sign in to leave a comment.
Please check what Generates sources folders option and Phase to be used for folders update are set to in Settings(Preferences) | Build, Execution, Deployment | Build Tools | Maven | Importing settings. Try changing accordingly.
>A reimport of the maven project kills these manual fixes though, making it a rather unworkable workaround.
Please enable Keep sources and test folders on reimport option.
Hi, thanks for the answer.
The settings had Detect Automatically with process-sources as phase. I changed both of these to try different combinations and I saw it work a few times in every any combination of settings (Detect Automaticall vs subdirectories of target/generated-sources, as well as generate-sources vs process-sources). However it also stopped working again in all these combinations. I can't figure out when or why.
The "Keep sources and test folders on reimport" option was already enabled. But even with this option enabled it discards the generated sources route folder on reimport. So with the following settings:
I manually mark the folder as generated sources root, then press reimport, and it's immediately unmarked.
Are there any specific Maven pom.xml settings where you specify generated sources folder? Do you use 3rd IDE plugins?
Hi,
I do not specify anything in the pom, the build plugins part looks like this:
The parent pom has one extra plugin (sonar-maven-plugin) but the problem persists even when I disable it.
My IntelliJ install has one plugin listed under "Custom", namely the Lombok plugin, but I disabled it and restarted IntelliJ and the problem still persists as well.
There was similar issue reported: https://youtrack.jetbrains.com/issue/IDEA-123702 when multiply schemas are defined. If issue is different please share a sample project to reproduce.
I looked into a bit more, and there seems to be something strange going on. IntelliJ marks the wrong directory as generated sources root:
At first xdto was called jaxb, so I changed it since I thought it might be an issue related to the name of the package, but now that it's called xdto it does the same thing. The top level com package should be the one being marked as generated sources root...
Ah our replies crossed each other. That bug indeed does look like the issue you are pointing to, except that neither of the workarounds work for me.