Mavenize your JBoss BRMS projects

Screen Shot 2012-07-13 at 10.21.49 AMOne of the nicest features of the newer JBoss Enterprise Application Platform 6 (EAP6) is that is supplies your organization with the Maven artifacts in a separate download so that you can populate your internal maven repository.

This is what I wanted to achieve with JBoss Business Rules Management System (BRMS) too, so we put together a short script to extract these from the product and populate your default maven repository.

Hope you enjoy it!

UPDATE (15 Feb 2013): see comments below, have led to improved script thanks to Maurice de Chateau, replaced original below.

#!/bin/bash
SRC_DIR=./installs
BRMS=brms-p-5.3.1.GA-deployable-ee6.zip
VERSION=5.3.1.BRMS

command -v mvn -q >/dev/null 2>&1 || { echo >&2 "Maven is required but not installed yet... aborting."; exit 1; }

installPom() {
    mvn -q install:install-file -Dfile=../$SRC_DIR/$2-$VERSION.pom.xml -DgroupId=$1 -DartifactId=$2 -Dversion=$VERSION -Dpackaging=pom;
}

installBinary() {
    unzip -q $2-$VERSION.jar META-INF/maven/$1/$2/pom.xml;
    mvn -q install:install-file -DpomFile=./META-INF/maven/$1/$2/pom.xml -Dfile=$2-$VERSION.jar -DgroupId=$1 -DartifactId=$2 -Dversion=$VERSION -Dpackaging=jar;
}

echo
echo Installing the BRMS binaries into the Maven repository...
echo

