我从 wsdl 文件生成 Java 源代码。这些源不受版本控制(但 wsdl 是)。我们使用maven中的cxf-codegen-plugin,生成的类在<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
中生成.
这在 Maven 中一切正常。
我必须将此目录定义为 Intelij Idea 中的附加源目录。 ( target
通常被排除在外)。
但是每次我将maven项目重新导入InteliJ Idea(由于pom变化),我必须手动编辑Idea中的项目结构并重新定义添加源目录。
有什么方法可以在 maven 中定义这个额外的源目录,以便 Idea 在重新加载时选择它,或者告诉 Idea 不要忘记手动源目录定义?
最佳答案
此案例在 IntelliJ IDEA Maven FAQ 中有所描述。 , 生成源 部分:
Specify the directory of your source root when you reimport a project.
You can select one of the following options:
Detect automatically This is a default option. When you select this option, IntelliJ IDEA automatically detects the location of the generated sources. IntelliJ IDEA also detects which directory to mark as a source root. However, IntelliJ IDEA searches for the generated sources only in target/generated-sources and target/generated-sources/* directories.
target/generated-sources This option enables you to mark the directory as source root manually.
subdirectories of "target/generated-sources" This option enables you to mark a subdirectory as a source root manually.
Don't detect This option lets you skip the detection process.
关于maven - 在 maven 中定义额外的源目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10735380/