Maven项目可以有多个父母吗? [英] Can maven projects have multiple parents?
问题描述
我想要做的更干净一点, base-pom,然后是java-base-pom和flex-base-pom。但是,在一个兼有flex部分和java部分的multimodule中,这是如何工作的?
我们在我们自己的应用程序中使用了以下结构的插件:我的插件客户端(flex)
/ li>
$ b
解决方案一个项目可以只有一个父(不同于C ++中的多重继承),但是这个父母可以是更大父母等级的一部分。正如其他人所指出的那样,您可以这样做:
base-pom /
| - flex-base -pom
| | - my-plugin-client
| | ` - pom.xml
| ` - pom.xml
| - java-base-pom
| | - 我的插件服务器
| | ` - pom.xml
| ` - pom.xml
` - pom.xml
也就是说,我注意到你写的是你的实际问题是例如,
flex项目继承javadoc和pmd的配置,例如他们不想要的配置。
您应该使用 pluginManagement
元素来避免这种情况:
$ b
pluginManagement strong>是沿着插件看到的元素。插件管理包含插件元素的方式非常相似,除了不是为这个特定的项目构建配置插件信息,而是为了配置从这个插件继承的项目构建。但是,这只能配置实际上在子节点的插件元素中引用的插件。因此,在父pom中,将插件配置在
pluginManagement
(例如javadoc和pmd),并在所需子元素的插件
元素中引用它们(仅在我的插件中这里的服务器)。这将解决您当前的问题。We have java and flex projects at work. We currently have 1 base pom that contains the configurations we want to use for both projects. Problem with this is: flex projects inherit configuration for javadoc and pmd for example, which they do not want.
I want to do this a bit more clean and have a real base-pom and then a java-base-pom and a flex-base-pom. But how does this work in a multimodule that has both a flex part and a java part?
We have plugins to our own application where we use the following structure:
- my-plugin
- my-plugin-client (flex)
- my-plugin-server (java)
The my-plugin just contains a pom.xml with section. I would use the my-plugin pom.xml as a parent to both, but then I cannot also use the java base-pom or the flex base-pom also as parent. What would be the best approarch for this?
解决方案A project can have only one parent (unlike multiple inheritance in C++) but this parent can be part of a bigger parent hierarchy. As pointed out by others, you could thus have something like this:
base-pom/ |-- flex-base-pom | |-- my-plugin-client | | `-- pom.xml | `-- pom.xml |-- java-base-pom | |-- my-plugin-server | | `-- pom.xml | `-- pom.xml `-- pom.xmlThat said, I noticed you wrote that your actual problem is that:
flex projects inherit configuration for javadoc and pmd for example, which they do not want.
You should use the
pluginManagement
element to avoid this situation:pluginManagement is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one. However, this only configures plugins that are actually referenced within the plugins element in the children. The children have every right to override pluginManagement definitions.
So, in the parent pom, configure your plugins in
pluginManagement
(javadoc and pmd for example), and reference them within theplugins
element in the desired children (only in my-plugin-server here). This would solve your current issue.这篇关于Maven项目可以有多个父母吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!