unzip -q $SRC_DIR/$BRMS jboss-brms-engine.zip
unzip -q jboss-brms-engine.zip binaries/*
unzip -q $SRC_DIR/$BRMS jboss-jbpm-engine.zip
unzip -q -o -d ./binaries jboss-jbpm-engine.zip
cd binaries

echo Installing parent POMs...
echo
installPom org.drools droolsjbpm-parent
installPom org.drools droolsjbpm-knowledge
installPom org.drools drools-multiproject
installPom org.drools droolsjbpm-tools
installPom org.drools droolsjbpm-integration
installPom org.drools guvnor
installPom org.jbpm jbpm

echo Installing Drools binaries...
echo
# droolsjbpm-knowledge
installBinary org.drools knowledge-api
# drools-multiproject
installBinary org.drools drools-core
installBinary org.drools drools-compiler
installBinary org.drools drools-jsr94
installBinary org.drools drools-verifier
installBinary org.drools drools-persistence-jpa
installBinary org.drools drools-templates
installBinary org.drools drools-decisiontables
# droolsjbpm-tools
installBinary org.drools drools-ant
# droolsjbpm-integration
installBinary org.drools drools-camel
# guvnor
installBinary org.drools droolsjbpm-ide-common

echo Installing jBPM binaries...
echo
installBinary org.jbpm jbpm-flow
installBinary org.jbpm jbpm-flow-builder
installBinary org.jbpm jbpm-persistence-jpa
installBinary org.jbpm jbpm-bam
installBinary org.jbpm jbpm-bpmn2
installBinary org.jbpm jbpm-workitems
installBinary org.jbpm jbpm-human-task
installBinary org.jbpm jbpm-test

cd ..
rm -rf binaries
rm jboss-brms-engine.zip
rm jboss-jbpm-engine.zip

echo Installation of binaries "for" BRMS $VERSION complete.
echo

About Eric D. Schabell

Eric D. Schabell is the JBoss technology evangelist for Integration and BPM products at Red Hat. He is responsible for various outbound technical aspects of promoting JBoss Enterprise Middleware integration products and services. He has been working within software development since 1998 for many different enterprises. He helps out in the JBoss jBPM project focusing as lead on the jBPM Migration project. He has authored the e-book 'OpenShift Primer - get your code into the Cloud' as found on Amazon, iTunes, etc. Follow this blog at http://www.schabell.org.

View all posts by Eric D. Schabell

6 Comments on “Mavenize your JBoss BRMS projects”

  1. ge0ffrey Says:

    Interesting feature to have :)
    Even the .org distribution could use this feature (which would make it easier to get included in the productized version by default).
    If you want to pull request, just add a fixed version of this script here:
    https://github.com/droolsjbpm/drools/tree/master/drools-distribution/src/main/assembly/scripts
    and adjust the assembly accordingly:
    https://github.com/droolsjbpm/drools/blob/master/drools-distribution/src/main/assembly/assembly-drools.xml

    Problems with the current script (feedback):
    - The real high-quality pom’s aren’t used. Instead, new dummy poms are created, without dependencies. So depending on drools-compiler won’t transitively depend on drools-core or mvel or whatever else is needed to run.
    - The version 5.3.0.BRMS is problematic: by lexicographic comparison, it sits between 5.3.0.Beta2 and 5.3.0.Final. That messes with conflict resolution.
    IIRC, there’s a wolf convention of using something like 5.3.0.Final-redhat1.
    - The installing order is wrong: Installing drools-core before knowledge-api should not work, because drools-core should depend on knowledge-api.

    Reply

    • Maurice de Chateau (@mauricedchateau) Says:

      Hi Geoffrey,

      You’re making a couple of valid points there. The initial setup was simply a means to an end: have the jars from the BRMS product available for use in a maven project. And the script above accomplishes just that, and nothing more.

      From the three problems you’re pointing out, two can be mended relatively easily:
      - Using the POM files that are included in the jars themselves, the appropriate dependencies will be available. As the parent POM files are not included in the BRMS product jars, adequate ones need to be constructed (e.g. from the released versions).
      - The installing order can be corrected to match the module order in the respective parent POM file.
      For one of the projects I’m helping Eric out with this is what I’ve done; if you could find the time to have a look at it and maybe give some further feedback that would be great:
      https://github.com/eschabell/jboss-brms-performance-testing-framework/blob/master/mavenize.sh

      The version naming issue is something different altogether. The version naming scheme you’re mentioning (as also described inside some of the Drools and jBPM parent POM files) is afaik applicable to the community releases. The version used here is the BRMS product version – which coincidentally happens to resemble the Drools version used in it, but it’s not derived from it. In fact, the jBPM version used is 5.2, less resemblance there already.
      So while I’m certainly not sure when such product versions are used locally only there won’t be any problems, there are none I’ve encountered so far.

      Thanks for the feedback!

      Reply

      • ge0ffrey Says:

        Great stuff Maurice :) @Eric can you replace your original script with Maurice’s script? At least it fixes 2 of the issues.

        As for the version issue: officially the BRMS version is 5.3.0.BRMS, so it makes sense that you use that (even though it’s wrong). But for 6, the official version with use a lexographically correct version number, for example 6.0.0.Final-redhat-1, which will fix that last issue.

      • Eric D. Schabell Says:

        Thanks to Maurice for the new script, I have updated the post above. Open exchange of idea at work. ;)

  2. Miguel Reyes (@mindbts) Says:

    The script worked beautifully to insert the JARs.

    Some comments:
    1. I ended up removing the “echo Installing parent POMs…” section. The poms are not found in the brms ZIP distribution, so the script would throw errors in the form or:

    Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.3.1:install-file (default-cli) on project standalone-pom: Error installing artifact ‘org.jbpm:jbpm:pom’: Failed to install artifact org.jbpm:jbpm:pom:5.3.1.BRMS: /tmp/installs/jbpm-5.3.1.BRMS.pom.xml (No such file or directory)

    2. I added an echo to installBinary( ) because I wanted to see the file being installed:
    echo “–> Installing jar:” $1.$2-$VERSION.jar

    3. These JARs are not inserted and I believe will be needed at some point in when compiling drools code:
    - mvel2-2.1.3.Final.jar
    - antlr-runtime-3.3.jar
    - ecj-3.5.1.jar

    Thanks for the script!

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 106 other followers

%d bloggers like this: