All Downloads are FREE. Search and download functionalities are using the official Maven repository.

win32service.build.xml Maven / Gradle / Ivy

<?xml version="1.0"?>

<!--
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - JOnAS: Java(TM) Open Application Server
 - Copyright (C) 1999-2005 Bull S.A.
 - Contact: [email protected]
 -
 - This library is free software; you can redistribute it and/or
 - modify it under the terms of the GNU Lesser General Public
 - License as published by the Free Software Foundation; either
 - version 2.1 of the License, or any later version.
 -
 - This library is distributed in the hope that it will be useful,
 - but WITHOUT ANY WARRANTY; without even the implied warranty of
 - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 - Lesser General Public License for more details.
 -
 - You should have received a copy of the GNU Lesser General Public
 - License along with this library; if not, write to the Free Software
 - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 - USA
 -
 - Initial developer(s): Philippe Durieux
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 - $Id: build.xml 18462 2009-09-02 07:18:10Z fornacif $
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 -->

<!--
 - build.xml file for JOnAS (for Ant Version 1.5)
 - environment variables used :
 -  JONAS_ROOT
 -  JONAS_BASE
 -  CATALINA_HOME | JETTY_HOME
 -->
<project name="jonas" default="create_win32service" basedir=".">

  <!-- properties -->
  <property environment="myenv" />
  <property name="jonas.root" value="${myenv.JONAS_ROOT}" />
  <!-- Set jonas.name property to default in case it is not set by -Djonas.name -->
  <property name="jonas.name" value="jonas" />

  <!-- tasks -->
  <taskdef name="jonas"
           classname="org.ow2.jonas.ant.JOnASTask"
           classpath="${jonas.root}/lib/common/ow_jonas_ant.jar" />
           
  <!-- initialization tasks to be executed before any other target -->
  <target name="init">
    <!-- Set jonas.base and check if the property is defined -->
    <condition property="jonas.base.isset">
      <or>
        <isset property="myenv.JONAS_BASE" />
      </or>
    </condition>
    <condition property="jonas.base" value="${myenv.JONAS_BASE}">
      <and>
        <isset property="myenv.JONAS_BASE" />
      </and>
    </condition>
    
    <!-- Test if there is already a jonas.properties in JONAS_BASE/conf -->
    <available file="${jonas.base}/conf/jonas.properties" property="jonas.base.alreadyset" />
  </target>
  
  <target name="create_win32service_init">
    <fail message="JONAS_BASE not set. Unable to create Win32 Service."
          unless="jonas.base.isset" />
    <fail unless="jonas.base.alreadyset">
      JONAS_BASE structure is not initialized properly.
      Run ANT create_jonasbase before attempting to create a Win32 Service.
    </fail>

    <!-- verify that JONAS_ROOT (required by jonas.bat) environment variable is set -->
    <condition property="jonas.root.isset">
      <and>
        <isset property="myenv.JONAS_ROOT" />
      </and>
    </condition>
    <fail unless="jonas.root.isset"
          message="JONAS_ROOT environment variable not set." />

    <property name="wrapper.home" value="${myenv.WRAPPER_HOME}" />
    <condition property="wrapper.home.isset">
      <and>
        <isset property="myenv.WRAPPER_HOME" />
      </and>
    </condition>
    <fail unless="wrapper.home.isset"
          message="WRAPPER_HOME environment variable not set." />

    <!-- make sure Java Service Wrapper is installed -->
    <available file="${wrapper.home}/bin/Wrapper.exe"
               property="wrapper.isinstalled" />
    <fail unless="wrapper.isinstalled"
          message="Java Service Wrapper not installed." />

  </target>

  <target name="create_win32service"
          description="Create Win32 Service for the JOnAS server configured by JONAS_BASE."
          depends="init, create_win32service_init">

    <!-- copy Java Service Wrapper files to JONAS_BASE directory -->
    <copy file="${wrapper.home}/lib/wrapper.jar" todir="${jonas.base}/lib" />
    <copy file="${wrapper.home}/lib/Wrapper.DLL" todir="${jonas.base}/lib" />

    <!-- update wrapper_ext.conf for current JONAS_BASE -->
    <exec executable="${jonas.root}/bin/jonas.bat">
      <arg value="-cfgsvc" />
      <arg file="${jonas.base}/conf/wrapper_ext.conf" />
      <arg value="-n" />
      <arg value="${jonas.name}" />
    </exec>

  	<replace file="${jonas.base}/conf/wrapper.conf" token="@jonas.base@" value="${jonas.base}"/>

  </target>

  <target name="win32service"
          description="run the Win32 wrapper command"
          depends="init, create_win32service_init">

    <exec executable="${jonas.root}/bin/jonasnt.bat" >
    	<arg value="${win32param}" />
  	</exec>
  </target>


  <target name="install_win32service"
          description="install the Win32 service associated with JONAS_BASE"
          depends="init, create_win32service_init">

    <exec executable="${jonas.root}/bin/jonasnt.bat" >
    	<arg value="install" />
  	</exec>
  </target>


  <target name="uninstall_win32service"
          description="uninstall the Win32 service associated with JONAS_BASE"
          depends="init, create_win32service_init">

    <exec executable="${jonas.root}/bin/jonasnt.bat" >
    	<arg value="uninstall" />
  	</exec>
  </target>

</project>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy