Sunday, September 22, 2013

Weblogic Application deployment using maven plugin

1)create a "weblogic" maven plug-in

 i) change webloigc library directory

      #cd MW_HOME/wlserver_10.3/server/lib/

 ii)create a plug-in using wljarbuilder

      #java -jar wljarbuilder.jar -profile weblogic-maven-plugin

 iii)now you can see the weblogic maven plugin file "weblogic-maven-plugin.jar"

2)weblogic plugin  configuration and installaion in to maven ".m2" repository

    i)extract pom file from weblogic plug-in

      #jar xvf weblogic-maven-plugin.jar META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml
  
   ii)copy the pom file from extract location to local location .
    
      #cp META-INF/maven/com.oracle.weblogic/weblogic-maven-plugin/pom.xml .

   iii)add "com.oracle.weblogic" in pluginGroups to the maven settings.xml as follow
  
            <pluginGroups>
                  <pluginGroup>com.oracle.weblogic</pluginGroup>
             </pluginGroups>

  iV)change the weblogic-maven-plugin.jar pom.xml file as follows
         <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
          http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>com.oracle.weblogic</groupId>
        <artifactId>weblogic-maven-plugin</artifactId>
        <packaging>maven-plugin</packaging>
        <version>10.3.4</version>
        <name>Maven Mojo Archetype</name>
        <url>http://maven.apache.org</url>
        <dependencies>
           <dependency>
               <groupId>org.apache.maven</groupId>
               <artifactId>maven-plugin-api</artifactId>
               <version>2.0</version>
           </dependency>
        </dependencies>
        <build>
        <plugins>
          <plugin>
          <artifactId>maven-plugin-plugin</artifactId>
          <version>2.3</version>
           <configuration>
             <goalPrefix>weblogic</goalPrefix>
           </configuration>
          </plugin>
        </plugins>
        </build>
        </project>
   v) install weblogic-maven-plugin file and pom file .
  
       #mvn install:install-file -Dfile=weblogic-maven-plugin.jar -DpomFile=pom.xml  

3)verify weblogic plug-in

   i)execute below file will show weblogic help
    
     #mvn weblogic:listapps


4)sample maven for undeploy , deploy and list the applications in cluster

<?xml version="1.0" encoding="windows-1252" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0">
  <modelVersion>4.0.0</modelVersion>
  <groupId>application</groupId>
  <artifactId>applicationEar</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>ear</packaging>
 
  <dependencies>
    <dependency>
          <groupId>application</groupId>
          <artifactId>applicationViewController</artifactId>
          <version>0.0.1-SNAPSHOT</version>
          <type>war</type>
    </dependency>
  </dependencies>
 
  <build>
    <resources>
          <resource>
            <directory>../.adf</directory>
            <includes>
              <include>**/*</include>
            </includes>
            <targetPath>adf</targetPath>
          </resource>
          <resource>
            <directory>../src/META-INF</directory>
            <includes>
              <include>**/*</include>
            </includes>
            <targetPath>META-INF</targetPath>
          </resource>
     </resources>
    <plugins>
        <plugin>
            <artifactId>maven-ear-plugin</artifactId>
            <configuration>
              <finalName>application</finalName>
              <earSourceDirectory>${project.build.directory}/classes</earSourceDirectory>
              <archive>
                <addMavenDescriptor>false</addMavenDescriptor>
              </archive>
              <modules>
                <webModule>
                  <groupId>application</groupId>
                  <artifactId>applicationViewController</artifactId>
                  <contextRoot>application</contextRoot>
                </webModule>
              </modules>
              <defaultLibBundleDir>lib</defaultLibBundleDir>
            </configuration>
          </plugin>
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>10.3.6.0</version>
<configuration>
<adminurl>t3://10.0.1.40:7001</adminurl>
<user>wldeployer</user>
<password>wldeployer123</password>
<upload>true</upload>
<target>vfccare</target>
<verbose>true</verbose>
<source>${project.build.directory}/application.ear</source>
<stage>true</stage>
<name>application</name>
<failonerror>false</failonerror>
</configuration>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>undeploy</goal>
<goal>deploy</goal>
<goal>list-apps</goal>
</goals>
</execution>
</executions>
</plugin>

    </plugins>
   
  </build>
 
  <parent>
    <groupId>application</groupId>
    <artifactId>application</artifactId>
    <version>0.0.1-SNAPSHOT</version>
  </parent>
 
</project>

No comments:

Post a Comment