> -----Original Message-----
> From: Liang Chen [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 10, 2002 12:40 PM
> To: Struts Users Mailing List
> Subject: Re: struts set up question
>
>
> Hi, Mitchell:
>
>     Of course I'd like to see your scripts. Can you show me it? Thanks a
> lot.
>
> Leon
> ----- Original Message -----
> From: "James Mitchell" <[EMAIL PROTECTED]>
> To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
> Sent: Wednesday, May 08, 2002 3:58 PM
> Subject: RE: struts set up question
>
>
> > Did you look at the ant docs?
> >
> > Do you want to see my build script?
> >
> > It does the following:
> > stoptomcat - executes tomcats shutdown.bat batch file to stop tomcat
> > prep       - prepares the directory for compilation, deletes
> >              the deployed war file and extracted directory
> > compile    - compiles the project source
> > war        - creates the new war file
> > deploy     - copies the war to TOMCAT_HOME/webapps
> > cleanup    - deletes the build folder where the whole compile/war took
> place
> > starttomcat- fires up tomcat with the appropriate startup.bat
> >
> > *optional  - I also have a target for running javadoc on your project.
> >
> >              I know (with JBuilder 4+) you can add your javadoc.jar
> >              to the project and have right click context access
> >              (and I think F1) to any of your classes from anywhere
> >              in your project)
> >
> > JM
> >

* Side Note *
One of the coolest features of Ant is the ability to use your existing
environment variables within the build script.  Although I stopped using
this because I didn't want to "effectively" hard-code where TOMCAT_HOME was
on my OS.
I just let tomcat pick up the default (./) and run with it.
That way I can specify which tomcat version to deploy and run in the build
script.
I have also seen this taken a step forward where you can supply which
version on the command line that fires off your build script.

Anyway, this is just a generic example of what I commonly use.  (Consider it
a beginners template)
Once you get familiar with the standard Ant tasks try out a few of the
optional ones, you can do just about anything from  automated ftp to
compiling and running your favorite c# project (although I highly recommend
you stay away from that one ;=)

**If this doesn't help, I can set up the struts-example for you (standalone
directory structure) with its own build.xml.


Here goes, my directory structure looks like this....


+-struts-test
  +-bak            <-quick backups
  +-jsp            <-all jsp files
  +-project-files  <-files such as db schema and jokes from Mark
  +-src            <- .java files
  +-WEB-INF        <-should be obvious
    +-classes      <-same
    +-lib          <-same



and here's the build.xml
Search for all the ### you see and replace it with your info.


<project name="###Simple Struts 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-test"/>
        <property name="javadoc.deploy.to"      value="./javadoc"/>

<!--
      If you don't want to use your environment variable for TOMCAT_HOME,
then uncomment this
    <property name="TOMCAT_HOME"      value="###C:/jakarta-tomcat-4.0.3"/>

    and comment out this one -->
    <property name="TOMCAT_HOME"      value="${env.TOMCAT_HOME}"/>

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

        <path id="project.class.path">
         <!-- be sure to modify for you environment -->
       <!-- I know there is a better way to do this, but Netbeans seems to
like this way -->
                <pathelement location="./WEB-INF/lib/crimson.jar"/>
                <pathelement location="./WEB-INF/lib/jakarta-regexp-1.2.jar"/>
                <pathelement location="./WEB-INF/lib/jasper.jar"/>
                <pathelement location="./WEB-INF/lib/jaxp.jar"/>
                <pathelement location="./WEB-INF/lib/jdbc2_0-stdext.jar"/>
                <pathelement location="./WEB-INF/lib/jmail.jar"/>
                <pathelement location="./WEB-INF/lib/jms.jar"/>
                <pathelement location="./WEB-INF/lib/junit.jar"/>
                <pathelement location="./WEB-INF/lib/jta-spec1_0_1.jar"/>
                <pathelement location="./WEB-INF/lib/log4j.jar"/>
                <pathelement location="./WEB-INF/lib/log4j-core.jar"/>
                <pathelement location="./WEB-INF/lib/mail_1_2.jar"/>
                <pathelement location="./WEB-INF/lib/mm.mysql-2.0.6.jar"/>
                <pathelement location="./WEB-INF/lib/parser.jar"/>
                <pathelement location="./WEB-INF/lib/poolman.jar"/>
                <pathelement location="./WEB-INF/lib/sax.jar"/>
                <pathelement location="./WEB-INF/lib/struts.jar"/>
                <pathelement location="./WEB-INF/lib/servlet.jar"/>
                <pathelement location="./WEB-INF/lib/webserver.jar"/>
        </path>

    <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="${TOMCAT_HOME}/common/lib">
                <include name="**/*.jar"/>
            </fileset>
        -->
                <fileset dir="${basedir}/WEB-INF/lib">
                <include name="**/*.jar"/>
            </fileset>
        </classpath>

      </javac>
    </target>

<target name="javadoc">
  <delete includeEmptyDirs="true">
    <fileset dir="${basedir}/javadoc"/>
  </delete>
  <javadoc packagenames="com.###.*"
           sourcepath="${basedir}/src"
           destdir="${basedir}/javadoc"
           author="true"
           version="true"
           use="true"
           classpathref="project.class.path"
           windowtitle="### Project or Application Name here ###
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}/jsp" includes="**/*.*" />
               <webinf  dir="${basedir}/WEB-INF"
includes="**/*.tld,**/*.xml" 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

<snip/>


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

Reply via email to