Sunday, June 3, 2012

Assembling a zip file via Maven

Up until this point I've been manually assembling the distro zip file. It's not really that complicated (just putting the relevant version of OpenMRS module into a zip file) but it would really be better if it were automated, and anyone could do it without having any special knowledge.

I spent some time this weekend getting this scripted. I decided to do it using maven, because it seemed like the "right" thing to do, though, or maybe because I wanted to punish myself...

I added a "distro" maven module to the kenyaemr project.

First off, since the omod files for the modules we depend on are not checked into the maven repository, I used the antrun plugin to get them. (Unfortunately we need a custom build of the metadata sharing module until Rafal releases 1.0.8, so that is commented out.)

Then I use the resources plugin to copy the compiled kenyamr.omod from ../omod/target into a folder with all the downloaded omods, and I use the assembly plugin with a custom descriptor to zip up that folder.

I also wrapped the whole thing up in a profile that is activated when you set buildDistro=true. So the whole build is run as:
mvn -DbuildDistro=true package
I'd welcome any comments on ways to improve what I did. (See the code I checked in.) I'm sure there's a much more "elegant" way to do this with maven. (At the very least I don't need the resources plugin, because I can just have the assembly plugin get that file from ../omod/target.)

No comments:

Post a Comment