maven integration and directories under "generated-sources."
I'm having trouble with IntelliJ's maven integration. I cannot get directories under target/generated-sources to be added as source roots for maven modules. When I open a maven project, IntelliJ marks the target directory as ignored. I'm using build #7549.
请先登录再写评论。
That is certainly on account of last bug-fixes. I've made target directory to be marked as excluded because there were request from users who have troubles with this directory. For example with web descriptors auto-detection.
Ok, I'll revert that change and do something else with facets detection.
BTW, how do you configure generated sources?
I'd like to have all directories under target/generated-sources added as source directories and all other directories under target ignored.
I'm afraid that is not possible since idea does not allow source folders under excluded directories. And as target directory might contain quite a lot of various directories under it, that is not possible to predict which of them to exclude.
The only solution I see is to exclude general directories (classes, test-classes) and mark generated sources as source folders.
And I wonder how do you configure you generated-source folders? What plugin do you use?
I use the jaxb2 plugin to generate source code from XML schemas, the antlr plugin to generate source code from antlr grammars, and a custom plugin that I use to generate java classes from .properties files.
And where are all the generated sources placed? Are there differente folders for jaxb2 and antlr sources?
They are all placed under target/generated-sources/<plugin-specified-directory-name>
So the jaxb2 plugin places sources under target/generated-sources/jaxb, The antlr plugin places sources under target/generated-sources/antlr3 and my plugin places sources under target/generated-sources/process_properties_main and target/generated-sources/process_properties_test
I think one problem is that target/generated-sources is a best practice but it is up to each Maven plugin to honor this. Luckily most of them allow overrides to the output location so those that don't default properly can usually be forced to target/generated-sources/<plugin-specified-directory-name> like Brandon mentions.
A problem I am having with my development workflow is that this directory is only detected when you open a pom.xml and Idea re-scans for possible generated source dirs under target. So basically nothing is detected if you open the project from a fresh checkout or after you have done a mvn clean. I would prefer that target/generated-sources be a default source dir when opening a Maven project, although I understand that this will probably irritate some people.
Unfortunately, these Maven issues are going to divide people and make it hard to find a universal solution.
I think that a rescan after you generate-sources for the first time is an acceptable tradeoff. Perhaps we could a global setting that specified generated-source directory patterns.
I think user created generated sources pattern matching is is a great idea since it they could be completely arbitrary. As far as rescanning, I don't mind the scan, but on larger projects closing the project and reopening makes it painful. I would like to see something happen while the IDE is open, like possibly checking for new generated sources directories when you press the synchronize button.
Every plugin which generates sources adds it to ${project.sources} or something similar directory. So write a small plugin that executes after compile phase so that all the plugins which generate source would have added those directory to ${project.sources} and split that to a temp file to get the list of all the generated source directories. This way one does not need to worry about non-standard locations or user specified locations - it works seamlessly.
Regards,
--Venkat.
Is there a bug report for this that I can follow? I noticed that new EAP still has the same problem.
Yes, I've created one. Please watch http://www.jetbrains.net/jira/browse/IDEADEV-23389
Thanks
So in what way has this been fixed in 7.0.2?
My company generates sources in target/generated-sources/main/java but idea is picking up target/generated-sources/main as the source folder and I can't find any option to change this (i use temporary project files as the projects are in a state of flux at the moment so I don't want to do this manually).
What plugin do you use for the code generation?
Could you please paste the pom section for this plugin?
Have sanitised a bit, but pom.xml is below:
... ... 1.0 4.0.0 ... ... ... ${anthill.version} jar 1.0 org.apache.cxf cxf-codegen-plugin ${cxf.version} generate-sources ]]>$/target/generated-sources/main/java http://some_host/SomeWSDL.wsdl true wsdl2java org.apache.cxf cxf-codegen-plugin ${cxf.version} ]]>
Ok, I see.
By and large, the problem with generated sources under the target directory should have been fixed in 7.0.3. There is a specific issue, though, with such sources. Only the immediate subfolders of the 'generated-sources' directory are marked as source folders.
In the first 7.0.4 eap much better source folders resolution will be implemented. We will elicit the list of all the folders registered by maven plugins.
well in that case, i await it with bated breath. When do you expect the first EAP of 7.0.4 to be available for download?