0

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>
gunslingor
  • 1,358
  • 12
  • 34

1 Answers1

0

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.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • We make ~100 apps as RPMs, we also make meta RPMs for installing configurations of the OS/apps. We have about 800 servers, someone had the idea to generate an RPM named after each hostname, the idea being you install 1 RPM and you have your server. Obviously there is common software & configs for all gateway svrs, historian svrs, terminals etc so that is handled via a gateway-common.rpm that will be 'required' in the child pom for example. So these 800 poms are host specific software and configs that also list requires for common packages. Make sense? Better Solution? – gunslingor Jun 03 '21 at 09:38