0

I've got a pom building a jar and packaging it into a rpm using rpm-maven-plugin. The jar is used both as a standalone application and as a dependency of other applications, so I need to deploy both artifacts to our local Nexus. I would like to deploy the jar into the standard maven-releases/maven-snapshots repositories, but the rpm I would like to deploy into a different repository in the same Nexus dedicated to just our RPMS.

My maven knowledge is fairly basic, but I'm not seeing how to do this. I hope it isn't so outside the maven philosophy that I can't, because the separate RPM repository is probably non-negotiable.

Thanks!

user3825850
  • 43
  • 1
  • 6
  • First if you have a jar which is a standalone app and being used as a dependency than I bet your jar contains things which are not used as it is used a dependency which mean you should decouple the dependencies and the standalone jar (usually separate modules).. Now coming to your question: The point is you are using the rpm-maven-plugin to build an rpm during the maven build which means all artifacts which are being produced will be deployed into the same remote repository...which means the same repository. – khmarbaise Aug 18 '18 at 15:02
  • The question is also why you have a separate repository for RPM`s ? Is this repository a yum repository or a like? Or a Maven repository ? – khmarbaise Aug 18 '18 at 15:02
  • Agreed that with a more extensive refactoring separate jars would be the right thing, but I need to migrate without breaking everything. The separate repository is a yum format repository hosted in Nexus. – user3825850 Aug 18 '18 at 16:56
  • Are you using a CI solution like Jenkins ? – khmarbaise Aug 18 '18 at 17:34
  • Yes, starting to transition everything into Jenkins – user3825850 Aug 18 '18 at 17:37
  • The point is in Maven the target for deploying artifacts is defined by the distributionManagement which means you haven only a single repository to deploy artifacts to...So you could go the way via Jenkins pipelines and stash the rpm during the build and deploy to the yum repository with a separate deploy step in a Jenkins pipeline..... – khmarbaise Aug 18 '18 at 18:14
  • Makes sense. I'll go down that path and see if I can make it work. Thank you! – user3825850 Aug 18 '18 at 21:04

1 Answers1

0

I had the same situation. My solution was to create a sub-directory/child module specifically for generating the rpms using the rpm plugin (I named the module create-rpms). In that child module I created a maven profile (also named create-rpms) with different distributionManagement elements pointing to the rpm/yum repos. To build my project I thus had 2 maven calls:

"mvn deploy" to generate/upload the jar/war, etc artifacts, "mvn deploy -P create-rpms -f create-rpms/pom.xml" to create/upload the rpms.

This approach also had the benefit of permitting Windows-based developers use regular maven to compile locally, but then use the second maven call on a Linux-based Jenkins server.

Hope this helps.

DaveR
  • 93
  • 8