Saturday, April 4, 2020

An introduction to OSB 12c Maven plug-ins

Recently I started exploring the possibilities with the OSB Maven plug-in that is provided with the 12c product. At my current client we are slowly moving towards a more CI/CD environment and using a Maven plug-in to package OSB projects and resources is an important step in this. When the Jenkins pipeline kicks off, one of the stages is to package the OSB project using this plug-in. But I was surprised by how limited configuration settings are.

The plug-in can be found in %ORACLE_HOME%\osb\plugins\maven\com\oracle\servicebus\plugin\oracle-servicebus-plugin\
We are currently on version:

<groupId>com.oracle.servicebus.plugin</groupId>
<artifactId>oracle-servicebus-plugin</artifactId>
<version>12.2.1-3-0</version>


The accepted parameters for packaging projects are as follows:

<parameters>
 <parameter>
  <name>excludes</name>
  <type>java.lang.String[]</type>
  <required>false</required>
  <editable>true</editable>
  <description>Specifies a list of files to exclude from the project. Use this to exclude things like versioning system files.</description>
 </parameter>
 <parameter>
  <name>oracleHome</name>
  <type>java.io.File</type>
  <required>true</required>
  <editable>true</editable>
  <description>Specifies the location to the Oracle Fusion Middleware home directory. You can specify this value as an expression.</description>
 </parameter>
  <parameter>
  <name>project</name>
  <type>org.apache.maven.project.MavenProject</type>
  <required>true</required>
  <editable>false</editable>
  <description></description>
 </parameter>
 <parameter>
  <name>system</name>
  <type>boolean</type>
  <required>false</required>
  <editable>true</editable>
  <description>Specifies whether the resources being packaged are system resources, which are shared by multiple projects within a Service Bus application. The default value is false. You must set this value to true when packaging system resources.</description>
 </parameter>
</parameters>


An example of usage (this piece of code is inserted in the project's pom.xml file):

<plugin>
   <groupId>com.oracle.servicebus.plugin</groupId>
   <artifactId>oracle-servicebus-plugin</artifactId>
   <version>12.2.1-3-0</version>
   <extensions>true</extensions>
   <configuration>
      <oracleHome>${oracle_home_12c}</oracleHome>   
      <project>${project.artifactId}</project>
      <system>false</system>
      <excludes>
         <exclude>*/.idea/**</exclude>
         <exclude>*/Test/**</exclude>
         <exclude>*/properties/**</exclude>
         <exclude>*/Version/**</exclude>
      </excludes>
   </configuration>
</plugin>


The configuration settings are used by the plug-in to create a ConfigJarSettings file. It determines what resources are included and excluded in the package. The plug-in uses the offline export tool (configuration jar) to package Service Bus resources.


In this version of the plug-in I'm missing the ability to control whether projects are exported on project or resource level. The latter is important for specific OSB projects where you only need an incremental to be installed and not an entire project to be overwritten, for example DVM's where values could differ between environments. If this is your requirement in version 12.2.1-3-0 you might want to take a look over here: https://whitehorsesblogarchive.wordpress.com/tag/osb/ On their Bitbucket you will find a customized plug-in which allows you to build projects on resource level using Maven.

Or you could consider upgrading to:

<groupId>com.oracle.servicebus.plugin</groupId>
<artifactId>oracle-servicebus-plugin</artifactId>
<version>12.2.1-4-0</version>


This version allows you to control the exportLevel and which resources need to be in- or excluded. The parameters are as follows:

<parameters>
 <parameter>
  <name>excludes</name>
  <type>java.lang.String[]</type>
  <required>false</required>
  <editable>true</editable>
  <description>Specifies a list of files to exclude from the project. Use this to exclude things like versioning system files.</description>
 </parameter>
 <parameter>
  <name>exportLevel</name>
  <type>java.lang.String</type>
  <required>false</required>
  <editable>true</editable>
  <description>Specifies the export level either RESOURCE or PROJECT. You can specify this value as an expression.</description>
 </parameter>
 <parameter>
  <name>includes</name>
  <type>java.lang.String[]</type>
  <required>false</required>
  <editable>true</editable>
  <description>Specifies a list of files to include from the project. Use this to include things like versioning system files.</description>
 </parameter>
 parameter>
  <name>oracleHome</name>
  <type>java.io.File</type>
  <required>true</required>
  <editable>true</editable>
  <description>Specifies the location to the Oracle Fusion Middleware home directory. You can specify this value as an expression.</description>
 </parameter>
 <parameter>
  <name>project</name>
  <type>org.apache.maven.project.MavenProject</type>
  <required>true</required>
  <editable>false</editable>
  <description></description>
 </parameter>
 <parameter>
  <name>resources</name>
  <type>java.io.File</type>
  <required>false</required>
  <editable>true</editable>
  <description>Specify the resources, which points towards a configuration file. This can be used to specify which files need to be included and excluded.</description>
 </parameter>
 <parameter>
  <name>skipAll</name>
  <type>boolean</type>
  <required>false</required>
  <editable>true</editable>
  <description>Setting skipAll as true will skip depolyment of sbar.</description>
 </parameter>
 <parameter>
  <name>system</name>
  <type>boolean</type>
  <required>false</required>
  <editable>true</editable>
  <description>Specifies whether the resources being packaged are system resources, which are shared by multiple projects within a Service Bus application. The default value is false. You must set this value to true when packaging system resources.</description>
 </parameter>
</parameters>


More information regarding the plug-in can be found on the following Oracle page: https://docs.oracle.com/en/middleware/soa-suite/service-bus/12.2.1.4/develop/using-oracle-service-bus-development-maven-plug1.html#GUID-F3308599-234C-48FF-B74B-4F479100ABA0