Friday 1 July 2022

SOACS Maven Deployment

Maven Setup:
First we need to download and install Maven. 
  • Download maven from this site - https://maven.apache.org/download.cgi
  • Unzip the downloaded file. 
  • Add MAVEN_HOME system variable / Environment Variable
    • MAVEN_HOME = C:\Vijaya\SW\Maven\apache-maven-3.8.6
  • Add Maven bin folder to PATH variable. 
    • PATH = C:\Vijaya\SW\Maven\apache-maven-3.8.6/bin
  • Run mvn --version to check the setup
Update local repository: 
We need to set up a local maven repository for deploying applications using maven. 
First we need to install SOACS on our local machine. Download the SOA installer jars from Oracle and install it on a local machine. 

Update Local Repository with SOA plugins:  Follow the below steps to configure a local repository with SOA plugins. 

  • Go to the following Oracle installation path . 
        cd C:\Oracle\Middleware\Oracle_Home\oracle_common\plugins\maven\com\oracle\maven\oracle-maven-sync\12.2.1
  • Execute the following maven commands. 
mvn install:install-file -Dfile=oracle-maven-sync-12.2.1.jar -DpomFile=oracle-maven-sync-12.2.1.pom

mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=C:/Oracle/Middleware/Oracle_Home -DoverwriteParent=true

mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=C:/Oracle/Middleware/Oracle_Home

mvn com.oracle.maven:oracle-maven-sync:push -Doracle-maven-sync.oracleHome=C:/Oracle/Middleware/Oracle_Home -Doracle-maven-sync.testonly='true'

mvn archetype:crawl -Dcatalog=C:\Users\vijaya\.m2\archetype-catalog.xml 


Create a Maven SOA Project and update the POM files.

Use the following POM files as a template.

Application POM:

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemalocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelversion>4.0.0</modelversion>
  <groupid>SampleApplicationSOA</groupid>
  <artifactid>SampleApplicationSOA</artifactid>
  <version>1.0</version>
  <packaging>pom</packaging>
  <modules>
    <!--Add project modules-->
    <module>SampleProject1</module>
    <module>SampleProject2</module>
  </modules>
</project>

Project POM:

<?xml version="1.0" encoding="UTF-8" ?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.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>SampleProject1</groupId>
  <artifactId>SampleProject1</artifactId>
  <version>1.0</version>
  <packaging>sar</packaging>
  <parent>
    <groupId>com.oracle.soa</groupId>
    <artifactId>sar-common</artifactId>
    <version>12.2.1-3-0</version>
    <relativePath></relativePath>
  </parent>
  <properties>
    <!-- These parameters are used by the compile goal -->    
    <scac.input.dir>${project.basedir}/SOA/</scac.input.dir>
    <scac.output.dir>${project.basedir}/target</scac.output.dir>
    <scac.input>${scac.input.dir}/composite.xml</scac.input>
    <scac.output>${scac.output.dir}/out.xml</scac.output>
    <scac.error>${scac.output.dir}/error.txt</scac.error>
    <scac.displayLevel>1</scac.displayLevel>
    <composite.name>${project.artifactId}</composite.name>
    <composite.revision>1.0</composite.revision>
    <composite.partition>default</composite.partition>
    <overwrite>true</overwrite>
    <forceDefault>true</forceDefault>
    <regenerateRulebase>false</regenerateRulebase>
    <keepInstancesOnRedeploy>false</keepInstancesOnRedeploy>
    <scatest.result>${scac.output.dir}/testResult</scatest.result>
    <input>${project.artifactId}</input>
  </properties>
  <build>
    <plugins>
    <!-- Plugin to read the propery file</file>-->
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>properties-maven-plugin</artifactId>
        <version>1.0-alpha-2</version>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>read-project-properties</goal>
            </goals>
            <configuration>
              <files>
                <file>${build.properties.file}</file>
              </files>
            </configuration>
          </execution>
        </executions>
      </plugin>
     <!-- Plugin to replace the tokens </file>-->
       <plugin>
        <groupId>com.google.code.maven-replacer-plugin</groupId>
        <artifactId>replacer</artifactId>
        <version>1.5.3</version>
        <executions>
          <execution>
            <id>replace-schema-file</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>replace</goal>
            </goals>
            <configuration>            
