jueves, 3 de julio de 2014

Soa Suite 11g MDS deploy with Maven

I had see lots of post where to deploy the MDS with ant. My intention is to give the configuration i follow to make a MDS maven project.

I follow the post of Edwin Biemond http://biemond.blogspot.com.es/2009/11/soa-suite-11g-mds-deploy-and-removal.html  and adapt the files to use them with maven.


The configuration needed in the pom:

        
<properties>
  <!-- Server-->
  <wl.server.url>http://localhost:33000</wl.server.url>
  <wl.user>weblogic</wl.user>
  <wl.pass>welcome1</wl.pass>
  <wl.home.mdw>C:\Oracle\MDWJdev</wl.home.mdw>
  <wl.home.mdw.jdev>C:\Oracle\MDWJdev\jdeveloper</wl.home.mdw.jdev>
  <wl.home.mdw.jdk>C:\Oracle\MDWJdev\jdeveloper</wl.home.mdw.jdk>
  <wl.home.mdw.wls>C:\Oracle\MDWJdev\wlserver_10.3</wl.home.mdw.wls>
 </properties>

 <profiles>
  <profile>
   <id>deployMDSServer1</id>
   <build>
    <plugins>
     <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-antrun-plugin</artifactId>
      <version>1.7</version>
      <dependencies>
       <dependency>
        <groupId>ant-contrib</groupId>
        <artifactId>ant-contrib</artifactId>
        <version>1.0b3</version>
        <exclusions>
         <exclusion>
          <groupId>ant</groupId>
          <artifactId>ant</artifactId>
         </exclusion>
        </exclusions>
       </dependency>
      </dependencies>
      <executions>
       <execution>
        <id>deployMDSServer1</id>
        <phase>install</phase>
        <goals>
         <goal>run</goal>
        </goals>
        <configuration>
         <tasks>
          <ant antfile="${basedir}\build.xml">
           <property name="wl.serverURL" value="${wl.server.url}" />
           <property name="wl.user" value="${wl.user}" />
           <property name="wl.password" value="${wl.pass}" />
           <property name="mds.reposistory"
            value="${basedir}/src/main/resources/mds/apps" />
           <property name="tmp.output.dir" value="${basedir}" />
           <property name="wn.bea.home" value="${wl.home.mdw}" />
           <property name="oracle.home" value="${wl.home.mdw.jdev}" />
           <property name="java.passed.home" value="${wl.home.mdw.jdk}" />
           <property name="wl_home" value="${wl.home.mdw.wls}" />
           <target name="deployMDS" />
          </ant>
         </tasks>
        </configuration>
       </execution>
      </executions>
     </plugin>
    </plugins>
   </build>
  </profile>



The reduced version of the properties file:
mds.applications=apps
mds.undeploy=false

# dev deployment server weblogic
wl.overwrite=true
wl.forceDefault=true

Finally the build.xml:
<?xml version="1.0" encoding="iso-8859-1"?>
<project name="soaDeployAll" default="deployMDS">
    <echo>basedir ${basedir}</echo>

    <property file="${basedir}\build.properties"/>  
    <taskdef resource="net/sf/antcontrib/antcontrib.properties"/>


    <target name="unDeployMDS">
        <echo>undeploy MDS</echo>
        <foreach list="${mds.applications}" param="mds.application" target="undeployMDSApplication" inheritall="true" inheritrefs="false"/>
    </target>

    <target name="deployMDS">
        <echo>undeploy and deploy MDS</echo>
        <if> 
          <equals arg1="${mds.undeploy}" arg2="true"/>
          <then>
            <foreach list="${mds.applications}" param="mds.application" target="undeployMDSApplication" inheritall="true" inheritrefs="false"/>
          </then>
        </if>
        <foreach list="${mds.applications}" param="mds.application" target="deployMDSApplication" inheritall="true" inheritrefs="false"/>
    </target>

    <target name="deployMDSApplication">
        <echo>deploy MDS application ${mds.application}</echo>

        <echo>remove and create local MDS temp</echo>
        <property name="mds.deploy.dir" value="${tmp.output.dir}/${mds.application}"/>

        <delete dir="${mds.deploy.dir}"/>
        <mkdir dir="${mds.deploy.dir}"/>

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

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

        <propertycopy name="deploy.serverURL"    from="wl.serverURL"/>
        <propertycopy name="deploy.overwrite"    from="wl.overwrite"/>
        <propertycopy name="deploy.user"         from="wl.user"/>
        <propertycopy name="deploy.password"     from="wl.password"/>
        <propertycopy name="deploy.forceDefault" from="wl.forceDefault"/>

        <echo>deploy MDS app</echo>

        <echo>deploy on ${deploy.serverURL} with user ${deploy.user}</echo>
        <echo>deploy sarFile ${mds.deploy.dir}/${mds.application}_mds.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="${deploy.serverURL}"/>
             <property name="user" value="${deploy.user}"/>
             <property name="password" value="${deploy.password}"/>
             <property name="overwrite" value="${deploy.overwrite}"/>
             <property name="forceDefault" value="${deploy.forceDefault}"/>
             <property name="sarLocation" value="${mds.deploy.dir}/${mds.application}_mds.zip"/>
        </ant> 

    </target>

    <target name="undeployMDSApplication">
        <echo>undeploy MDS application ${mds.application}</echo>

        <propertycopy name="deploy.serverURL"    from="wl.serverURL"/>
        <propertycopy name="deploy.overwrite"    from="wl.overwrite"/>
        <propertycopy name="deploy.user"         from="wl.user"/>
        <propertycopy name="deploy.password"     from="wl.password"/>
        <propertycopy name="deploy.forceDefault" from="wl.forceDefault"/>

         <echo>undeploy MDS app folder apps/${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="${deploy.serverURL}"/>
              <property name="user" value="${deploy.user}"/>
              <property name="password" value="${deploy.password}"/>
              <property name="folderName" value="${mds.application}"/>
         </ant> 
    </target>

</project>

The structure of the project must be like this

- my-project
  - src/
    - main/
      - java/
        - resources/
          - mds/
            - apps/
              - upload_test.txt
 - build.properties
 - build.xml
 -  pom.xml

        

Thats it.


No hay comentarios: