I have a microservices project with multiple pom layers. I have it setup to generate rpms for each service using the 'org.codehaus.mojo:rpm-maven-plugin:2.1.1' plugin. I need to set it up to generate one rpm with all of those rpms as required dependencies.
In the parent pom, I added the setting to have no source but require the two rpm packages. When I add the same settings to the parent it fails and I don't understand what I'm missing.
For example: Project Group --ProjectCommon --Project1 --Project2
So ProjectCommon, Project1, and Project2 all have their own rpms generated and deployed to our repository alongside their poms and wars. Project1 and Project2 require the common and that works. What I want to do is put the same in the parent pom so it'll build an rpm that requires the children. Then instead of having to install each rpm I can install the 1 parent rpm and it'll pull/install all the others.
I should add that there are two levels of parent poms above this one because we grouped the services into business services and data access services. Then also grouped services together from the other components like gui/etc that have their own poms. But if I get it working with the immediate parent pom then it should work for their parents as well.
Here is what I added to the parent pom:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>attach-rpm</id>
<goals>
<goal>attached-rpm</goal>
</goals>
<configuration>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
<group>${rpm.group}</group>
<requires>
<require>project1 > ${project.version}</require>
<require>project2 > ${project.version}</require>
</requires>
<mappings>
<mapping>
<directory>${rpm.directory}</directory>
<filemode>$rpm.permissions}</filemode>
<username>${rpm.user}</username>
<groupname>${rpm.usergroup}</groupname>
</mapping>
</mappings>
</configuration>
</execution>
</executions>
</plugin>
Here is one of the children:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>rpm-maven-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<id>attach-rpm</id>
<goals>
<goal>attached-rpm</goal>
</goals>
<configuration>
<sourceEncoding>${project.build.sourceEncoding}</sourceEncoding>
<group>${rpm.group}</group>
<requires>
<require>weblogic</require>
<require>project1 > ${project.version}</require>
</requires>
<mappings>
<mapping>
<directory>${rpm.directory}/config</directory>
<filemode>$rpm.permissions}</filemode>
<username>${rpm.user}</username>
<groupname>${rpm.usergroup}</groupname>
<sources>
<source>
<location>${project.build.directory}/${project.build.finalName}.${project.packaging}</location>
</source>
</sources>
</mapping>
</mappings>
</configuration>
</execution>
</executions>
</plugin>
Here is the error:
[ERROR] Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1.1:attached-rpm (attach-rpm) on project project-business-parent: RPM build execution returned: '1' executing '/bin/sh -c cd '/workspace/project-pom/services/business/target/rpm/project-business-parent/SPECS' && 'rpmbuild' '-bb' '--target' 'noarch-pc-linux' '--buildroot' '/workspace/project-pom/services/business/target/rpm/project-business-parent/buildroot' '--define' '_topdir /workspace/project-pom/services/business/target/rpm/project-business-parent' 'project-business-parent.spec'' -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:rpm-maven-plugin:2.1.1:attached-rpm (attach-rpm) on project project-business-parent: RPM build execution returned: '1' executing '/bin/sh -c cd '/workspace/project-pom/services/business/target/rpm/project-business-parent/SPECS' && 'rpmbuild' '-bb' '--target' 'noarch-pc-linux' '--buildroot' '/workspace/project-pom/services/business/target/rpm/project-business-parent/buildroot' '--define' '_topdir /workspace/project-pom/services/business/target/rpm/project-business-parent' 'project-business-parent.spec'' at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:216) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84) at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59) at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183) at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161) at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317) at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152) at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555) at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214) at org.apache.maven.cli.MavenCli.main(MavenCli.java:158) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) Caused by: org.apache.maven.plugin.MojoExecutionException: RPM build execution returned: '1' executing '/bin/sh -c cd '/workspace/project-pom/services/business/target/rpm/project-business-parent/SPECS' && 'rpmbuild' '-bb' '--target' 'noarch-pc-linux' '--buildroot' '/workspace/project-pom/services/business/target/rpm/project-business-parent/buildroot' '--define' '_topdir /workspace/project-pom/services/business/target/rpm/project-business-parent' 'project-business-parent.spec'' at org.codehaus.mojo.rpm.RPMHelper.buildPackage(RPMHelper.java:149) at org.codehaus.mojo.rpm.AbstractRPMMojo.execute(AbstractRPMMojo.java:633) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 19 more
Edit: Added more verbose error with "mvn -X install". Thank you jdevelop!