I've attached my build.xml (with changes to IPs and passwords :))

The kind of setup I'd recommend is this:
local developer machines (windows, linux, bsd, whatever....) running local copies of tomcat, eclipse for an IDE attached to your CVS repository and ant either run from command line, or launched from within the eclipse itself with the appropriate client. Now the deploy to staging need to be done, but I'm sure you can research that part. Get the files from CVS for your local copy and then pushing those to production or staging. You'll need an ant target that uses ftp or something or rsync or scp would work too....


Paul Sundling


SuniX wrote:


Thank you
Can you give an example of ant source whick "reload and deploy" to a tomcat server? It can help me.
Thanks


Paul Sundling wrote:

I'm not sure why you'd want to have it deployed automatically. You can probably do it with ant and cruise control?
With ant, you can create targets that reload your app or deploy it to a tomcat server. That's what I do currently and it even integrates well with eclipse!
If you really want to do it automatically I heard cruise control does that sort of functionality, but I'm not sure about having it look for changes in CVS.


SuniX wrote:

Hi
Is there a way to use CVS with tomcat ?
i want my tomcat server to check a cvs project and deployed it automaticaly. (cvs server and tomcat server in the same machine running on a debian testing)




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




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


<!-- A "project" describes a set of targets that may be requested
     when Ant is executed.  The "default" attribute defines the
     target which is executed if no specific target is requested,
     and the "basedir" attribute defines the current working directory
     from which Ant executes the requested task.  This is normally
     set to the current working directory.
-->
<project name="Gladiator" default="compile" basedir=".">



<!-- ===================== Property Definitions =========================== -->

<!--
  Each of the following properties are used in the build script.
  Values for these properties are set by the first place they are
  defined, from the following list:
  * Definitions on the "ant" command line (ant -Dcatalina.home=xyz compile)
  * Definitions from a "build.properties" file in the top level
    source directory
  * Definitions from a "build.properties" file in the developer's
    home directory
  * Default definitions in this build.xml file

  You will note below that property values can be composed based on the
  contents of previously defined properties.  This is a powerful technique
  that helps you minimize the number of changes required when your development
  environment is modified.  Note that property composition is allowed within
  "build.properties" files as well as in the "build.xml" script.
-->
<!-- The only properties we need is TOMCAT_HOME, so we get it from the environment 
  <property file="build.properties"/>
  <property file="${user.home}/build.properties"/>
-->
<property environment="env"/>


<!-- ==================== File and Directory Names ======================== -->

<!--

  These properties generally define file and directory names (or paths) that
  affect where the build process stores its outputs.

  app.name             Base name of this application, used to
                       construct filenames and directories.
                       Defaults to "myapp".

  app.version          Version identifier for this application.

  build.home           The directory into which the "prepare" and
                       "compile" targets will generate their output.
                       Defaults to "build".

  catalina.home        The directory in which you have installed
                       a binary distribution of Tomcat 4.  This will
                       be used by the "deploy" target.

  deploy.home          The name of the directory into which the
                       deployment hierarchy will be created, and into
                       which the build directory will be copied.
                       Defaults to "${catalina.home}/webapps/${app.name}".

  dist.home            The name of the base directory in which
                       distribution files are created.
                       Defaults to "dist".

-->

  <property name="app.name"      value="gladiator"/>
  <property name="app.version"   value="1.0"/>
  <property name="build.home"    value="build"/>
  <property name="catalina.home" value="${env.TOMCAT_HOME}"/>
  <property name="deploy.home"   value="${catalina.home}/webapps/${app.name}"/>
  <property name="dist.home"     value="dist"/>
  <property name="webapp.libs"   value="web/WEB-INF/lib"/>
  <property name="local.tomcat.username" value="admin"/>
  <property name="local.tomcat.password" value="mypassword"/>
  <property name="staging.tomcat.username" value="${local.tomcat.username}"/>
  <property name="staging.tomcat.password" value="${local.tomcat.password}"/>
  <property name="production.tomcat.username" value="${local.tomcat.username}"/>
  <property name="production.tomcat.password" value="${local.tomcat.password}"/> 

