Skip to main content

Building IPS package from Maven

Posted by kohsuke on June 27, 2008 at 11:15 PM PDT


I blogged about my experience about creating an IPS package several days ago. Since my motivation for this was to package Hudson, which is built by Maven, I wanted to integrate the package creation process into a Maven build.


Toward this end, I packaged IPS as a Maven artifact, then I used that to write maven-makepkgs-plugin. This plugin assumes a working Python 2.4 on your system, but otherwise it can fully automate the IPS packagin creation and has no platform specific pieces.


You'd be writing a src/proto.py like the following, which describes the package and files that are in it. The script gets several key parameters, like version, from Maven:

# definition of the IPS package.
# see https://updatecenter2.dev.java.net/maven-makepkgs-plugin/ for more about this

import builder;

# IPS can't do SNAPSHOT
version = builder.props['version']
if version.endswith("-SNAPSHOT"):
    version = version[:-9];

pkg = builder.build_pkg(name="hudson", version=version+",0-0")
pkg.update({
    "attributes"    : {
        "pkg.summary" : "Hudson",
        "pkg.description" : "Extensible continuous integration system",
    }
})


pkg.addfile("/usr/local/bin/hudson.war",{"file":"./target/hudson.war"})
pkg.addfile("/var/svc/manifest/application/hudson.xml",{"file":"../ips/hudson.xml"})
# this is the Hudson home directory
pkg.mkdirs("/var/lib/hudson")

This will be then hooked into your POM. In my case, I didn't want to create a package for every build and only during the release, so I separated this out into a profile, which then gets activated during the release through maven-release-plugin configuration. But the snippet below shows how to run it.

>    
     
      ips
     
       
         
            org.jvnet.updatecenter2
            maven-makepkgs-plugin
           
             
               
                  package
               

             

           

         

       

     

   

By default, the plugin creates an IPS package and put that into a .tgz file. This will be attached to the build with the .ipstgz extension, and deployed to the repository. So one idea that I have is to write a separate program, which reads Nexus repository index and pick up all .ipstgz file, and create an IPS repository. In this way, we can reuse the existing Maven publishing mechanism (which is much better than that of IPS today) to manage an IPS repository.

See the plugin website for more details. If anyone is interested in helping this effort, please drop us a note.

Related Topics >>

Comments

Kohsuke, Thanks for putting this together. This is a great idea and a useful tool. I'm still working on understanding IPS better myself, at the moment, but I'll soon be looking for a good way to deploy my Maven-built projects to Solaris. So I'll definitely be back to check this out more.