The Challenge

The Oracle 12.1.3 release provided Maven support and it generates project POMs for SOA, ADF and OSB quite nicely.  However, there is no out-of-the-box POM created for a project charged with deploying a Metadata Services archive (MAR) to SOA.   The solution is to use the Apache Assembly plugin to create the archive and then a SAR type deployment to target SOA.  The latter requires a large number of parameters be passed as Maven command line arguments and the deployment does not address targeting the MAR to different environments like QA and PROD.  

Earlier Adam DesJardin (AVIO CTO) blogged about a SAR parent POM that could instead be referenced to accept only one parameter on the Maven deployment which was a reference to a properties file that contains the name-value properties for a SOA deployment.  The idea is to create one of them for each of the environments (DEV, QA, CI, PROD).  This topic will show how to configure the MDS project POM to utilize the AVIO parent POM and add an Assembly plugin for use in the deployment to SOA. 

Maven Solution

Use the AVIO SAR parent POM but add the assembly plugin to create the MAR that will be deployed to SOA.  The assembly plugin is out-of-the-box Apache.  It references an assembly descriptor that contains project variable tokens that get substituted nicely by the Maven build.  Of course, it needs to be deployable and this blog will show you those steps to summarize.  

There are a couple of assumptions before you actually undertake the steps listed below.

  • You already have a functioning 12.1.3 or 12.2.1 FMW repository already set up.  If not you can at least peruse the steps below for future reference.
  • You have added the AVIO parent POM to your local Maven repository. If you have not please read SAR parent POM. Adam discusses downloading the AVIO parent Pom and covers the properties you’ll need in the SAR project POM in his blog.
  • The FMW references as you will see are to 12.2.1.

The Steps

In this scenario there is a SOA application containing a project whose project source directory is “apps” and below it are the packages for the application.  Below is a sample of the apps folder structure in the MDS project.  Of course your structure will likely be different but the important thing is you have an apps folder. 

apps
|-avioconsulting
|-samples
|-soa
|-app
|-dvms
|-policies
|-Schemas
|-WSDLs

 

Step 1 – Create the POM for the MDS project and modify it to reference the AVIO SAR parent POM. 

     1. In JDeveloper add Maven to the MDS project by right-clicking the project and selecting (New…From Gallery).

     2. In the Gallery dialog select General…Maven…Maven POM for Project.

     3. JDeveloper will open the project POM.  Switch to the Source view and replace the parent element with the reference to the AVIO SAR parent POM.  

<parent>
<groupId>com.avioconsulting.oracle.soa</groupId>
<artifactId>avio-sar-common</artifactId>
<version>12.2.1-0-0</version>
<relativePath></relativePath>
</parent>

(If you haven’t added the AVIO SAR parent POM to your local Maven repo you could “cheat” and reference it in the relativePath element above.)

    4. There will be one build plugin in the generated project POM for the oracle.soa.plugin.  The next step will have you add the assembly plugin just below it.

 

Step 2 – Add Maven Assembly Plugin

    1. Just above the </plugins> element add the following lines that reference a file you will create in the project directory.  

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<finalName>sca</finalName>
<descriptors>
<descriptor>mar-assembly-descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
... (copy the above lines)
</plugins>

    Notice in the preceding XML the reference to “mar-assembly-descriptor.xml” and that the assembly plugin executes in the package phase.

    2. In JDeveloper create an XML file in the project directory named “mar-assembly-descriptor.xml” with the following contents.       

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0
  http://maven.apache.org/xsd/assembly-1.1.0.xsd"
>
<id>${composite.name}-${composite.revision}</id>
<baseDirectory>/</baseDirectory>
<formats>
<format>jar</format>
</formats>
<fileSets>
<fileSet>
<directory>../apps</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*/**</include>
</includes>
</fileSet>
</fileSets>
</assembly>

    3. Save the MAR assembly XML file.

 

Step 3 – Create Environment Properties

We are about to deploy the MAR but the properties file the AVIO SAR parent POM requires needs to be created.  

    1. Create an “env” sub-directory within your application directory.

    2. Create a file named “dev.properties” in the “env” sub-directory.

    3. Add the following name-value pairs shown below and customize for your environment.  (These properties are the same as those in Adam’s blog.)

soa.host=localhost
soa.port=8001
soa.deploy.url=http://${soa.host}:${soa.port}
soa.server=soa_server1
oracle.middleware.home=/opt/oracle/12.1.3/oracle_home
oracle.home=${oracle.middleware.home}/soa
weblogic.user=weblogic
weblogic.password=oracle1234
java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
java.naming.provider.url=t3://${soa.host}:${soa.port}/soa-infra
java.naming.security.principal=${weblogic.user}
java.naming.security.credentials=${weblogic.password}
dedicated.connection=true
dedicated.rmicontext=true

    4. Save the file as  “DEV.properties” in the env directory.

Step 4 – Deploy the MDS Archive to SOA

A little quirk is that you must set the “soamds.apps.home” environment variable for the Maven deployment to succeed.  This is relatively straight-forward in Windows, as shown below.  The key is the environment variable has to be the full path to where the “apps” directory is defined.  (This environment variable is used in the .adf/META-INF/adf-config.xml file.)

set soamds.apps.home=C:app-directorymds-project ... mvn pre-integration-test -Denv=DEV

On Linux and the Mac however there is apparently a dislike of environment variables with dots in the names.  You will have to include it in the Maven command line.  (Line break added on first line for readability.)

env 'soamds.apps.home=/home/greg/app-foler/mds-project/'
/opt/oracle/product/oracle_home/oracle_common/modules/org.apache.maven_3.0.5/bin/mvn pre-integration-test -Denv=dev

Summary

AVIO strongly encourages the use of parent POMs as a way to standardize your Fusion Middleware Maven deployments.  The AVIO SAR parent POM does that.  This blog hopefully combines that best practice with some fragments that should help to Maven-ize your MDS deployments.