home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / build.xml.txt < prev    next >
Encoding:
Text File  |  2004-08-28  |  16.4 KB  |  504 lines

  1. <!--
  2.      General purpose build script for web applications and web services,
  3.      including enhanced support for deploying directly to a Tomcat 5
  4.      based server.
  5.  
  6.      This build script assumes that the source code of your web application
  7.      is organized into the following subdirectories underneath the source
  8.      code directory from which you execute the build script:
  9.  
  10.         docs                 Static documentation files to be copied to
  11.                              the "docs" subdirectory of your distribution.
  12.  
  13.         src                  Java source code (and associated resource files)
  14.                              to be compiled to the "WEB-INF/classes"
  15.                              subdirectory of your web applicaiton.
  16.  
  17.         web                  Static HTML, JSP, and other content (such as
  18.                              image files), including the WEB-INF subdirectory
  19.                              and its configuration file contents.
  20.  
  21.      $Id: build.xml.txt,v 1.6 2004/05/23 19:50:44 markt Exp $
  22. -->
  23.  
  24.  
  25. <!-- A "project" describes a set of targets that may be requested
  26.      when Ant is executed.  The "default" attribute defines the
  27.      target which is executed if no specific target is requested,
  28.      and the "basedir" attribute defines the current working directory
  29.      from which Ant executes the requested task.  This is normally
  30.      set to the current working directory.
  31. -->
  32.  
  33. <project name="My Project" default="compile" basedir=".">
  34.  
  35.  
  36.  
  37. <!-- ===================== Property Definitions =========================== -->
  38.  
  39.  
  40. <!--
  41.  
  42.   Each of the following properties are used in the build script.
  43.   Values for these properties are set by the first place they are
  44.   defined, from the following list:
  45.  
  46.   * Definitions on the "ant" command line (ant -Dfoo=bar compile).
  47.  
  48.   * Definitions from a "build.properties" file in the top level
  49.     source directory of this application.
  50.  
  51.   * Definitions from a "build.properties" file in the developer's
  52.     home directory.
  53.  
  54.   * Default definitions in this build.xml file.
  55.  
  56.   You will note below that property values can be composed based on the
  57.   contents of previously defined properties.  This is a powerful technique
  58.   that helps you minimize the number of changes required when your development
  59.   environment is modified.  Note that property composition is allowed within
  60.   "build.properties" files as well as in the "build.xml" script.
  61.  
  62. -->
  63.  
  64.   <property file="build.properties"/>
  65.   <property file="${user.home}/build.properties"/>
  66.  
  67.  
  68. <!-- ==================== File and Directory Names ======================== -->
  69.  
  70.  
  71. <!--
  72.  
  73.   These properties generally define file and directory names (or paths) that
  74.   affect where the build process stores its outputs.
  75.  
  76.   app.name             Base name of this application, used to
  77.                        construct filenames and directories.
  78.                        Defaults to "myapp".
  79.  
  80.   app.path             Context path to which this application should be
  81.                        deployed (defaults to "/" plus the value of the
  82.                        "app.name" property).
  83.  
  84.   app.version          Version number of this iteration of the application.
  85.  
  86.   build.home           The directory into which the "prepare" and
  87.                        "compile" targets will generate their output.
  88.                        Defaults to "build".
  89.  
  90.   catalina.home        The directory in which you have installed
  91.                        a binary distribution of Tomcat 5.  This will
  92.                        be used by the "deploy" target.
  93.  
  94.   dist.home            The name of the base directory in which
  95.                        distribution files are created.
  96.                        Defaults to "dist".
  97.  
  98.   manager.password     The login password of a user that is assigned the
  99.                        "manager" role (so that he or she can execute
  100.                        commands via the "/manager" web application)
  101.  
  102.   manager.url          The URL of the "/manager" web application on the
  103.                        Tomcat installation to which we will deploy web
  104.                        applications and web services.
  105.  
  106.   manager.username     The login username of a user that is assigned the
  107.                        "manager" role (so that he or she can execute
  108.                        commands via the "/manager" web application)
  109.  
  110. -->
  111.  
  112.   <property name="app.name"      value="myapp"/>
  113.   <property name="app.path"      value="/${app.name}"/>
  114.   <property name="app.version"   value="0.1-dev"/>
  115.   <property name="build.home"    value="${basedir}/build"/>
  116.   <property name="catalina.home" value="../../../.."/> <!-- UPDATE THIS! -->
  117.   <property name="dist.home"     value="${basedir}/dist"/>
  118.   <property name="docs.home"     value="${basedir}/docs"/>
  119.   <property name="manager.url"   value="http://localhost:8080/manager"/>
  120.   <property name="src.home"      value="${basedir}/src"/>
  121.   <property name="web.home"      value="${basedir}/web"/>
  122.  
  123.  
  124. <!-- ================== Custom Ant Task Definitions ======================= -->
  125.  
  126.  
  127. <!--
  128.  
  129.   These properties define custom tasks for the Ant build tool that interact
  130.   with the "/manager" web application installed with Tomcat 5.  Before they
  131.   can be successfully utilized, you must perform the following steps:
  132.  
  133.   - Copy the file "server/lib/catalina-ant.jar" from your Tomcat 5
  134.     installation into the "lib" directory of your Ant installation.
  135.  
  136.   - Create a "build.properties" file in your application's top-level
  137.     source directory (or your user login home directory) that defines
  138.     appropriate values for the "manager.password", "manager.url", and
  139.     "manager.username" properties described above.
  140.  
  141.   For more information about the Manager web application, and the functionality
  142.   of these tasks, see <http://localhost:8080/tomcat-docs/manager-howto.html>.
  143.  
  144. -->
  145.  
  146.   <taskdef name="deploy"   classname="org.apache.catalina.ant.DeployTask"/>
  147.   <taskdef name="list"     classname="org.apache.catalina.ant.ListTask"/>
  148.   <taskdef name="reload"   classname="org.apache.catalina.ant.ReloadTask"/>
  149.   <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/>
  150.  
  151.  
  152. <!--  ==================== Compilation Control Options ==================== -->
  153.  
  154. <!--
  155.  
  156.   These properties control option settings on the Javac compiler when it
  157.   is invoked using the <javac> task.
  158.  
  159.   compile.debug        Should compilation include the debug option?
  160.  
  161.   compile.deprecation  Should compilation include the deprecation option?
  162.  
  163.   compile.optimize     Should compilation include the optimize option?
  164.  
  165. -->
  166.  
  167.   <property name="compile.debug"       value="true"/>
  168.   <property name="compile.deprecation" value="false"/>
  169.   <property name="compile.optimize"    value="true"/>
  170.  
  171.  
  172.  
  173. <!-- ==================== External Dependencies =========================== -->
  174.  
  175.  
  176. <!--
  177.  
  178.   Use property values to define the locations of external JAR files on which
  179.   your application will depend.  In general, these values will be used for
  180.   two purposes:
  181.   * Inclusion on the classpath that is passed to the Javac compiler
  182.   * Being copied into the "/WEB-INF/lib" directory during execution
  183.     of the "deploy" target.
  184.  
  185.   Because we will automatically include all of the Java classes that Tomcat 5
  186.   exposes to web applications, we will not need to explicitly list any of those
  187.   dependencies.  You only need to worry about external dependencies for JAR
  188.   files that you are going to include inside your "/WEB-INF/lib" directory.
  189.  
  190. -->
  191.  
  192. <!-- Dummy external dependency -->
  193. <!--
  194.   <property name="foo.jar"
  195.            value="/path/to/foo.jar"/>
  196. -->
  197.  
  198.  
  199. <!-- ==================== Compilation Classpath =========================== -->
  200.  
  201. <!--
  202.  
  203.   Rather than relying on the CLASSPATH environment variable, Ant includes
  204.   features that makes it easy to dynamically construct the classpath you
  205.   need for each compilation.  The example below constructs the compile
  206.   classpath to include the servlet.jar file, as well as the other components
  207.   that Tomcat makes available to web applications automatically, plus anything
  208.   that you explicitly added.
  209.  
  210. -->
  211.  
  212.   <path id="compile.classpath">
  213.  
  214.     <!-- Include all JAR files that will be included in /WEB-INF/lib -->
  215.     <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
  216. <!--
  217.     <pathelement location="${foo.jar}"/>
  218. -->
  219.  
  220.     <!-- Include all elements that Tomcat exposes to applications -->
  221.     <pathelement location="${catalina.home}/common/classes"/>
  222.     <fileset dir="${catalina.home}/common/endorsed">
  223.       <include name="*.jar"/>
  224.     </fileset>
  225.     <fileset dir="${catalina.home}/common/lib">
  226.       <include name="*.jar"/>
  227.     </fileset>
  228.     <pathelement location="${catalina.home}/shared/classes"/>
  229.     <fileset dir="${catalina.home}/shared/lib">
  230.       <include name="*.jar"/>
  231.     </fileset>
  232.  
  233.   </path>
  234.  
  235.  
  236.  
  237. <!-- ==================== All Target ====================================== -->
  238.  
  239. <!--
  240.  
  241.   The "all" target is a shortcut for running the "clean" target followed
  242.   by the "compile" target, to force a complete recompile.
  243.  
  244. -->
  245.  
  246.   <target name="all" depends="clean,compile"
  247.    description="Clean build and dist directories, then compile"/>
  248.  
  249.  
  250.  
  251. <!-- ==================== Clean Target ==================================== -->
  252.  
  253. <!--
  254.  
  255.   The "clean" target deletes any previous "build" and "dist" directory,
  256.   so that you can be ensured the application can be built from scratch.
  257.  
  258. -->
  259.  
  260.   <target name="clean"
  261.    description="Delete old build and dist directories">
  262.     <delete dir="${build.home}"/>
  263.     <delete dir="${dist.home}"/>
  264.   </target>
  265.  
  266.  
  267.  
  268. <!-- ==================== Compile Target ================================== -->
  269.  
  270. <!--
  271.  
  272.   The "compile" target transforms source files (from your "src" directory)
  273.   into object files in the appropriate location in the build directory.
  274.   This example assumes that you will be including your classes in an
  275.   unpacked directory hierarchy under "/WEB-INF/classes".
  276.  
  277. -->
  278.  
  279.   <target name="compile" depends="prepare"
  280.    description="Compile Java sources">
  281.  
  282.     <!-- Compile Java classes as necessary -->
  283.     <mkdir    dir="${build.home}/WEB-INF/classes"/>
  284.     <javac srcdir="${src.home}"
  285.           destdir="${build.home}/WEB-INF/classes"
  286.             debug="${compile.debug}"
  287.       deprecation="${compile.deprecation}"
  288.          optimize="${compile.optimize}">
  289.         <classpath refid="compile.classpath"/>
  290.     </javac>
  291.  
  292.     <!-- Copy application resources -->
  293.     <copy  todir="${build.home}/WEB-INF/classes">
  294.       <fileset dir="${src.home}" excludes="**/*.java"/>
  295.     </copy>
  296.  
  297.   </target>
  298.  
  299.  
  300.  
  301. <!-- ==================== Dist Target ===================================== -->
  302.  
  303.  
  304. <!--
  305.  
  306.   The "dist" target creates a binary distribution of your application
  307.   in a directory structure ready to be archived in a tar.gz or zip file.
  308.   Note that this target depends on two others:
  309.  
  310.   * "compile" so that the entire web application (including external
  311.     dependencies) will have been assembled
  312.  
  313.   * "javadoc" so that the application Javadocs will have been created
  314.  
  315. -->
  316.  
  317.   <target name="dist" depends="compile,javadoc"
  318.    description="Create binary distribution">
  319.  
  320.     <!-- Copy documentation subdirectories -->
  321.     <mkdir   dir="${dist.home}/docs"/>
  322.     <copy    todir="${dist.home}/docs">
  323.       <fileset dir="${docs.home}"/>
  324.     </copy>
  325.  
  326.     <!-- Create application JAR file -->
  327.     <jar jarfile="${dist.home}/${app.name}-${app.version}.war"
  328.          basedir="${build.home}"/>
  329.  
  330.     <!-- Copy additional files to ${dist.home} as necessary -->
  331.  
  332.   </target>
  333.  
  334.  
  335.  
  336. <!-- ==================== Install Target ================================== -->
  337.  
  338. <!--
  339.  
  340.   The "install" target tells the specified Tomcat 5 installation to dynamically
  341.   install this web application and make it available for execution.  It does
  342.   *not* cause the existence of this web application to be remembered across
  343.   Tomcat restarts; if you restart the server, you will need to re-install all
  344.   this web application.
  345.  
  346.   If you have already installed this application, and simply want Tomcat to
  347.   recognize that you have updated Java classes (or the web.xml file), use the
  348.   "reload" target instead.
  349.  
  350.   NOTE:  This target will only succeed if it is run from the same server that
  351.   Tomcat is running on.
  352.  
  353.   NOTE:  This is the logical opposite of the "remove" target.
  354.  
  355. -->
  356.  
  357.   <target name="install" depends="compile"
  358.    description="Install application to servlet container">
  359.  
  360.     <deploy url="${manager.url}"
  361.        username="${manager.username}"
  362.        password="${manager.password}"
  363.            path="${app.path}"
  364.        localWar="file://${build.home}"/>
  365.  
  366.   </target>
  367.  
  368.  
  369. <!-- ==================== Javadoc Target ================================== -->
  370.  
  371. <!--
  372.  
  373.   The "javadoc" target creates Javadoc API documentation for the Java
  374.   classes included in your application.  Normally, this is only required
  375.   when preparing a distribution release, but is available as a separate
  376.   target in case the developer wants to create Javadocs independently.
  377.  
  378. -->
  379.  
  380.   <target name="javadoc" depends="compile"
  381.    description="Create Javadoc API documentation">
  382.  
  383.     <mkdir          dir="${dist.home}/docs/api"/>
  384.     <javadoc sourcepath="${src.home}"
  385.                 destdir="${dist.home}/docs/api"
  386.            packagenames="*">
  387.       <classpath refid="compile.classpath"/>
  388.     </javadoc>
  389.  
  390.   </target>
  391.  
  392.  
  393.  
  394. <!-- ====================== List Target =================================== -->
  395.  
  396. <!--
  397.  
  398.   The "list" target asks the specified Tomcat 5 installation to list the
  399.   currently running web applications, either loaded at startup time or
  400.   installed dynamically.  It is useful to determine whether or not the
  401.   application you are currently developing has been installed.
  402.  
  403. -->
  404.  
  405.   <target name="list"
  406.    description="List installed applications on servlet container">
  407.  
  408.     <list    url="${manager.url}"
  409.         username="${manager.username}"
  410.         password="${manager.password}"/>
  411.  
  412.   </target>
  413.  
  414.  
  415. <!-- ==================== Prepare Target ================================== -->
  416.  
  417. <!--
  418.  
  419.   The "prepare" target is used to create the "build" destination directory,
  420.   and copy the static contents of your web application to it.  If you need
  421.   to copy static files from external dependencies, you can customize the
  422.   contents of this task.
  423.  
  424.   Normally, this task is executed indirectly when needed.
  425.  
  426. -->
  427.  
  428.   <target name="prepare">
  429.  
  430.     <!-- Create build directories as needed -->
  431.     <mkdir  dir="${build.home}"/>
  432.     <mkdir  dir="${build.home}/WEB-INF"/>
  433.     <mkdir  dir="${build.home}/WEB-INF/classes"/>
  434.  
  435.  
  436.     <!-- Copy static content of this web application -->
  437.     <copy todir="${build.home}">
  438.       <fileset dir="${web.home}"/>
  439.     </copy>
  440.  
  441.     <!-- Copy external dependencies as required -->
  442.     <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
  443.     <mkdir  dir="${build.home}/WEB-INF/lib"/>
  444. <!--
  445.     <copy todir="${build.home}/WEB-INF/lib" file="${foo.jar}"/>
  446. -->
  447.  
  448.     <!-- Copy static files from external dependencies as needed -->
  449.     <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
  450.  
  451.   </target>
  452.  
  453.  
  454. <!-- ==================== Reload Target =================================== -->
  455.  
  456. <!--
  457.  
  458.   The "reload" signals the specified application Tomcat 5 to shut itself down
  459.   and reload. This can be useful when the web application context is not
  460.   reloadable and you have updated classes or property files in the
  461.   /WEB-INF/classes directory or when you have added or updated jar files in the
  462.   /WEB-INF/lib directory.
  463.  
  464.   NOTE: The /WEB-INF/web.xml web application configuration file is not reread
  465.   on a reload. If you have made changes to your web.xml file you must stop
  466.   then start the web application. 
  467.  
  468. -->
  469.  
  470.   <target name="reload" depends="compile"
  471.    description="Reload application on servlet container">
  472.  
  473.     <reload url="${manager.url}"
  474.        username="${manager.username}"
  475.        password="${manager.password}"
  476.            path="${app.path}"/>
  477.  
  478.   </target>
  479.  
  480.  
  481. <!-- ==================== Remove Target =================================== -->
  482.  
  483. <!--
  484.  
  485.   The "remove" target tells the specified Tomcat 5 installation to dynamically
  486.   remove this web application from service.
  487.  
  488.   NOTE:  This is the logical opposite of the "install" target.
  489.  
  490. -->
  491.  
  492.   <target name="remove"
  493.    description="Remove application on servlet container">
  494.  
  495.     <undeploy url="${manager.url}"
  496.          username="${manager.username}"
  497.          password="${manager.password}"
  498.              path="${app.path}"/>
  499.  
  500.   </target>
  501.  
  502.  
  503. </project>
  504.