As you may know, I am working on WSRP for GateIn. One problem I faced until today in my daily development was that deploying a new version of the WSRP module for testing required re-building GateIn completely, which takes quite a bit of time and has the side effect of also destroying any persisted data. This, in turn, resulted in even more wasted time spent on configuring GateIn so that I could perform my tests (configuring consumers, adding remote portlets to pages, etc).

I decided that I could make that process faster by just replacing the WSRP artifacts in an already built version of GateIn if there hadn’t been any API change in the WSRP module. I present the following script to that effect:

# extract most recent version of WSRP module: only check the first 5 lines of maven-metadata-local.xml and extract value from <version> tag
export CURRENT_WSRP=`sed -n -e '5 s/.*<version>\(.*\)<\/version>.*/\1/p' $HOME/.m2/repository/org/gatein/wsrp/wsrp-common/maven-metadata-local.xml`
echo Current WSRP version: \'$CURRENT_WSRP\'

# extract which WSRP libs are currently needed by GateIn and replace them with a fresh version from local repository
for lib in `ls $GATEIN_EAR_HOME/lib/wsrp* | sed -n 's/.*\/\(.*\)-'$CURRENT_WSRP'.jar/\1/p'`
do
	echo Copying $lib-$CURRENT_WSRP.jar to $GATEIN_EAR_HOME/lib/
	cp $HOME/.m2/repository/org/gatein/wsrp/$lib/$CURRENT_WSRP/$lib-$CURRENT_WSRP.jar $GATEIN_EAR_HOME/lib/
done

# deal with producer and admin GUI WARs separately as they are put elsewhere and without version name
for war in `ls $GATEIN_EAR_HOME/wsrp* | sed -n 's/.*\/\(.*\).war/\1/p'`
do
	echo Copying $war-$CURRENT_WSRP.war to $GATEIN_EAR_HOME/$war.war
	cp $HOME/.m2/repository/org/gatein/wsrp/$war/$CURRENT_WSRP/$war-$CURRENT_WSRP.war $GATEIN_EAR_HOME/$war.war
done

Note that this script expects that you have a $GATEIN_EAR_HOME variable set, pointing to location of your GateIn EAR. Easy enough (though I had to freshen up my sed-fu ^_^).

Actually, I can also retrieve the current version of the WSRP module by looking at the currently deployed jar files, as follows:

# extract most recent version of WSRP module from existing files
CURRENT_WSRP=`ls $GATEIN_EAR_HOME/lib/wsrp* | sed -n '1 s/.*\/.*-\([0-9]\.[0-9].[0-9]-.*-.*\).jar/\1/p'`

Might be faster that way…

I’ve made more improvements to the code and decided to put it in the SVN of the WSRP module. If you’re interested, you can take a look there.

Related posts:

  1. Code reminder: using an isolated local Maven repository I can never remember the command line option to use...
  2. GateIn 3.0.0 Beta 2 released! As some of you may know, JBoss and eXo have...
  3. GateIn 3.0 CR1 released! Where have I been? Well, mostly working towards releasing GateIn...

Related posts brought to you by Yet Another Related Posts Plugin.