icon-arrow icon-check icon-mail icon-phone icon-facebook icon-linkedin icon-youtube icon-twitter icon-cheveron icon-download icon-instagram play close close icon-arrow-uturn icon-calendar icon-clock icon-search icon-chevron-process icon-skills icon-knowledge icon-kite icon-education icon-languages icon-tools icon-experience icon-coffee-cup
Werken bij Integration & Application Talents
Blog 12/01/2017

Building OSB 12c releases on resource level using Maven

Building

Whitehorses
Mike Heeren /
Integratie expert

A while ago I published a Whitebook (in Dutch) about building OSB 12c releases on resource level using Maven. In the Whitebook, you could read which functionality we were missing in the regular Oracle Service Bus plugin for Maven and how we were able to create this functionality using a custom Maven plugin.

I have added the code of this custom Maven plugin to the following public repository: https://bitbucket.org/whitehorsesbv/servicebusplugin

Used settings

The custom Maven plugin has been developed and tested on multiple environments, so we can confirm that the Maven plugin is working if you are using the following version(s):

Application Version
Java 1.7.0_79, 1.8.0_101
Maven 3.3.9
Oracle Service Bus 12.1.3, 12.2.1

Installing the custom Maven plugin

First start to install the custom Maven plugin to your local Maven repository. To do this, you can download both the JAR and the POM file from the download page of the repository. After you have downloaded both files, you can execute the following commands to install it to you local Maven repository:

mvn install:install-file -Dfile=servicebus-plugin-1.0.jar -DgroupId=nl.whitehorses.servicebus -DartifactId=servicebus-plugin -Dversion=1.0 -Dpackaging=jar
mvn install:install-file -Dfile=servicebus-plugin-1.0.pom -DgroupId=nl.whitehorses.servicebus -DartifactId=servicebus-plugin -Dversion=1.0 -Dpackaging=pom

 

Building a Service Bus project on resource level

Now that the custom Maven plugin is available in the Maven repository, we are able to build OSB projects using this plugin instead of the default Oracle plugin. To do so, open the pom.xml file in the OSB project directory. By default, the pom.xml file will look something like the below example:

pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
	<modelVersion>4.0.0</modelVersion> 
	<parent> 
		<groupId>com.oracle.servicebus</groupId> 
		<artifactId>sbar-project-common</artifactId> 
		<version>12.1.3-0-0</version> 
	</parent> 
	<groupId>nl.whitehorses</groupId> 
	<artifactId>Employee</artifactId> 
	<version>1.0-SNAPSHOT</version> 
	<packaging>sbar</packaging> 
	<description/> 
</project>

If we package the project into an archive using the above pom.xml file by executing mvn package via the command line, we will get an archive that can be used to deploy the OSB project on project level to the OSB. The build archive can be found in the .data/maven folder within the project directory.

If we change the value of the pom.xml file to the below example, and we package the project the project using the same command, we will get an archive  which can be used to deploy on resource level via the OSB. In the below example the following files will be added to the archive:

  • All files within the Business directory.
  • All files within the Pipeline directory, except UpdateEmployee.pipeline.

pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
	<modelVersion>4.0.0</modelVersion> 
	<groupId>nl.whitehorses</groupId> 
	<artifactId>Employee</artifactId> 
	<version>1.0-SNAPSHOT</version> 
	<packaging>sbar</packaging> 
	<build> 
		<directory>${project.basedir}/.data/maven</directory> 
		<sourceDirectory>${project.basedir}</sourceDirectory> 
		<resources> 
			<resource> 
				<directory>${project.basedir}</directory> 
			</resource> 
		</resources> 
		<plugins> 
			<plugin> 
				<groupId>nl.whitehorses.servicebus</groupId> 
				<artifactId>servicebus-plugin</artifactId> 
				<version>1.0</version> 
				<extensions>true</extensions> 
				<configuration> 
					<!-- Configure the Oracle Home directory --> 
					<oracleHome>C:OracleMiddleware1221Oracle_Home</oracleHome> 
					<!-- Specify whether this is a system release --> 
					<system>false</system> 
					<!-- Configure the export level of the release, possible values are PROJECT and RESOURCE --> 
					<exportLevel>RESOURCE</exportLevel> 
					<!-- Optional parameter to specify which of the resources should be included into the archive --> 
					<includes> 
						<include>**/Business/*</include> 
						<include>**/Pipeline/*</include> 
					</includes> 
					<!-- Optional parameter to specify which of the resources should be excluded from the archive --> 
					<excludes> 
						<exclude>**/Pipeline/UpdateEmployee.pipeline</exclude> 
					</excludes> 
				</configuration> 
			</plugin> 
		</plugins> 
	</build> 
</project>

Instead of using the includes and excludes tags, we can also add a resourcestag to the pom.xml file, which points towards a configuration file. This can be used to specify which files need to be included and excluded. For example, the below files will result in exactly the same archive as we would get using the includes and excludes tags: 

pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
	<modelVersion>4.0.0</modelVersion> 
	<groupId>nl.whitehorses</groupId> 
	<artifactId>Employee</artifactId> 
	<version>1.0-SNAPSHOT</version> 
	<packaging>sbar</packaging> 
	<build> 
		<directory>${project.basedir}/.data/maven</directory> 
		<sourceDirectory>${project.basedir}</sourceDirectory> 
		<resources> 
			<resource> 
				<directory>${project.basedir}</directory> 
			</resource> 
		</resources> 
		<plugins> 
			<plugin> 
				<groupId>nl.whitehorses.servicebus</groupId> 
				<artifactId>servicebus-plugin</artifactId> 
				<version>1.0</version> 
				<extensions>true</extensions> 
				<configuration> 
					<!-- Configure the Oracle Home directory --> 
					<oracleHome>C:OracleMiddleware1221Oracle_Home</oracleHome> 
					<!-- Specify whether this is a system release --> 
					<system>false</system> 
					<!-- Configure the export level of the release, possible values are PROJECT and RESOURCE --> 
					<exportLevel>RESOURCE</exportLevel> 
					<!-- Optional parameter to specify which of the resources should be included into and excluded from the archive --> 
					<resources>C:JDevelopermyworkIntegration & Application TalentsEmployeearchiveResources.xml</resources> 
				</configuration> 
			</plugin> 
		</plugins> 
	</build> 
</project>

archiveResources.xml

<?xml version="1.0" encoding="UTF-8"?> 
<resources> 
	<!-- Optional parameter to specify which of the resources should be included into the archive --> 
	<includes> 
		<include>**/Business/*</include> 
		<include>**/Pipeline/*</include> 
	</includes> 
	<!-- Optional parameter to specify which of the resources should be excluded from the archive --> 
	<excludes> 
		<exclude>**/Pipeline/UpdateEmployee.pipeline</exclude> 
	</excludes> 
</resources>

 

Adding an Assembly project to add multiple projects to single archive

The final step of creating full OSB release archives on resource level, was that we wanted to add multiple projects to a single archive. We achieved this by first building every OSB project separately, and later build an Assembly application which combines all projects into a single archive file. To do this, we use the parent pom.xml file to build all projects (including the assembly project). It is important that the assembly project is build last.

The parent pom.xml file, which will build every project, including the assembly project, will look something like the below example:

pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
	<modelVersion>4.0.0</modelVersion> 
	<groupId>nl.whitehorses</groupId> 
	<artifactId>Integration & Application Talents</artifactId> 
	<version>1.0-SNAPSHOT</version> 
	<packaging>pom</packaging> 
	<modules> 
		<!-- All OSB projects --> 
		<module>Clockwise</module> 
		<module>Employee</module> 
		<module>Office</module> 
		<!-- Assembly project --> 
		<module>Assembly</module> 
	</modules> 
</project>

The pom.xml file of the Assembly project will look like the below example. It is important that if you add new projects, you don’t only add them to the parent pom.xml file, but you also add them as a dependency to the Assembly project. 

pom.xml

<?xml version="1.0" encoding="UTF-8"?> 
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
	<modelVersion>4.0.0</modelVersion> 
	<groupId>nl.whitehorses</groupId> 
	<artifactId>Assembly</artifactId> 
	<version>1.0-SNAPSHOT</version> 
	<dependencies> 
		<dependency> 
			<groupId>nl.whitehorses</groupId> 
			<artifactId>Clockwise</artifactId> 
			<version>1.0-SNAPSHOT</version> 
			<type>sbar</type> 
		</dependency> 
		<dependency> 
			<groupId>nl.whitehorses</groupId> 
			<artifactId>Employee</artifactId> 
			<version>1.0-SNAPSHOT</version> 
			<type>sbar</type> 
		</dependency> 
		<dependency> 
			<groupId>nl.whitehorses</groupId> 
			<artifactId>Office</artifactId> 
			<version>1.0-SNAPSHOT</version> 
			<type>sbar</type> 
		</dependency> 
	</dependencies> 
	<build> 
		<finalName>sbconfig_${project.version}</finalName> 
		<plugins> 
			<plugin> 
				<artifactId>maven-jar-plugin</artifactId> 
				<version>2.6</version> 
				<executions> 
					<execution> 
						<id>default-jar</id> 
						<phase>never</phase> 
					</execution> 
				</executions> 
			</plugin> 
			<plugin> 
				<artifactId>maven-assembly-plugin</artifactId> 
				<version>2.6</version> 
				<configuration> 
					<appendAssemblyId>false</appendAssemblyId> 
					<descriptors> 
						<descriptor>${basedir}/src/main/assembly/assembly.xml</descriptor> 
					</descriptors> 
				</configuration> 
				<dependencies> 
					<dependency> 
						<groupId>nl.whitehorses.servicebus</groupId> 
						<artifactId>servicebus-plugin</artifactId> 
						<version>1.0</version> 
					</dependency> 
				</dependencies> 
				<executions> 
					<execution> 
						<id>make-assembly</id> 
						<phase>package</phase> 
						<goals> 
							<goal>single</goal> 
						</goals> 
					</execution> 
				</executions> 
			</plugin> 
		</plugins> 
	</build> 
