How can I reduce this child pom further before generating 800 similar poms or is it impossible?

40 Views Asked by At

I will have like 800 of these child pom files/modules, so I want to get this one right and reduced as much as humanly possible before I start the other 799 child poms.

Things I would specifically like to address, things that will not change across all 800 child poms, but that I do not know how accomplish:

  • project tag attributes are long and repeated from the parent attributes.
  • model version is repeated
  • parent tag is always the same, but intelliJ gives code highlighting issues when missing
  • plugin tag: the only thing that differs is the configuration, must you really include the first 3 lines in every single child pom?
  • plugin/configuration/group tag: intelliJ gives code highlighting error when not there, but works with or without it. I would like to remove it because the parent defines it.

The Child 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>
1

There are 1 best solutions below

1
On

You can move the <build> section to the parent POM. The rest must stay.

The natural question that arises is of course: Are you really (really) sure you need 800 of these modules? Maybe your original problem has a simpler solution. It would be interesting to know the background.