Pages

Friday, June 27, 2014

Maven support for 12.1.3 Service Bus & SOA Suite artifacts

With the 12.1.3 release of Oracle Service Bus and Oracle SOA Suite we finally can build all our soa projects with Maven. And this time we can do it natively without calling a utility like configjar or ANT from Maven .

We start by setting all the required variables like JAVA_HOME,M2_HOME and PATH

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
export M2_HOME=/Users/edwin/apache-maven-3.0.5
export PATH=${M2_HOME}/bin:${JAVA_HOME}:$PATH

Check if maven works

mvn -v 

You can also use the maven 3.0.5 version of JDeveloper 12.1.3 located at .../oracle_common/modules/org.apache.maven_3.0.5

Next step is to populate all the maven repositories

cd  .../oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3

install the maven sync plugin to the local repository

mvn install:install-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar -DoracleHome=/Users/edwin/Oracle/JDevMiddleware12.1.3

Deploy all the libraries to the local mvn repository

mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=/Users/edwin/Oracle/JDevMiddleware12.1.3

update your local archetype catalog

mvn archetype:crawl -Dcatalog=$HOME/.m2/archetype-catalog.xml

Next steps are, to do the same but then we will fill the Nexus repository

Deploy the maven sync plugin to the nexus maven repository and we need to configure the maven settings.xml

mvn deploy:deploy-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar -Durl=http://localhost:8081/nexus/content/repositories/thirdparty -DrepositoryId=internal

and do a another sync

mvn com.oracle.maven:oracle-maven-sync:push


Here is the matching maven settings.xml

  <servers>
    <server>
      <id>internal</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>

  <mirrors>
    <mirror>
      <id>nexus</id>
      <name>Internal nexus Mirror of Central</name>
      <url>http://localhost:8081/nexus/content/groups/public/</url>
      <mirrorOf>*</mirrorOf>
    </mirror>
  </mirrors>

  <profiles>

    <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
          <id>internal</id>
          <name>internal</name>
          <url>http://localhost:8081/nexus/content/repositories/thirdparty</url>
        </repository>
      </repositories>
    </profile> 

    <profile>
      <id>oracle-maven</id>
      <properties>
        <oracleHome>/Users/edwin/Oracle/JDevMiddleware12.1.3</oracleHome>
        <serverId>internal</serverId>
        <testOnly>false</testOnly>
        <failOnError>false</failOnError>
        <overwriteParent>true</overwriteParent>
      </properties>      
    </profile> 
  </profiles>

  <activeProfiles>
     <activeProfile>nexus</activeProfile>
     <activeProfile>oracle-maven</activeProfile>
  </activeProfiles>                     



Next step is to do a describe of the soa and osb plugin

mvn help:describe -DgroupId=com.oracle.soa.plugin -DartifactId=oracle-soa-plugin -Dversion=12.1.3-0-0

with this as output

Name: Oracle SOA Maven Plugin
Description: This plugin allows users to compile, package, deploy, test and
  undeploy SOA composites.
Group Id: com.oracle.soa.plugin
Artifact Id: oracle-soa-plugin
Version: 12.1.3-0-0
Goal Prefix: oracle-soa

This plugin has 6 goals:

oracle-soa:compile
  Description: Compiles the composite. Note that 'compiling' a composite does
    not actually produce any new files, it is really a 'validation' and
    produces only output messages.

oracle-soa:deploy
  Description: To deploy a SOA composite (supports all formats SAR, MAR,
    etc.)

oracle-soa:help
  Description: Display help information on oracle-soa-plugin.
    Call mvn oracle-soa:help -Ddetail=true -Dgoal=<goal-name> to display
    parameter details.

oracle-soa:sar
  Description: Packages the composite into a SAR.

oracle-soa:test
  Description: To execute SCA Test Suites.

oracle-soa:undeploy
  Description: Undeploy a SOA composite from a SOA managed server or cluster


mvn help:describe -DgroupId=com.oracle.servicebus.plugin -DartifactId=oracle-servicebus-plugin -Dversion=12.1.3-0-0

with this as output

Name: Oracle Service Bus - Plugin
Description: (no description available)
Group Id: com.oracle.servicebus.plugin
Artifact Id: oracle-servicebus-plugin
Version: 12.1.3-0-0
Goal Prefix: servicebus

This plugin has 2 goals:

servicebus:deploy
  Description: (no description available)

servicebus:package
  Description: (no description available)



Now we are able to create a new Service Bus project from a Maven Archetype.


Provide the all the maven details


Search for the servicebus application ArcheType and select this one


Provide the required projectName of this archetype


Create the application


Now we got a Service Bus application with 3 poms, One project with sbar as package type , System project pom and a parent pom with these 2 projects


Now we can build the Service Bus project from JDeveloper by selecting the pom and right click to start for example run the package phase.

or from a terminal by using mvn package




We can do the same for a SOA Suite application and a SOA Composite.


Search for oracle-soa-application



Now we got 2 poms ( 1 is at the workspace level )  and project packaging is now a sar.


And we can also build the soa composite.