</project>

This pom.xml file also points to an assembly.xml file, which contains some configuration about how the Assembly archive should be build bij the Maven assembly plugin. This assembly.xml file should look like the below example: 

assembly.xml

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd"> 
	<id>src</id> 
	<formats> 
		<format>sbar</format> 
	</formats> 
	<includeBaseDirectory>false</includeBaseDirectory> 
	<dependencySets> 
		<dependencySet> 
			<outputDirectory>/</outputDirectory> 
			<unpack>true</unpack> 
		</dependencySet> 
	</dependencySets> 
</assembly>

If you navigate to the directory which contains the parent pom.xml file, and you execute mvn install via the command line, the OSB release will be build.

For a working example of the above, please download: Building-OSB-12c-releases-on-resource-level-using-Maven.zip

Deploying the archive via Maven

It is also possible to deploy the generated (Assembly) archive directly to an OSB server via the Maven plugin. To achieve this, we should add the deploy-assembly goal of the custom Maven plugin to the desired Maven phase. We chose the pre-integration-test phase for deploying the archive to the OSB server. The pom.xml file in the Assembly project can be updated like the below example to connect the Maven pre-integration-test phase to the deploy-assembly goal of the Maven plugin:

<?xml version="1.0" encoding="UTF-8"?> 
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
	<modelVersion>4.0.0</modelVersion> 
	<groupId>nl.whitehorses</groupId> 
	<artifactId>Assembly</artifactId> 
	<version>1.0-SNAPSHOT</version> 
	<dependencies> 
		<dependency> 
			<groupId>nl.whitehorses</groupId> 
			<artifactId>Clockwise</artifactId> 
			<version>1.0-SNAPSHOT</version> 
			<type>sbar</type> 
		</dependency> 
		<dependency> 
			<groupId>nl.whitehorses</groupId> 
			<artifactId>Employee</artifactId> 
			<version>1.0-SNAPSHOT</version> 
			<type>sbar</type> 
		</dependency> 
		<dependency> 
			<groupId>nl.whitehorses</groupId> 
			<artifactId>Office</artifactId> 
			<version>1.0-SNAPSHOT</version> 
			<type>sbar</type> 
		</dependency> 
	</dependencies> 
	<build> 
		<finalName>sbconfig_${project.version}</finalName> 
		<plugins> 
			<plugin> 
				<artifactId>maven-jar-plugin</artifactId> 
				<version>2.6</version> 
				<executions> 
					<execution> 
						<id>default-jar</id> 
						<phase>never</phase> 
					</execution> 
				</executions> 
			</plugin> 
			<plugin> 
				<artifactId>maven-assembly-plugin</artifactId> 
				<version>2.6</version> 
				<configuration> 
					<appendAssemblyId>false</appendAssemblyId> 
					<descriptors> 
						<descriptor>${basedir}/src/main/assembly/assembly.xml</descriptor> 
					</descriptors> 
				</configuration> 
				<dependencies> 
					<dependency> 
						<groupId>nl.whitehorses.servicebus</groupId> 
						<artifactId>servicebus-plugin</artifactId> 
						<version>1.0</version> 
					</dependency> 
				</dependencies> 
				<executions> 
					<execution> 
						<id>make-assembly</id> 
						<phase>package</phase> 
						<goals> 
							<goal>single</goal> 
						</goals> 
					</execution> 
				</executions> 
			</plugin>
			<plugin>
				<groupId>nl.whitehorses.servicebus</groupId> 
				<artifactId>servicebus-plugin</artifactId> 
				<version>1.0</version> 
				<executions>
					<execution>
						<id>deploy-assembly</id>
						<phase>pre-integration-test</phase>
						<goals>
							<goal>deploy-assembly</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
		</plugins> 
	</build> 
</project>

If we navigate to the directory containing the parent pom.xml file again, we will be able to deploy the release to the OSB server by executing the mvn pre-integration-test statement. The following parameters must/can be added to this command:

Parameter Required? Default value
-Dserver.url Yes
-Dserver.username Yes
-Dserver.password Yes
-Ddeployment.preserve.credentials true
-Ddeployment.preserve.envValues true
-Ddeployment.preserve.operationalValues true
-Ddeployment.preserve.securityAndPolicyConfig true
-Ddeployment.preserve.accessControlPolicies true
-Ddeployment.customization.file No
-Ddeployment.session.activate true
-Ddeployment.session.discardOnError true

 

These settings represent the “Advanced Settings” when manually uploading an archive via the servicebus console.

Building OSB

Good luck building your OSB releases on resouce level using Maven!

Overzicht blogs

Geen reacties

Geef jouw mening

Reactie plaatsen

Reactie toevoegen

Jouw e-mailadres wordt niet openbaar gemaakt.

Geen HTML

  • Geen HTML toegestaan.
  • Regels en alinea's worden automatisch gesplitst.
  • Web- en e-mailadressen worden automatisch naar links omgezet.
Whitehorses
Mike Heeren /
Integratie expert

Wil je deel uitmaken van een groep gedreven en ambitieuze experts? Stuur ons jouw cv!