<!--  ==================== Compilation Control Options ==================== -->
<!--

  These properties control option settings on the Javac compiler when it
  is invoked using the <javac> task.

  compile.debug        Should compilation include the debug option?
  compile.deprecation  Should compilation include the deprecation option?
  compile.optimize     Should compilation include the optimize option?

-->

  <property name="compile.debug"       value="true"/>
  <property name="compile.deprecation" value="false"/>
  <property name="compile.optimize"    value="true"/>

<!-- ==================== External Dependencies =========================== -->
<!--

  Use property values to define the locations of external JAR files on which
  your application will depend.  In general, these values will be used for
  two purposes:
  * Inclusion on the classpath that is passed to the Javac compiler
  * Being copied into the "/WEB-INF/lib" directory during execution
    of the "deploy" target.

  Because we will automatically include all of the Java classes that Tomcat 4
  exposes to web applications, we will not need to explicitly list any of those
  dependencies.  You only need to worry about external dependencies for JAR
  files that you are going to include inside your "/WEB-INF/lib" directory.

-->

<!-- Dummy external dependency -->
<!--
  <property name="foo.jar"
           value="/path/to/foo.jar"/>
-->


<!-- ==================== Compilation Classpath =========================== -->
<!--

  Rather than relying on the CLASSPATH environment variable, Ant includes
  features that makes it easy to dynamically construct the classpath you
  need for each compilation.  The example below constructs the compile
  classpath to include the servlet.jar file, as well as the other components
  that Tomcat makes available to web applications automatically, plus anything
  that you explicitly added.

-->

  <path id="compile.classpath">
    <!-- Include all JAR files that will be included in /WEB-INF/lib -->
    <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
<!--
    <pathelement location="${foo.jar}"/>
-->

    <!-- Include all elements that Tomcat exposes to applications -->
    <pathelement location="${catalina.home}/common/classes"/>
    <fileset dir="${catalina.home}/common/lib">
      <include name="*.jar"/>
    </fileset>
    <!-- Include all elements in the webapp's lib directory -->
    <fileset dir="${webapp.libs}">
       <include name="*.jar"/>
    </fileset>
    <!--pathelement location="${catalina.home}/classes"/>
    <fileset dir="${catalina.home}/lib">
      <include name="*.jar"/>
    </fileset-->

  </path>



<!-- ==================== All Target ====================================== -->

<!--

  The "all" target is a shortcut for running the "clean" target followed
  by the "compile" target, to force a complete recompile.

-->

  <target name="all" depends="clean,compile,deploy,reload"
   description="Clean build and dist, then compile"/>



<!-- ==================== Clean Target ==================================== -->
<!--

  The "clean" target deletes any previous "build" and "dist" directory,
  so that you can be ensured the application can be built from scratch.

-->

  <target name="clean"
   description="Delete old build and dist directories">
    <delete dir="${build.home}"/>
    <delete dir="${dist.home}"/>
  </target>

<!-- ==================== Prepare Target ================================== -->
<!--

  The "prepare" target is used to create the "build" destination directory,
  and copy the static contents of your web application to it.  If you need
  to copy static files from external dependencies, you can customize the
  contents of this task.

  Normally, this task is executed indirectly when needed.

-->

  <target name="prepare">

    <!-- Create build directory and copy static content -->
    <mkdir  dir="${build.home}"/>
    <copy todir="${build.home}">
      <fileset dir="web"/>
    </copy>

    <!-- Copy external dependencies as required -->
    <!-- *** CUSTOMIZE HERE AS REQUIRED BY YOUR APPLICATION *** -->
    <mkdir  dir="${build.home}/WEB-INF/lib"/>
<!--
    <copy todir="${build..home}/WEB-INF/lib" file="${foo.jar}"/>
