Maven dependency mapping macros
Thing I haven’t blogged about yet but it’s pretty important: We have new macros for maven depmaps in Fedora. In the past when you wanted to map certain groupId:artifactId to a file in _javadir, you had to include snippet like this in your spec:
%add_to_maven_depmap com.google.guava guava 05 JPP guava
%add_to_maven_depmap com.google.collections google-collections 05 JPP guava
This tells our maven that com:google:guava:guava and com.google.collections:google-collections can be found in one of the repositories as JPP/guava.jar. It meant you had to know the groupId:artifactId and other information, plus it was extremely easy to make a mistake here causing all sorts of trouble. Current code doing the same thing:
%add_maven_depmap JPP-guava.pom guava.jar -a "com.google.collections:google-collections"
We parse the pom file and get groupId:artifactId from it, plus we do additional sanity checks such as:
- naming of pom and jar file have to be consistent
- jar file has to exist if packaging type is not pom
If you need additional mappings you can easily add them. There are few other options for this new macro useful in certain situations.
Maven test deps skipping
Long story short: When you use -Dmaven.test.skip=true in Fedora packages you no longer need to patch those test dependencies out of pom.xml.
We’ve had Apache Maven in Fedora for quite some time and packaging using Maven has been getting easier over time due to small tweaks to our packaging macros and guidelines changes. However there has been one problem that’s been bugging all Java packagers and was especially confusing for those starting to package software built with Maven. The problem is that Maven creates a tree of dependencies before it starts building the project, but it includes test dependencies even when tests are being skipped.
Skipping tests is sometimes necessary due to problems with koji, or dependencies and up until now we had to either patch those tests dependencies from pom.xml or use custom dependency mappings (ugly concept in itself).
Last week I decided it’s about time someone did something about this, so I dug in the Maven code and created a solution (more of a hack really) that is already included in Fedora. If you want the gory details, you can read the patch itself (I advise against it). I’ll try to make the patch work properly so that it can be included in mainstream code.
I can just hope that packagers will find these changes helpful, but general feedback has been positive.