Thursday, July 20, 2017

Hos to use Maven to deploy SOA 12c Composites

Prerequisites


JDK1.7
Apache Maven 3.0.5
Oracle Linux (you can try this in windows but I did it in Linux)
Oracle SOA 12.1.3 installed (you can use the quick start version of this as only libraries will be referenced)


Set the following environment variables 

JAVA_HOME
M2_HOME
ORACLE_HOME


Steps to set maven for SOA

Within Oracle SOA folder structure navigate to the maven plugins folder. In my case this was as follows: 
cd /home/oracle/Oracle/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3

Install the soa plugins using the following maven command:
mvn install:install-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar

If you are behind a proxy this will fail but no worries still the .m2 repository folder will be created. 

Now if you were behind a proxy all you need to do is set the proper maven settings.xml configuration file. Create this within .m2 folder. In my case it was here --> /home/oracle/.m2

Below is an example of the settings.xml file.

<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <proxies>
    <proxy>
      <username>youusergoeshere</username>
      <password>passwordgoeshere</password>
      <port>yourproxyportgoeshere</port>
      <host>yourproxyhostgoeshere</host>
      <nonProxyHosts>localhost|127.0.0.0/8|localhost.localdomain|127.0.0.1|::1|testsoa|testsoa|10.0.2.15</nonProxyHosts>
    </proxy>
  </proxies>
  <profiles>
    <profile>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
    </profile>
  </profiles>
</settings>

Now you should be ready to populate your maven repository as follows (adjust paths according to your environment):
mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=/home/oracle/Oracle -Dmaven.repo.local=/home/oracle/.m2/repository

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

You can use the following command to create a new SOA project
mvn archetype:generate -DarchetypeGroupId=com.oracle.soa.archetype -DarchetypeArtifactId=oracle-soa-application -DarchetypeVersion=12.1.3-0-0 -DarchetypeRepository=local -DgroupId=org.my.test -DartifactId=test-soa-application -DprojectName=test-soa-project -Dversion=1.0-SNAPSHOT

Also from within the app generated pom.xml folder you can execute
mvn clean  and  mvn package

When using jdeveloper choose import maven project and build your code, for example do mvn clean package from app pom.xml and the built project should be now in the target folder.

Deploying existing projects

Modify the pom.xml file (project pom not the application pom) as follows:

- Add the highlighted line
                        <scacInputDir>${scac.input.dir}</scacInputDir>
                  <!-- custom added for MAVEN -->
                    <appHome>${project.basedir}/..</appHome>
                    <input>${input}</input>


- Remove the word SNAPSHOT form <version>1.0-SNAPSHOT</version> to make it look as <version>1.0</version>

- Execute the following maven command to deploy to a specific server (change server name and credentials):
mvn pre-integration-test -DserverUrl=http://myhost.com:myport -Doverwrite=true -DforceDefault=true -Dcomposite.partition=mypartition -Duser=myuser -Dpassword=mypassword


Additional notes on projects referencing policies

 Modify the file /.m2/repository/com/oracle/adf/wsm-policy-core/12.1.3-0-0/wsm-policy-core-12.1.3-0-0.pom to look such as:

 <!--
Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.-->
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.oracle.adf</groupId>
  <artifactId>wsm-policy-core</artifactId>
  <version>12.1.3-0-0</version>
  <packaging>jar</packaging>
  <name>wsm-policy-core</name>
  <description>Generated from Oracle JDeveloper</description>

  <dependencies>
  <dependency>
            <groupId>com.oracle.adf</groupId>
            <artifactId>osdt_xmlsec</artifactId>
            <version>12.1.3-0-0</version>
  </dependency>
  <dependency>
  <groupId>com.oracle.adf</groupId>
  <artifactId>wsm-agent-core</artifactId>
  <version>12.1.3-0-0</version>
  </dependency>
  </dependencies>



No comments:

Post a Comment