gpt4 book ai didi

Maven - 父 Pom - 子继承

转载 作者:行者123 更新时间:2023-12-03 12:05:21 25 4
gpt4 key购买 nike

我正在尝试进行 maven 父 pom 设置,我不必在我的子 pom 中声明任何插件信息,所有内容都取自父 pom。

我基本上让它工作,我已经将所有带有配置的插件放入父 pom.xml 中。然后在子 poms 中,我仍然必须声明插件,但没有版本和配置信息。

我根本不想在 child 中声明插件。通过这种方式,我可以向我的父 pom 添加新功能(例如 pmd、freebugs 等),并且我的所有项目现在都可以使用它们。我怎样才能做到这一点?

父 Pom

<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.0</version>
<inherited>true</inherited>
<configuration>
<providerImplementations>
<cvs>cvs_native</cvs>
</providerImplementations>
<systemProperties>
<property>
<name>maven.scm.perforce.clientspec.name</name>
<value>${perforceClientSpec}</value>
</property>
</systemProperties>
</configuration>
</plugin>

Child Pom 仍然需要这个,但如果我可以避免的话,我不想这样做:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
</plugin>

最佳答案

<pluginManagement>部分旨在配置从这个继承的项目构建。但是,这只会配置 的插件。实际上在子项的 plugins 元素中引用(因此您必须按照您的指示明确指定它们)。查看更多 here .

如果您想避免这种情况,可以将此信息放入<build>像这样的部分:

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.0</version>
<configuration>
<...>
</configuration>
<executions>
<...>
</executions>
</plugin>
</plugins>
</build>

关于Maven - 父 Pom - 子继承,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9477789/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com