19 Ağustos 2011 Cuma

ant deploy to glassfish

In order to deploy the web service war to glassfish using ant, you can use the following ant snippet:



<target name="glassfish-init" unless="glassfish.initialized">
<taskdef name="sun-appserv-deploy" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.DeployTask">
<classpath path="${glassfish.home}/lib/sun-appserv-ant.jar" />
</taskdef>
<taskdef name="sun-appserv-undeploy" classname="org.apache.tools.ant.taskdefs.optional.sun.appserv.UndeployTask">
<classpath path="${glassfish.home}/lib/sun-appserv-ant.jar" />
</taskdef>
<!-- ensure that glassfish taskdef is only run once, otw ant will error -->
<property name="glassfish.initialized" value="true" />
</target>


<target name="glassfish-password-init" depends="init, glassfish-init">
<!-- do not forget to delete this! -->
<echo message="AS_ADMIN_PASSWORD=adminadmin" file="${build.dir}/password.file" />
</target>


<target name="glassfish-remote-deploy" depends="glassfish-init, glassfish-password-init, war">
<sun-appserv-deploy file="${build.dir}/${name}-${version}.war" name="${name}-${version}" 
user="admin" passwordfile="${build.dir}/password.file" host="remotemachine" port="4848"
asinstalldir="${glassfish.home}"/>
</target>


<target name="glassfish-remote-undeploy" depends="glassfish-init, glassfish-password-init">
<sun-appserv-undeploy name="${name}-${version}" 
user="admin" passwordfile="${build.dir}/password.file" host="remotemachine" port="4848" 
asinstalldir="${glassfish.home}"/>
</target>



The point is to use sun-appserv-ant.jar file, which includes glassfish specific ant task definitions, inside glassfish v2.1 home directory. Otherwise, there will be ClassCouldNotBeFound exceptions..


Hiç yorum yok:

Yorum Gönder