Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do install the generated Maven RPM artifact to local m2 repo with the correct rpm name?

Tags:

maven

rpm

So I can use the maven RPM plugin successfully to generate the RPM artifact as expected.

I use the attached-rpm goal in a pom.xml (packaged as a pom) so that the RPM plugin installs the artifact into the local m2 repository (as it is bound to the package phase).

Problem: The RPM generated name is great and is as follows : code-module-1.0.3-SNAPSHOT20120727095507.amd64.rpm

However when maven installs this to my local repo I end up with:

code-module-rpm-1.0.3-SNAPSHOT-rpm.rpm

I lose the the full name, the architecture part of the RPM and instead Maven is appending rpm to the end of the name before the .rpm extension (the classifier that I havent defined) and is using my pom artifact id as the rpm name instead of the rpm name itself.

I tried using the build-helper plugin to point to the generated RPM in the target directory but this doesnt work as the rpm name is dynamically generated and the build-helper plugin only accepts full file name no wildcards etc.

I dont want to change the final name of the artifact as I'd be breaking maven convention.

Here is the maven output:

[INFO] Installing /home/xzcx/Development/repository/svn/source/parent-project    
/code-module-rpm/target/rpm/code-module/RPMS/amd64/code-module-1.0.3-
SNAPSHOT20120727145507.amd64.rpm to  
/home/xzcx/.m2/repository/com/xpackage/ypackage/codepackage/code-module-rpm/1.0.3-
SNAPSHOT/code-module-rpm-1.0.3-SNAPSHOT-rpm.rpm

Any thoughts please?

Update: I noted that the RPM Plugin site states that using the attached:RPM goal will allow you to build multiple RPMs say with different architectures etc...but based on the above the only way this would work would be to use classifiers as the arch bit of the RPM name doesnt get carried over to the installation on the local repo.

like image 545
user983022 Avatar asked Nov 25 '22 19:11

user983022


1 Answers

The classifier field is an important piece because often the file extension is not enough to differentiate project artifacts (e.g. foobar-1.0.jar, foobar-1.0-javadoc.jar, foobar-1.0-sources.jar all have file extension jar).

Beside the main artifact there can be additional files which are attached to the Maven project. Such attached filed can be recognized and accessed by their classifier.

http://maven.apache.org/plugins/maven-deploy-plugin/examples/deploying-with-classifiers.html

All project artifacts are associated with each other by the project.artifactId + project.version and consequently are named <artifactId>-<version>-<classifier>.<ext>.

http://maven.apache.org/plugins/maven-install-plugin/examples/installing-secondary-artifacts.html

like image 101
Leif Gruenwoldt Avatar answered Dec 24 '22 00:12

Leif Gruenwoldt