<file> ${scac.input.dir}/wsm-assembly.xml</file>              
              <replacements>
                <replacement>
                  <token>@@TARGET_SERVER1@@</token>
                  <value>${TARGET_SERVER1}</value>
                </replacement>
                <replacement>
                  <token>@@TARGET_SERVER2@@</token>
                  <value>${TARGET_SERVER2}</value>
                </replacement>
              </replacements>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.oracle.soa.plugin</groupId>
        <artifactId>oracle-soa-plugin</artifactId>
        <version>12.2.1-3-0</version>
        <configuration>
          <compositeName>${project.artifactId}</compositeName>
          <composite>${scac.input}</composite>
          <sarLocation>${scac.output.dir}/sca_${project.artifactId}_rev${project.version}.jar</sarLocation>
          <serverUrl>${SOACS_HOST_NAME}</serverUrl>
          <user>${SOACS_USER_NAME}</user>
          <password>${SOACS_PASSWORD}</password>
          <!-- Note: compositeRevision is needed to package, revision is needed to undeploy -->
          <compositeRevision>${composite.revision}</compositeRevision>
          <revision>${composite.revision}</revision>
          <scacInputDir>${scac.input.dir}</scacInputDir>
          <appHome>${project.basedir}/..</appHome>
          <oracleHome>${ORACLE_HOME}/soa</oracleHome>
          <input>${input}</input>
        </configuration>
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
<!-- To download the plugins from Oracle maven repo </file>-->
  <repositories>
    <repository>
      <name>OracleMaven</name>
      <id>maven.oracle.com</id>
      <url>https://maven.oracle.com</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <name>OracleMaven</name>
      <id>maven.oracle.com</id>
      <url>https://maven.oracle.com</url>
    </pluginRepository>
  </pluginRepositories>
</project>


Note:  If we are using MDS resources (wsdl/xsd) then we need to provide the local mds path details for compilation and packaging. 

Use the following adf-config.xml file 

<?xml version="1.0" encoding="windows-1252" ?>
<adf-config xmlns="http://xmlns.oracle.com/adf/config" xmlns:adf="http://xmlns.oracle.com/adf/config/properties"
            xmlns:sec="http://xmlns.oracle.com/adf/security/config">
  <adf:adf-properties-child xmlns="http://xmlns.oracle.com/adf/config/properties">
    <adf-property name="adfAppUID" value="XxScmSDTLightAppSOA-8435"/>
  </adf:adf-properties-child>
  <sec:adf-security-child xmlns="http://xmlns.oracle.com/adf/security/config">
    <CredentialStoreContext credentialStoreClass="oracle.adf.share.security.providers.jps.CSFCredentialStore"
                            credentialStoreLocation="../../src/META-INF/jps-config.xml"/>
  </sec:adf-security-child>
  <adf-mds-config xmlns="http://xmlns.oracle.com/adf/mds/config">
    <mds-config xmlns="http://xmlns.oracle.com/mds/config">
      <persistence-config>
        <metadata-namespaces>
          <namespace path="/apps" metadata-store-usage="mstore-usage_2"/>
          <namespace path="/soa/shared" metadata-store-usage="mstore-usage_3"/>
        </metadata-namespaces>
        <metadata-store-usages>
          <metadata-store-usage id="mstore-usage_2">
            <metadata-store class-name="oracle.mds.persistence.stores.file.FileMetadataStore">
              <property name="metadata-path" value="${soamds.apps.home}"/>
            </metadata-store>
          </metadata-store-usage>
          <metadata-store-usage id="mstore-usage_3">
            <metadata-store class-name="oracle.mds.persistence.stores.file.FileMetadataStore">
              <property name="partition-name" value="seed"/>
              <property name="metadata-path" value="${soa.oracle.home}/integration"/>
            </metadata-store>
          </metadata-store-usage>
        </metadata-store-usages>
      </persistence-config>
    </mds-config>
  </adf-mds-config>
</adf-config>

${soamds.apps.home} :  Pass local MDS path while running Maven command.
${soa.oracle.home} :   Pass either local MDS or SOA install directory path where seeded resources are present. 


Maven Command to Deploy:

mds_path=$(pwd)/soamp/mds

MIDDLEWARE_HOME_SOA= C:\Oracle\Middleware\Oracle_Home\  (SOA installation path)

mvn -Dbuild.properties.file=${property} -Dsoa.oracle.home=${MIDDLEWARE_HOME_SOA}/soa -Dsoamds.apps.home=${mds_path} pre-integration-test


In case if we have to use an SSL port for the deployment and if we need to use a custom trust store to connect then we can use the following maven command. 

mvn -Dbuild.properties.file=${property} -Dsoa.oracle.home=${MIDDLEWARE_HOME_SOA}/soa -Dsoamds.apps.home=${mds_path}  -Djavax.net.ssl.keyStoreType=JKS -Djavax.net.ssl.trustStore=${trustStoreFile} -Djavax.net.ssl.trustStorePassword=**** -Djavax.net.ssl.keyStore=${trustStoreFile} -Djavax.net.ssl.keyStorePassword=*** pre-integration-test



No comments:

Post a Comment

IDCS - Identity Federation with Azure and Google (SAML IDP & Social IDP)

The setup involves Identity Cloud Service (IDCS) acting as the central identity provider, facilitating seamless authentication and authoriza...