Monday, May 23, 2011

If you have common shared artifacts which need to be deployed to MDS, you can use the below ANT script.
This script has 5 targets
1.buildMDSApplication – builds archive for deployment through ANT
2.deployMDSApplication – builds and deploys to target server MDS
3.buildMDSForServer – builds archive for deployment through em console
4.deployPackagedMDS – deploys already packaged MDS archive
5.undeployMDSApplication – undeploy’s MDS artifacts from server.
<?xml version="1.0" encoding="UTF-8" ?>
<project name="MDSProject">
    <!-- build.properties -->
    <property file="build.properties"/>
    <property name="deploy.dir" value="${basedir}/deploy"/>
   
   <!-- Add targets here -->
    <target name="deployMDSApplication">
        <echo>deploy MDS application ${mds.application}</echo>
        <echo>remove and create local MDS temp</echo>
        <property name="mds.deploy.dir" value="${deploy.dir}"/>
    
        <delete dir="${mds.deploy.dir}"/>
        <mkdir dir="${mds.deploy.dir}"/>
        
        <!-- copy common xsd's -->
        <copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
            <fileset dir="${basedir}" includes="${mds.folderName}/services/xsd/**"/>
        </copy>
        
       <!-- copy dmv files -->
        <copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
            <fileset dir="${basedir}" includes="${mds.folderName}/dvm/**"/>
        </copy>
        
        <!-- copy wsdl's and rename it by trimming deployment env extension. -->
        <copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
            <fileset dir="${basedir}" includes="${mds.folderName}/services/*.wsdl.${deployment.plan.environment}"/>
             <mapper>
                <globmapper from="*.wsdl.${deployment.plan.environment}" to="*.wsdl" />
            </mapper>
        </copy>  
       
        <echo>create zip from file MDS store</echo>
      <zip destfile="${mds.deploy.dir}/${mds.application}.jar" compress="false"> 
        <!--<fileset dir="${basedir}" includes="${mds.folderName}/**"/>-->
          <fileset dir="${mds.deploy.dir}" includes="${mds.folderName}/**"/>
      </zip>

        <echo>create zip with MDS jar</echo>
      <zip destfile="${mds.deploy.dir}/${mds.application}.zip" compress="false"> 
        <fileset dir="${mds.deploy.dir}" includes="*.jar"/>
      </zip>

        <echo>deploy MDS app</echo>

        <echo>deploy on http://${managed.server.host}:${managed.server.port}/soa-infra/deployer with user ${server.user}</echo>
        <echo>deploy sarFile ${mds.deploy.dir}/${mds.application}.zip</echo>

        <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" inheritAll="false" target="deploy">
             <property name="wl_home" value="${wl.home}"/>
             <property name="oracle.home" value="${oracle.home}"/>
             <property name="serverURL" value="http://${managed.server.host}:${managed.server.port}/soa-infra/deployer"/>
             <property name="user" value="${server.user}"/>
             <property name="password" value="${server.password}"/>
             <property name="overwrite" value="true"/>
             <property name="forceDefault" value="false"/>
             <property name="sarLocation" value="${mds.deploy.dir}/${mds.application}.zip"/>
        </ant>   
    </target>
    
    <target name="buildMDSApplication">
        <echo>deploy MDS application ${mds.application}</echo>
        <echo>remove and create local MDS temp</echo>
        <property name="mds.deploy.dir" value="${deploy.dir}"/>
    
        <delete dir="${mds.deploy.dir}"/>
        <mkdir dir="${mds.deploy.dir}"/>
        
        <!-- copy common xsd's -->
        <copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
            <fileset dir="${basedir}" includes="${mds.folderName}/services/xsd/**"/>
        </copy>
        
       <!-- copy dmv files -->
        <copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
            <fileset dir="${basedir}" includes="${mds.folderName}/dvm/**"/>
        </copy>
        
        <!-- copy wsdl's and rename it by trimming deployment env extension. -->
        <copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
            <fileset dir="${basedir}" includes="${mds.folderName}/services/*.wsdl.${deployment.plan.environment}"/>
             <mapper>
                <globmapper from="*.wsdl.${deployment.plan.environment}" to="*.wsdl" />
            </mapper>
        </copy>  
       
        <echo>create zip from file MDS store</echo>
      <zip destfile="${mds.deploy.dir}/${mds.application}.jar" compress="false"> 
        <!--<fileset dir="${basedir}" includes="${mds.folderName}/**"/>-->
          <fileset dir="${mds.deploy.dir}" includes="${mds.folderName}/**"/>
      </zip>

        <echo>create zip with MDS jar</echo>
      <zip destfile="${mds.deploy.dir}/${mds.application}.zip" compress="false"> 
        <fileset dir="${mds.deploy.dir}" includes="*.jar"/>
      </zip>
    </target>    

    <target name="buildMDSForServer">
        <echo>deploy MDS application ${mds.application}</echo>
        <echo>remove and create local MDS temp</echo>
        <property name="mds.deploy.dir" value="${deploy.dir}"/>
    
        <delete dir="${mds.deploy.dir}/apps"/>
        <mkdir dir="${mds.deploy.dir}/apps"/>
        
        <!-- copy common xsd's -->
        <copy todir="${mds.deploy.dir}/apps" verbose="true" overwrite="true">
            <fileset dir="${basedir}" includes="${mds.folderName}/services/xsd/**"/>
        </copy>
        
        <!-- copy dmv files -->
        <copy todir="${mds.deploy.dir}/apps" verbose="true" overwrite="true">
            <fileset dir="${basedir}" includes="${mds.folderName}/dvm/**"/>
        </copy>
        
        <!-- copy wsdl's and rename it by trimming deployment env extension. -->
        <copy todir="${mds.deploy.dir}/apps" verbose="true" overwrite="true">
            <fileset dir="${basedir}" includes="${mds.folderName}/services/*.wsdl.${deployment.plan.environment}"/>
             <mapper>
                <globmapper from="*.wsdl.${deployment.plan.environment}" to="*.wsdl" />
            </mapper>
        </copy>  
       
        <echo>create zip from file MDS store</echo>
      <zip destfile="${mds.deploy.dir}/${mds.application}_${deployment.plan.environment}.zip" compress="false"> 
        <!--<fileset dir="${basedir}" includes="${mds.folderName}/**"/>-->
          <fileset dir="${mds.deploy.dir}" includes="apps/**"/>
      </zip>
    </target>  
    
    <target name="deployPackagedMDS">
        <echo>deploy packaged MDS</echo>
        <property name="mds.deploy.dir" value="${deploy.dir}"/>
        <echo>deploy on http://${managed.server.host}:${managed.server.port}/soa-infra/deployer with user ${server.user}</echo>
        <echo>deploy sarFile ${mds.deploy.dir}/${mds.application}.zip</echo>
        <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" inheritAll="false" target="deploy">
             <property name="wl_home" value="${wl.home}"/>
             <property name="oracle.home" value="${oracle.home}"/>
             <property name="serverURL" value="http://${managed.server.host}:${managed.server.port}/soa-infra/deployer"/>
             <property name="user" value="${server.user}"/>
             <property name="password" value="${server.password}"/>
             <property name="overwrite" value="true"/>
             <property name="forceDefault" value="false"/>
             <property name="sarLocation" value="${mds.deploy.dir}/${mds.application}.zip"/>
        </ant>   
    </target>    
    
    <target name="undeployMDSApplication">
        <echo>undeploy MDS application ${mds.application}</echo>
         <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" inheritAll="false" target="removeSharedData">
              <property name="wl_home" value="${wl.home}"/>
              <property name="oracle.home" value="${oracle.home}"/>
              <property name="serverURL" value="http://${managed.server.host}:${managed.server.port}/soa-infra/deployer"/>
              <property name="user" value="${server.user}"/>
              <property name="password" value="${server.password}"/>
              <property name="folderName" value="${mds.folderName}"/>
         </ant> 
    </target>    
</project>


build.properties file used


mds.application=DeployMDS
mds.folderName=MDSFolder

# change this env based on deployment.
# supported values = dev,iqa,eqa,prod
deployment.plan.environment=dev

# Set oracle.home to <JDEV_HOME>/jdeveloper, where <JDEV_HOME> is JDEV # installation directory
wn.bea.home=C:/oracle/Middleware/jdev_11gR3/
oracle.home=${wn.bea.home}/jdeveloper
java.passed.home=${wn.bea.home}/jdk160_18
wl.home=${wn.bea.home}/wlserver_10.3

# soa-server side oracle home directory - needed for deployment plans
# and the weblogic sca library deployment
soa.server.oracle.home=/product/Oracle/Middleware/Oracle_SOA1

###### Deployment server connection information ###############

# the admin server connection information
admin.server.host=<host>
admin.server.port=7001

# the domain where soa infra is installed
server.domain.name=soa_server1

# connection information for the managed server, used for soa-deployment
managed.server.host=<host>
managed.server.port=8001

# User and credentials for the servers
server.user=<username>
server.password=<password>

# wls server where soa is targeted.
server.targets=soa_server1

Next
This is the most recent post.
Previous
Older Post

1 comments :

  1. Hi All,

    I'am trying to add artifacts from local system to mds. The file location is from C:\Oracle\Middleware\jdeveloper\integration\seed\apps\schemasOld , i kept my schemas(xsd's) in schemasOld folder.
    I was using the ant scripts from the link:-http://biemond.blogspot.in/2009/11/soa-suite-11g-mds-deploy-and-removal.html
    to store my artifacts in mds, To make this work the antcontrib.jar to the jdeveloper\ant\lib folder ( because of the foreach and the propertycopy fucntion ). And i given all my server details in build.properties from where my artifacts should upload to server mds. And in MDS.sh batch file mentioned the required details.

    But its not working, I will appreciate any comments in order to help to fix the problem.

    ReplyDelete