如何在生成 800 个类似的 pom 之前进一步减少这个子 pom 或者是不可能的?

问题描述

我将拥有 800 个这样的子 pom 文件/模块,所以我想在开始其他 799 个子 pom 之前正确处理并尽可能减少。

我特别想解决的事情,在所有 800 个子 poms 中都不会改变的事情,但我不知道如何完成:

  • 项目标签属性很长并且与父属性重复。
  • 模型版本重复
  • 标签总是相同的,但 intelliJ 会在缺失时出现代码高亮问题
  • plugin 标签:唯一不同的是配置,你真的必须在每个子 pom 中包含前 3 行吗?
  • plugin/configuration/group 标签:intelliJ 在不存在时会给出代码高亮错误,但不管有没有它都可以工作。我想删除它,因为它是父级定义的。

儿童 Pom:

    <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.company.software</groupId>
    <artifactId>SOMEHOSTNAME</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>rpm</packaging>

    <parent>
        <groupId>org.company.software</groupId>
        <artifactId>host</artifactId>
        <version>1.0-SNAPSHOT</version>
    </parent>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>rpm-maven-plugin</artifactId>
                <version>2.2.0</version>
                <extensions>true</extensions>
                <configuration>
                    <group/>
                    <mappings combine.children="append">
                        <mapping>
                            <directory>/etc/opt/software-${version}/gateway</directory>
                            <sources>
                                <source>
                                    <location>src/main/resources/config</location>
                                </source>
                            </sources>
                        </mapping>
                    </mappings>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

解决方法

您可以将 <build> 部分移动到父 POM。其余的必须留下。

自然出现的问题当然是:您真的(真的)确定需要 800 个这样的模块吗?也许你原来的问题有一个更简单的解决方案。了解背景会很有趣。