-->

    <!-- Copy static files from external dependencies as needed -->

  </target>


<!-- ==================== Compile Target ================================== -->
<!--

  The "compile" target transforms source files (from your "src" directory)
  into object files in the appropriate location in the build directory.
  This example assumes that you will be including your classes in an
  unpacked directory hierarchy under "/WEB-INF/classes".

-->

  <target name="compile" depends="prepare"
   description="Compile Java sources">
  <fail unless="env.TOMCAT_HOME">
	This build script requires TOMCAT_HOME to be set
  </fail>
    <!-- Compile Java classes as necessary -->
    <mkdir    dir="${build.home}/WEB-INF/classes"/>
    <javac srcdir="src"
          destdir="${build.home}/WEB-INF/classes"
           debug="${compile.debug}"
     deprecation="${compile.deprecation}"
        optimize="${compile.optimize}">
        <classpath refid="compile.classpath"/>
    </javac>

    <!-- Copy associated resource files -->
    <copy  todir="${build.home}/WEB-INF/classes">
    <fileset dir="src" includes="**/*.properties"/>
    </copy>

  </target>

<!-- ==================== Deploy Target =================================== -->
<!--

  The "deploy" target copies the contents of the build directory into a
  location required by our servlet container, and picks up any external
  dependencies along the way.  After restarting the servlet container, you
  can now test your web application.

-->

  <target name="deploy" depends="compile"
   description="Deploy application to servlet container">

  <fail unless="env.TOMCAT_HOME">
	This build script requires TOMCAT_HOME to be set
  </fail>
    <!-- Copy the contents of the build directory -->
    <echo>deploy.home is ${deploy.home}</echo>
    <echo>catalina.home is ${catalina.home}</echo>
    <mkdir     dir="${deploy.home}"/>
    <copy    todir="${deploy.home}">
      <fileset dir="${build.home}"/>
    </copy>

  </target>

<!-- ==================== Javadoc Target ================================== -->
<!--

  The "javadoc" target creates Javadoc API documentation for the Java
  classes included in your application.  Normally, this is only required
  when preparing a distribution release, but is available as a separate
  target in case the developer wants to create Javadocs independently.

-->

  <target name="javadoc" depends="compile"
   description="Create Javadoc API documentation">

    <mkdir          dir="${dist.home}/docs/api"/>
    <javadoc sourcepath="src"
                destdir="${dist.home}/docs/api"
           packagenames="*">
      <classpath refid="compile.classpath"/>
    </javadoc>

  </target>

<!-- ==================== Dist Target ===================================== -->
<!--

  The "dist" target creates a binary distribution of your application
  in a directory structure ready to be archived in a tar.gz or zip file.
  Note that this target depends on two others:
  * "deploy" so that the entire web application (including external
    dependencies) will have been assembled
  * "javadoc" so that the application Javadocs will have been created

-->

  <target name="dist" depends="deploy,javadoc"
   description="Create binary distribution">

    <!-- Copy documentation subdirectory -->
    <copy    todir="${dist.home}/docs">
      <fileset dir="docs"/>
    </copy>

    <!-- Create application JAR file -->
    <jar jarfile="${dist.home}/${app.name}.war"
         basedir="${deploy.home}"/>

    <!-- Copy additional files to ${dist.home} as necessary -->

  </target>


