Here's one of my current build files for a little side project I am
doing....

my directory structure looks like this....


+-struts-test
  +-bak            <-quick backups
  +-content        <-all html, gif, jpg, etc, etc
  +-project-files  <-files such as db schema
  +-src            <- .java files
  +-WEB-INF        <-should be obvious
    +-jsp          <-all jsp files
    +-classes      <-same
    +-lib          <-same



<project name="Struts-Example Modified for Mysql (sxm4m) App" default="main"
basedir=".">

<!-- This allows you to use your own environment variables -->
    <property environment="env"/>

    <property name="build.compiler"   value="classic"/>
    <property name="build.dir"        value="./build" />
    <property name="class.dir"        value="./src" />
    <property name="warFile"          value="struts-mysql-example"/>
        <property name="javadoc.deploy.to"      value="./javadoc"/>

        <!--
      If you don't want to use your environment variable for TOMCAT_HOME,
then uncomment this
      and comment out this one
      -->

    <property name="TOMCAT_HOME"      value="C:/jakarta-tomcat-4.0.3"/>
<!--<property name="TOMCAT_HOME"      value="${env.TOMCAT_HOME}"/>-->

    <property name="deploy.dir"       value="${TOMCAT_HOME}/webapps"/>

    <target name="prep">
        <delete file="${basedir}/${warFile}.war" />
        <mkdir dir="${build.dir}"/>

        <copy todir="${build.dir}">
              <fileset dir="${class.dir}" includes="**/*.properties"/>
        </copy>
    </target>

    <target name="compile">
      <javac srcdir="${basedir}/src"
               destdir="${build.dir}" >
        <include name="**/*.java"/>
        <classpath>
                <fileset dir="${basedir}/WEB-INF/lib">
                <include name="**/*.jar"/>
            </fileset>

                <fileset dir="${TOMCAT_HOME}/common/lib">
                <include name="servlet.jar"/>
            </fileset>

        </classpath>
      </javac>
    </target>

<!--
<target name="javadoc">
  <delete includeEmptyDirs="true">
    <fileset dir="${basedir}/javadoc"/>
  </delete>
  <javadoc packagenames="org.opentools.sxm4m.*"
           sourcepath="${basedir}/src"
           destdir="${basedir}/javadoc"
           author="true"
           version="true"
           use="true"
           classpathref="project.class.path"
           windowtitle="Struts-Example Modified for Mysql support
Documentation"
           bottom="&lt;i&gt;Copyright &#169; 2002 ### , Inc. All Rights
Reserved.&lt;/i&gt;">
  </javadoc>
  <jar jarfile="${javadoc.deploy.to}/javadoc/###-docs.jar"
basedir="${basedir}/javadoc" includes="**/*" />
</target>
-->

    <target name="war">
        <war warfile="${warFile}.war" webxml="WEB-INF/web.xml" >
               <fileset dir="${basedir}/content" includes="**/*.*" />
               <webinf  dir="${basedir}/WEB-INF"
includes="**/*.tld,**/*.xml, **/*.jsp" excludes="web.xml"/>
               <lib     dir="${basedir}/WEB-INF/lib" />
               <classes dir="${build.dir}" excludes="*.xml"/>
        </war>
    </target>

    <target name="deploy">
        <delete dir="${deploy.dir}/${warFile}" includeEmptyDirs="true" />
        <copy todir="${deploy.dir}">
          <fileset dir="${basedir}" includes="${warFile}.war"/>
        </copy>
    </target>

    <target name="cleanup">
        <delete dir="${build.dir}" includeEmptyDirs="true" />
    </target>

    <target name="stoptomcat">
       <exec dir="${basedir}" executable="cmd.exe">
         <arg line="/c ${TOMCAT_HOME}/bin/shutdown"/>
       </exec>
    </target>

    <target name="starttomcat">
       <exec dir="${basedir}" executable="cmd.exe">
         <arg line="/c ${TOMCAT_HOME}/bin/startup"/>
       </exec>
    </target>

<target name="main" depends="stoptomcat, prep, compile, war, deploy,
cleanup, starttomcat"/>
<target name="testwar" depends="prep, war"/>

</project>


JM

> -----Original Message-----
> From: Leanne, Mui [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 10, 2002 10:30 PM
> To: '[EMAIL PROTECTED]'
> Subject: How to Deploy file in hierarchy structure by build.xml
>
>
> Hi,
>
>       Have anyone ever tried to use Ant to deploy file by build.xml? If I
> want to compile and deploy file as following structure, how can I make my
> build.xml?
>   $tomcat_home\test\build\WEB-INF
>                                            |_classes
>                                                     |_catalog (it has
> test1.class, test2.class)
>                                                     |_include (it has
> test3.class, test4.class)
>
> Where should I place the Java files? Is it place under src directory? Can
> you provide an simple example to tell me how to deploy project in package
> hierarchy?
> My code doesn't deploy class file in package hierarchy, but it deploy as
> following structure:
>   $tomcat_home\test\build\WEB-INF
>                                                |_classes (it has
> test1.class
> ~ test4.class)
> My code:
> <project name="test" default="dist" basedir=".">
> <!-- set global properties for this build -->
> <property name="context" value="test"/>
> <property name="dist" value="dist"/>
> <property name="src" value="src"/>
> <property name="build" value="build"/>
>        :
> <target name="init">
> <!-- Create the build directory structure used by compile -->
>       <mkdir dir="${build}"/>
>       <mkdir dir="${build}/WEB-INF"/>
>       <mkdir dir="${build}/WEB-INF/classes"/>
>       <mkdir dir="${build}/WEB-INF/lib"/>
> :
> </target>
> <target name="compile" depends="init">
>       <!-- Compile the java code from ${src} into ${build}/WEB-INF/classes
> -->
>       <javac srcdir="${src}" destdir="${build}/WEB-INF/classes" debug="on"
>               extdirs="${lib}" deprecation="on" />
>       <copy preservelastmodified="yes" todir="${build}/WEB-INF/classes">
>               <fileset dir="${src}" includes="**/*.properties">
>               </fileset>
>       </copy>
>       <!-- Copy files from ${web} to ${build} -->
>       <copy preservelastmodified="yes" todir="${build}/web">
>               <fileset dir="${web}" excludes="**/*.bak">
>               </fileset>
>       </copy>
> </target>
>
> <target name="dist" depends="compile">
>       <!-- Delete any directories expanded from the web archive in the
> ${dist}directory tree -->
>       <delete dir="${dist}/${context}"/>
>
>       <!-- Create the distribution directory -->
>       <mkdir dir="${dist}"/>
>       <!-- Put everything in ${build} into the ${dist}/${context}.war file
> -->
>       <jar jarfile="${dist}/${context}.war" basedir="${build}"/>
> </target>
> </project>
> Can anyone tell me how to fix it?
>
>
> Best Regards,
>
> Leanne
>
>
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to