Build and release OSB projects with Maven Screen Shot 2012 11 14 at 9.27.54 PM

Build and release OSB projects with Maven

With Maven we are able to build & deploy OSB projects. The artifacts generated by Maven called snaphosts and releases can be automatically uploaded to a software repository. These versioned OSB jars can then be downloaded by the OSB Servers and deployed ( this can be a Test, Acceptance or a Production OSB Server).

In this blogpost I will guide you through this OSB build and release process, so you can do the same with or without Hudson or Jenkens

For this blogpost I will use this maven test project on github, this also contains a working OSB Eclipse Workspace which you can use for your own testing.

First step is to create a Maven POM file and put this on the Eclipse Workspace or Project level. The Workspace pom should build the whole workspace and the pom in a project only that particular OSB project.

The pom always start with the groupId & artifactId and a version.  A normal Maven build will always have an number with snapshot as version, a release will build the OSB project without snapshot and automatically will update the version to a higher number and commits the updated pom.xml with the new higher snapshot version.

For releases we need to provide a version repository and in my case I used git ( it should also work with subversion).

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 9.27.54 PM

Maven uses plugins to do all the hard work. The first plugin I define in this pom is the exec-maven-plugin. For OSB I can’t use the java plugin because I need to fork a new Java process to set the classpath and the OSB environment variables. Plus I can’t use dependencies libraries, this leads to strange OSB errors.

In the package phase of this plugin I will build the OSB project and in the deploy phase I can deploy this jar to the OSB server.

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 9.28.21 PM

In the package phase I will call the org.eclipse.equinox.launcher.Main java class and set the following params so I can build the whole workspace

org.eclipse.equinox.launcher.Main
-application com.bea.alsb.core.ConfigExport
-data ${project.basedir}/source
-configProject “OSB Configuration”
-configJar ${project.basedir}/export/${project.artifactId}-${project.version}.jar
-includeDependencies true

For only 1 or more projects I can use these params

org.eclipse.equinox.launcher.Main
-application com.bea.alsb.core.ConfigExport
-data ${project.basedir}/source
-configProject “OSB Configuration”
-configSubProjects “ReliableMessageWS”
-configJar ${project.basedir}/export/${project.artifactId}-${project.version}.jar
-includeDependencies true

For the deploy phase, Maven starts WLST with an import.py script and the following parameters

weblogic.WLST ${project.basedir}/import.py
${wls.username}
${wls.password}
${wls.server}
${osb.all.import.projects}
${project.basedir}/export/${project.artifactId}-${project.version}.jar
${osb.all.import.plan}

Cause we are not generating an normal jar, war or ear  so we need to say to maven what the path is of our generated jar. For this we can use the maven-assembly-plugin. This will use the assembly.xml

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 9.28.44 PM

Here is my assembly.xml , which does an include of the generated OSB jar to a new zip file.

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 10.11.50 PM

The last maven plugin I use is the maven-release-plugin, This will handle my releases and updates the version number in the pom.

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 9.28.56 PM

And the last part of the pom is the definition where maven will upload the snapshot and release zips. I will use Artifactory as software repository. It should also work with Nexus.

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 9.29.18 PM

Besides the pom I also need to configure the maven settings.xml file with my Artifactory server details.

Here are my weblogic environments in the settings.xml file

the default profile settings

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 10.21.15 PM

And my test profile settings which I can use for my Test deployment.

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 10.21.29 PM

 

Now we can build some OSB snapshots and releases.

 

First we need to set the maven and java environment variables.

do this by running my  osb script “. osb.sh

Next go to the right pom folder and do a build

mvn package

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 10.31.23 PM

 

mvn deploy -Dtarget-env=dev

build and deploy to the dev OSB folder

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 10.33.15 PM

 

mvn release:prepare

prepare a release

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 10.38.40 PM

 

mvn release:perform -Dtarget-env=dev -DconnectionUrl=scm:git:git@github.com:biemond/soa_tools.git

Do a release and update the version in the pom.xml

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 10.42.21 PM

 

When we look at our Artifactory software repository we will see the new 1.3.7 snapshot and release builds

Build and release OSB projects with Maven Screen Shot 2012 11 14 at 10.45.32 PM

 

 

We can use this release for the Test, Acceptance or Production OSB Server.

To automatically deploy this version I will use a Puppet manifest which uses my WLS and the Artifatory plugin. The Puppet agent will download the right artifact from the software repository and deploy this OSB project to the OSB server

Here is an example of my puppet manifest code. Off course you can create your own scripts which does the same.

 artifactory::artifact {"/tmp/${artifactId}-${version}.zip":
     ensure     => present,
     gav        => "${groupId}:${artifactId}:${version}",
     repository => "libs-release-local",
     packaging  => "zip",
     classifier => "bin", 
  }

  Exec { path      => "/usr/java/${fullJDKName}/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:",
         user      => $user,
         group     => $group,
         logoutput => false,
  }

  exec { "extract OSBAllProjects":
          command => "unzip -j -o /tmp/${artifactId}-${version}.zip *.jar -d /tmp/OSBAllProjects",
          require => Artifactory::Artifact["/tmp/${artifactId}-${version}.zip"],
  }

  # default parameters for the wlst scripts
  Wls::Wlsdeploy {
    wlHome       => $osWlHome,
    osbHome      => $osbHome,
    fullJDKName  => $jdkWls11gJDK,  
    user         => $user,
    group        => $group,
    address      => "localhost",
    wlsUser      => "weblogic",
    password     => "weblogic1",
    port         => "7001",
  }

  # deploy OSB jar to the OSB server 
  wls::wlsdeploy { "deployOSBAllProjects":
      deployType => 'osb',
      artifact   => "/tmp/OSBAllProjects/${artifactId}-${version}.jar",
      customFile => "None",
      project    => "None",
      require    => Exec["extract OSBAllProjects"],
  }

 

Here is the link to the maven test OSB workspace on github

 

Tags:, , ,

2 Comments

  1. archenroot January 12, 2015
  2. Martijn van der Kamp April 4, 2014