<!-- ==================== Tomcat List Target ================================== -->

  <target name="list-catalina-apps" description="List Apps on Local Tomcat">
    <get src="http://127.0.0.1:8080/manager/list";
    dest="status.txt"
    username="${local.tomcat.username}"
    password="${local.tomcat.password}" />
    <loadfile property="catalina.applist" srcFile="status.txt" />
    <echo>${catalina.applist}</echo>
    <delete file="status.txt"/>
  </target>
  
  <!-- ==================== Tomcat Reload Target ================================== -->

  <target name="reload" depends="deploy" description="Reloads Tomcat Application (Local)">
    <get src="http://127.0.0.1:8080/manager/reload?path=/${app.name}";
    dest="status.txt"
    username="${local.tomcat.username}"
    password="${local.tomcat.password}" />
    <loadfile property="catalina.reload" srcFile="status.txt" />
    <echo>${catalina.reload}</echo>
    <delete file="status.txt"/>
  </target>

  <!-- ==================== Tomcat Start Target ================================== -->

  <target name="start" depends="deploy" description="Starts Tomcat Application (Local)">
    <get src="http://127.0.0.1:8080/manager/start?path=/${app.name}";
    dest="status.txt"
    username="${local.tomcat.username}"
    password="${local.tomcat.password}" />
    <loadfile property="catalina.start" srcFile="status.txt" />
    <echo>${catalina.start}</echo>
    <delete file="status.txt"/>
  </target>

<!-- ==================== Staging Tomcat List Target ================================== -->

  <target name="staging-list-apps" description="List Apps on Staging Tomcat">
    <get src="http://12.12.12.12:8080/manager/list";
    dest="status.txt"
    username="${staging.tomcat.username}"
    password="${staging.tomcat.password}" />
    <loadfile property="catalina.applist" srcFile="status.txt" />
    <echo>${catalina.applist}</echo>
    <delete file="status.txt"/>
  </target>
  
  <!-- ==================== Staging Tomcat Reload Target ================================== -->

  <target name="staging-reload" depends="deploy" description="Reloads Tomcat Application(Staging)">
    <get src="http://12.12.12.12:8080/manager/reload?path=/${app.name}";
    dest="status.txt"
    username="${staging.tomcat.username}"
    password="${staging.tomcat.password}" />
    <loadfile property="catalina.reload" srcFile="status.txt" />
    <echo>${catalina.reload}</echo>
    <delete file="status.txt"/>
  </target>

  <!-- ==================== Staging Tomcat Start Target ================================== -->

  <target name="staging-start" depends="deploy" description="Restarts Tomcat Application(Staging)">
    <get src="http://12.12.12.12:8080/manager/start?path=/${app.name}";
    dest="status.txt"
    username="${staging.tomcat.username}"
    password="${staging.tomcat.password}" />
    <loadfile property="catalina.start" srcFile="status.txt" />
    <echo>${catalina.start}</echo>
    <delete file="status.txt"/>
  </target>
 
  <!-- ==================== Production Tomcat List Target ================================== -->

  <target name="production-list-apps" description="List Production Apps">
    <get src="http://216.101.101.101:8080/manager/list";
    dest="status.txt"
    username="${production.tomcat.username}"
    password="${production.tomcat.password}" />
    <loadfile property="catalina.applist" srcFile="status.txt" />
    <echo>${catalina.applist}</echo>
    <delete file="status.txt"/>
  </target>
  
  <!-- ==================== Production Tomcat Reload Target ================================== -->

  <target name="production-reload" depends="deploy" description="Reloads Tomcat Application(Production)">
    <get src="http://216.101.101.101:8080/manager/reload?path=/${app.name}";
    dest="status.txt"
    username="${production.tomcat.username}"
    password="${production.tomcat.password}" />
    <loadfile property="catalina.reload" srcFile="status.txt" />
    <echo>${catalina.reload}</echo>
    <delete file="status.txt"/>
  </target>

  <!-- ==================== Production Tomcat Start Target ================================== -->

  <target name="production-start" depends="deploy" description="Restarts Tomcat Application(Production)">
    <get src="http://216.101.101.101:8080/manager/start?path=/${app.name}";
    dest="status.txt"
    username="${production.tomcat.username}"
    password="${production.tomcat.password}" />
    <loadfile property="catalina.start" srcFile="status.txt" />
    <echo>${catalina.start}</echo>
    <delete file="status.txt"/>
  </target>
</project>

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

Reply via email to