能否在非父POM中指定插件管理?

3

我正在为一个多模块项目设置maven插件管理。我想要使用 pluginManagement 部分而不继承(在parent pom中指定插件版本)。我的项目结构大致如下:

base_project
   -- pom.xml
   -- project-bom
        -- pom.xml
   -- project-a
        -- pom.xml

在根pom.xml文件中,我仅有两个模块:
<modules>
    <module>project-bom</module>
    <module>project-a</module>
</modules>

在项目的 pom.xml 文件中,我指定了dependencyManagementpluginManagement部分,以使用我想要的依赖项和插件版本。
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.some</groupId>
            <artifactId>dependency</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.some</groupId>
                <artifactId>plugin</artifactId>
                <version>1.0.0</version>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

在project-a的pom.xml文件中,我导入了project-bom的pom文件,并使用了其依赖和插件。
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.project</groupId>
            <artifactId>project-bom</artifactId>
            <version>1.0-SNAPSHOT</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>
    <dependency>
        <groupId>org.some</groupId>
        <artifactId>dependency</artifactId>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.some</groupId>
            <artifactId>plugin</artifactId>
        </plugin>
    </plugins>
</build>

我可以使用项目BOM中指定的依赖版本,但对于插件则不行。它会给出以下警告:

[WARNING] Some problems were encountered while building the effective model for <...>
[WARNING] 'build.plugins.plugin.version' for <org.some:plugin> is missing. 

能否在非父POM文件中指定插件管理并导入它?


1
这个回答解决了您的问题吗?在类似于BOM的东西中集中插件版本? - Ilya Serbis
1个回答

7

目前还无法实现此功能。 Maven 项目中有一个 打开的工单 来添加此功能。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接