Ratheesh Pai
Ratheesh Pai

Reputation: 1620

Deploy a app in weblogic only if it is not already present in it using ant wldeploy task

<target name="testapp" depends="init-wls"> <wldeploy action="deploy" verbose="true" debug="true" name="testapp" failonerror="false" ... source="testapp.war"/> </target>

Upvotes: 1

Views: 1719

Answers (1)

Petri Pellinen
Petri Pellinen

Reputation: 536

an interesting question. I'm not sure if wldeploy can do what you want. One approach that might work would be to use the wlconfig ant task. You could use it to get the ApplicationRuntimeMBeans and then query their ApplicationName attributes (again, with wlconfig task) to see if the application is deployed. Not super straightforward but at least you would avoid the application redeployment.

This is just a quick idea off the top of my head so not sure if it is feasible in practice, sorry.... :)

--edit: tried it out, something like this should work, the assumption here is that if we can find the MBean then it is already deployed which should be a valid assumption since these beans live under AppDeployments:

<project name="test" default="deploy">
     <property name="domainName" value="ejbTestDomain"/>
     <property name="serverName" value="AdminServer"/>
     <property name="appName" value="ejbWebEAR"/>
     <target name="findApp">
              <wlconfig url="t3://localhost:7001" username="weblogic" password="password_for_weblogic">
                       <query pattern="${domainName}:ServerRuntime=${serverName},Name=${appName},*,Type=ApplicationRuntime" property="app.is.deployed"/>
              </wlconfig>
     </target>
     <target name="deploy" unless="app.is.deployed" depends="findApp">
              <echo message="Deploying..."/>
              <!-- deploy using wldeploy task -->
     </target>
</project>

Upvotes: 3

Related Questions