English
Note that to actually build the package with tests disabled you have to specify the switch to `%mvn_build`.
It is always recommended to run all available test suites during build. It greatly improves quality of the package.
We already have package which provides `commons-io:commons-io` artifact, let's add it to the `BuildRequires`. Also disable tests for now.
BuildRequires: maven-local
BuildRequires: apache-commons-io
...
%prep
%setup -q
# Comment out following lines in %prep section
#%%pom_remove_dep :commons-io
#%%pom_remove_dep :junit
%build
# Skip tests for now, missing dependency junit:junit:4.11
%mvn_build -f
One can easily search for package which provides desired artifact. Try `dnf repoquery --whatprovides 'mvn(commons-io:commons-io)'`, or see how to xref:introduction_for_developers.adoc#querying_repositories[query repositories].
Now try to build the project one more time. The build should succeed now. Congrats, you managed to create an RPM from Maven project!
There is plenty of other things maintainer may want to do. For example, he may want to provide symbolic links to the JAR file in `%{_javadir}`.
This can be easily achieved with `%mvn_file` macro:
%prep
%setup -q
%mvn_file : %{name}/%{name} %{name}
See xref:mvn_macros.adoc#mvn_file[Alternative JAR File Names] section for more information.
Another quite common thing to do is adding aliases to Maven artifact. Try to run `rpm -qp --provides` on your locally built RPM package:
$ rpm -qp --provides simplemaven-1.0-1.fc21.noarch.rpm
mvn(com.example:simplemaven) = 1.0
simplemaven = 1.0-1.fc21
The output above tells us that the RPM package provides Maven artifact "com.example:simplemaven:1.0". Upstream may change the groupId:artifactId with any new release. And it happens. For example org.apache.commons:commons-io changed to commons-io:commons-io some time ago. It's not a big deal for package itself, but it is a huge problem for other packages that depends on that particular package. Some packages may still have dependencies on old groupId:artifactId, which is suddenly unavailable. Luckily, there is an easy way how to solve the problems like these. Package maintainer can add aliases to actually provided Maven artifact.
Add alias to Maven artifact
%mvn_alias org.example:simplemaven simplemaven:simplemaven
See xref:mvn_macros.adoc#mvn_alias[Additional Mappings] for more information on `%mvn_alias`.
Rebuild the pacakge and check `rpm -qp --provides` output again: