-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 To whom it may concern,
On 5/25/2009 3:44 AM, List Member wrote: > Pls do send some of your scripts/configurations, it will be of great > help for us! See attached (hopefully!). Here's what's going on: 1. ant.properties goes in ~/.ant.properties and is read first 2. build.xml creates build-[appname].properties and reads it 3. build.properties is read last This allows you to set up defaults in ~/.ant.properties for all your apps, and then override them like this: tomcat-home=/usr/local/tomcat myapp.tomcat-home=/usr/local/apache-tomcat-5.5.26 You should read the entire script to understand everything that is happening. Some things to note: 1. Be sure to change the value of the "name" attribute of the <project> element in build.xml: this sets the values for a lot of things. 2. The win32 tomcat-start and tomcat-stop targets are untested. We used to use our own batch files to start Tomcat but switched to a script-less strategy a while back. None of our devs use win32 so we haven't tested the replacement strategy. There's no reason not to expect it to work, but YMMV. 3. These scripts are rigged to build a Tomcat install from an existing one. Read RUNNING.txt in a Tomcat package to see the procedure that is being followed. In the webapp's conf/ and properties/ directory, there are (optional) directories for each "release type" (you can define these to be whatever you want... we use 'dev' 'demo' and 'prod'). Config files such as tomcat-server.xml and tomcat-context.xml are read from these directories, filtered using search-and-replace, and then deposited in the correct place (conf/server.xml and yourwebapp/META-INF/context.xml). The replacements include convenient things such as JNDI DataSource information, etc. Enjoy. - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkotMGYACgkQ9CaO5/Lv0PA6aACePmwbwoLFkyIp0cE2zFlxDAKN 5s8An1xLlG5/w83SXNS0WwHUsbCeG1iP =jTMR -----END PGP SIGNATURE-----
<?xml version="1.0"?> <!-- Created July 2003 by Chris Schultz This build file should handle all compile, install, test, etc. operations required for this web application. The only external requirement for this build is an existing Tomcat installation (see property [appname].tomcat.home). --> <project name="my-project" default="" basedir="."> <!-- Note that properties are fixed once set; .ant.properties can be used to override the values of properties "set later" by various properties files, etc. --> <patternset id="properties.file.pattern" includes="**/*.properties" /> <patternset id="properties-shallow.file.pattern" includes="*.properties" /> <patternset id="class.file.pattern" includes="**/*.class" /> <patternset id="jar.file.pattern" includes="**/*.jar" /> <patternset id="taglib.file.pattern" includes="**/*.tld" /> <patternset id="xml.file.pattern" includes="**/*.xml" /> <patternset id="xml-shallow.file.pattern" includes="*.xml" /> <target name="check-local-properties"> <condition property="local-properties-ready"> <uptodate srcfile="${ant.file}" targetfile="build-${ant.project.name}.properties" /> </condition> </target> <target name="build-local-properties" depends="check-local-properties" unless="local-properties-ready"> <echo>Building build-${ant.project.name}.properties</echo> <!-- Translate properties from [appname].whatever to app.whatever --> <echo file="build-${ant.project.name}.properties"> # # Set Generic Properties for this App # [appname].java-home=${java-home} [appname].release-type=${release-type} [appname].tomcat-home=${tomcat-home} [appname].tomcat-port = ${tomcat-port} [appname].tomcat-shutdown-port = ${tomcat-shutdown-port} [appname].context.name=${ant.project.name} # Database setup [appname].database.name=${database.name} [appname].database.username=${database.username} [appname].database.password=${database.password} [appname].database.host=${database.host} [appname].database.driver=${database.driver} [appname].database.url=${database.url} [appname].database.createUrl=${database.createUrl} [appname].datasource.ref=jdbc/${[appname].database.name} # # Copy Properties to app.* # app.java-home=${[appname].java-home} app.release-type=${[appname].release-type} app.tomcat-home=${[appname].tomcat-home} app.tomcat-port=${[appname].tomcat-port} app.tomcat-shutdown-port=${[appname].tomcat-shutdown-port} app.context.name=${[appname].context.name} app.database.name=${[appname].database.name} app.database.username=${[appname].database.username} app.database.password=${[appname].database.password} app.database.host=${[appname].database.host} app.database.driver=${[appname].database.driver} app.database.url=${[appname].database.url} app.database.createUrl=${[appname].database.createUrl} app.datasource.ref=${[appname].datasource.ref} </echo> <replace file="build-${ant.project.name}.properties" token="[appname]" value="${ant.project.name}" /> </target> <target name="init" depends="build-local-properties"> <tstamp /> <!-- Load global configuration --> <property file="${user.home}/.ant.properties" /> <!-- Load local configuration --> <property file="build-${ant.project.name}.properties" /> <!-- Now, load the project properties --> <property file="build.properties" /> <path id="compile.classpath"> <fileset dir="${lib.build.dir}"> <patternset refid="jar.file.pattern" /> </fileset> </path> <path id="test.classpath"> <fileset dir="${lib.build.dir}"> <patternset refid="jar.file.pattern" /> </fileset> <fileset dir="${lib.test.dir}"> <patternset refid="jar.file.pattern" /> </fileset> <pathelement location="${build.classes.dir}" /> <pathelement location="${build.testclasses.dir}" /> </path> </target> <!-- ****************************** --> <!-- Building, etc. targets --> <!-- ****************************** --> <!-- ============================================================= config-dependancies ============================================================== This target configures some properties required for compilation. --> <target name="config-dependancies"> </target> <!-- ============================================================= check-config ============================================================== This target checks the local environment to make sure that everything is in order. --> <target name="check-config" depends="init"> <condition property="no-release-type"> <not> <isset property="app.release-type" /> </not> </condition> <fail if="no-release-type"> =========================== You must set 'release-type' =========================== Create the file ~/.ant.properties and set the following properties: release-type Notes: release-type actually points to directories underneath the ${conf.dir} and ${properties.dir} directories. These allow you to have different configurations based upon the type of build that is being done (i.e. development, production, etc.). Consult the existing directories to decide which one to use. Additionally, if you require an alternate configuration that is specific to your environment, you may simply create a new directory and use that one as the release-type. </fail> </target> <!-- ============================================================= compile ============================================================== Compiles all source files to the build directory. --> <target name="compile" description="Compiles all Java source code to the build directory" depends="init, config-dependancies"> <!-- Ensure that all necessary directories are created --> <mkdir dir="${build.dir}" /> <mkdir dir="${build.classes.dir}" /> <javac destdir="${build.classes.dir}" srcdir="${java.src.dir}" deprecation="${javac.deprecation}" classpathref="compile.classpath" debug="${javac.debug}" debuglevel="${javac.debuglevel}" source="${javac.src.spec}" /> </target> <!-- ============================================================= build ============================================================== Perpare the local build directory by compiling all classes and copying properties files, etc. into it. This target is required for any compile to that the target directories exist, and before any test so that configuration files are available for the execution of the tests. --> <target name="build" depends="check-config, compile"> <!-- Compile has already been done. We have the following left to do: - Build the WEB-INF/conf directory containing *.properties - Properly copy/filter *.template into WEB-INF/conf/*.properties --> <filter token="app-name" value="${ant.project.name}" /> <filter token="app-dir" value="${app.app.dir}" /> <filter token="app-log-dir" value="${app.log.dir}" /> <filter token="connector-port" value="${app.tomcat-port}" /> <filter token="shutdown-port" value="${app.tomcat-shutdown-port}" /> <filter token="tomcat-home" value="${app.tomcat-home}" /> <filter token="DATABASE_URL" value="${app.database.url}" /> <filter token="DATABASE_USERNAME" value="${app.database.username}" /> <filter token="DATABASE_PASSWORD" value="${app.database.password}" /> <filter token="DATABASE_DRIVER" value="${app.database.driver}" /> <filter token="DATASOURCE_REF" value="${app.datasource.ref}" /> <mkdir dir="${build.webinf.dir}" /> <mkdir dir="${build.dir}/META-INF" /> <!-- Copy any properties files to be included in the classpath --> <!-- Use ISO-8859-1 encoding so we don't clobber any odd characters --> <copy toDir="${build.classes.dir}" encoding="ISO-8859-1" filtering="yes"> <fileset dir="${properties.dir}"> <patternset refid="properties-shallow.file.pattern" /> <patternset refid="xml-shallow.file.pattern" /> </fileset> <fileset dir="${properties.dir}/${app.release-type}"> <patternset refid="properties-shallow.file.pattern" /> <patternset refid="xml-shallow.file.pattern" /> </fileset> </copy> <!-- Copy any configuration files found --> <copy toDir="${build.webinf.dir}" filtering="yes"> <fileset dir="${conf.dir}"> <include name="*.*" /> <exclude name="jk_workers.properties" /> <exclude name="web.xml" /> <exclude name="tomcat-server.xml" /> <exclude name="tomcat-users.xml" /> <exclude name="tomcat-context.xml" /> </fileset> <fileset dir="${conf.dir}/${app.release-type}"> <include name="*" /> <exclude name="jk_workers.properties" /> <exclude name="web.xml" /> <exclude name="tomcat-server.xml" /> <exclude name="tomcat-users.xml" /> <exclude name="tomcat-context.xml" /> </fileset> </copy> <copy file="${conf.dir}/${app.release-type}/tomcat-context.xml" tofile="${build.dir}/META-INF/context.xml" filtering="yes" /> </target> <!-- ****************************** --> <!-- Installation and Clean targets --> <!-- ****************************** --> <!-- ============================================================= check-tomcat-config ============================================================== A pre-requisite for doing anything with Tomcat, your ports must be set up correctly. Tomcat ports are typically set in the user's .ant.properties file in their home directory. This target aborts if the Tomcat configuration is incomplete. --> <target name="check-tomcat-config"> <condition property="missing-tomcat-config"> <or> <not> <isset property="app-base" /> </not> <not> <isset property="app.tomcat-home" /> </not> <not> <isset property="app.tomcat-port" /> </not> <not> <isset property="app.tomcat-shutdown-port" /> </not> <equals arg1="${app-base}" arg2="" /> <equals arg1="${app.tomcat-home}" arg2="" /> <equals arg1="${app.tomcat-port}" arg2="" /> <equals arg1="${app.tomcat-shutdown-port}" arg2="" /> </or> </condition> <fail if="missing-tomcat-config"> ======================== Tomcat ports are not set ======================== Create the file ~/.ant.properties and set the following properties: app-base tomcat-home tomcat-port tomcat-shutdown-port Notes: app-base is typically ~/app, tomcat-home is typically /usr/local/tomcat, tomcat-port is typically 8x85 where x is any digit and tomcat-shutdown-port is typically 8x86. Here is an axample configuration: app-base=~/app tomcat-home=/usr/local/tomcat tomcat-port=8185 tomcat-shutdown-port=8186 </fail> </target> <!-- ============================================================= prepare-local-tomcat ============================================================== In order to perform any local installation (i.e. using the 'install' target) or perform any tomcat-related functions ('tomcat-start', 'tomcat-stop', etc.), a local setup of Tomcat must exist. A "local setup" of Tomcat is actually a user-specific directory out of which a master install of Tomcat will be configured and run. For example, your "real" install of Tomcat might be in /usr/local/tomcat, while the user-specific, or "local" directory might be in ~/app/[app-name]/[tomcat-port]. This local Tomcat install contains configuration required for a user-specific instance of Tomcat that can be started, stopped, reloaded, etc. by a single user without disturbing other users with similar configurations. --> <target name="prepare-local-tomcat" depends="init,check-tomcat-config"> <filter token="app-name" value="${ant.project.name}" /> <filter token="app-dir" value="${app.app.dir}" /> <filter token="app-log-dir" value="${app.log.dir}" /> <filter token="connector-port" value="${app.tomcat-port}" /> <filter token="shutdown-port" value="${app.tomcat-shutdown-port}" /> <filter token="tomcat-home" value="${app.tomcat-home}" /> <filter token="DATABASE_URL" value="${app.database.url}" /> <filter token="DATABASE_USERNAME" value="${app.database.username}" /> <filter token="DATABASE_PASSWORD" value="${app.database.password}" /> <filter token="DATABASE_DRIVER" value="${app.database.driver}" /> <filter token="DATASOURCE_REF" value="${app.datasource.ref}" /> <mkdir dir="${app.home.dir}" /> <mkdir dir="${app.conf.dir}" /> <mkdir dir="${app.webapps.dir}" /> <mkdir dir="${app.log.dir}" /> <mkdir dir="${app.temp.dir}" /> <!-- Prepare and install Tomcat configuration files tp the application --> <!-- Copy the stock web.xml from the tomcat installation --> <copy file="${app.tomcat-home}/conf/web.xml" tofile="${app.conf.dir}/web.xml" /> <!-- Copy tomcat-server.xml to server.xml in the local Tomcat conf dir. Use filters to substitute-in the values for the connector and shutdown ports. --> <copy file="${conf.dir}/${app.release-type}/tomcat-server.xml" tofile="${app.conf.dir}/server.xml" filtering="yes" /> </target> <!-- ============================================================= install-web ============================================================== Copies all web-related material into the live directory. Use this target when no code or configuration changes have been made. --> <target name="install-web" depends="init,jar" description="Installs all non-executable web resources"> <copy toDir="${app.app.dir}"> <fileset dir="${web.dir}" includes="**/*" /> </copy> </target> <!-- ============================================================= war ============================================================== Creates a WAR file suitable for deployment on an application server. The WAR file is placed into the ${build.dir}. --> <target name="war" depends="build"> <war destfile="${build.dir}/${war.file}" webxml="${conf.dir}/web.xml" basedir="web" compress="true"> <lib dir="${lib.build.dir}"> <patternset refid="jar.file.pattern" /> <!-- TODO: Make this an excludes set somewhere --> <exclude name="servlet.jar" /> <exclude name="servletapi-*.jar" /> <!-- This is all so Tomcat won't get angry --> <exclude name="commons-dbcp*.jar" /> <exclude name="commons-pool*.jar" /> <exclude name="mysql-connector-java*.jar" /> </lib> <classes dir="${build.classes.dir}"> <patternset refid="class.file.pattern" /> <patternset refid="properties.file.pattern" /> </classes> <webinf dir="${build.webinf.dir}" /> <metainf dir="${build.dir}/META-INF" /> </war> </target> <!-- ============================================================== quick-install ============================================================== Performs a quick installation suitable for an incremental build. All configuration files, libraries, and executable code are copied into the live directory. Your server may or may not detect these changes and take appropriate actions (like restarting). --> <target name="quick-install" description="Installs the application quickly (use for incremental installs)" depends="init,prepare-local-tomcat,build"> <mkdir dir="${app.app.dir}" /> <mkdir dir="${app.webinf.dir}" /> <mkdir dir="${app.classes.dir}" /> <mkdir dir="${app.lib.dir}" /> <!-- Copy content --> <copy toDir="${app.app.dir}"> <fileset dir="${web.dir}" /> </copy> <!-- Copy web.xml and all other configuration files --> <copy toDir="${app.webinf.dir}"> <fileset dir="${build.webinf.dir}" /> <fileset dir="${conf.dir}" includes="web.xml" /> </copy> <copy file="${conf.dir}/${app.release-type}/tomcat-context.xml" tofile="${app.app.dir}/META-INF/context.xml" filtering="yes" /> <!-- Copy class files (actually all files in the classes directory) --> <copy toDir="${app.classes.dir}"> <fileset dir="${build.classes.dir}" /> </copy> <!-- Copy libraries --> <copy toDir="${app.lib.dir}"> <fileset dir="${lib.build.dir}"> <patternset refid="jar.file.pattern" /> <!-- This is all so Tomcat won't get angry --> <exclude name="servlet.jar" /> <exclude name="servletapi-*.jar" /> <exclude name="commons-dbcp*.jar" /> <exclude name="commons-pool*.jar" /> <exclude name="mysql-connector-java*.jar" /> </fileset> </copy> </target> <!-- ============================================================= jar ============================================================== Creates a JAR file. The JAR file is placed into the ${build.dir}. --> <target name="jar" depends="compile, build"> <jar destfile="${build.dir}/${jar.file}" compress="false" basedir="${build.dir}/classes"/> </target> <!-- ============================================================== install ============================================================== Performs a full installation suitable for an actual deployment. The entire application is updated all at once. Do not use this target for incremental builds or for normal edit, compile, test cycles, as the server may restart when you don't want it to. --> <target name="install" description="Installs the application" depends="prepare-local-tomcat,war,jar"> <unwar src="${build.dir}/${war.file}" dest="${app.app.dir}" /> </target> <!-- ============================================================= clean ============================================================== Removes all local configuration and classes by deleting the build directory. --> <target depends="init" name="clean" description="Removes all local compiled code and configuration."> <delete dir="${build.dir}" /> <delete file="build-${ant.project.name}.properties" /> <delete dir="${doc.dir}" /> </target> <!-- ============================================================= install-clean ============================================================== Calls the 'clean' target, then removes all user-specific Tomcat files and directories. --> <target name="install-clean" description="Removes any installed files for the application." depends="init"> <delete dir="${app.home.dir}" /> </target> <!-- ************************** --> <!-- * Unit Testing Targets * --> <!-- ************************** --> <!-- ============================================================= test ============================================================== Executes unit tests. With no options, all UnitTest.class files are invoked. If the 'test.pattern' property is set from the command-line, a single test can be run instead. This target calls two subordinate targets, 'test-stock' and 'test-custom', only one of which will execute depending on the presence of a value for 'test.pattern'. --> <target name="test" depends="build-test" description="Runs all unit tests. Use -Dtest.pattern=complete/package/TestClass.class to run a single test"> <antcall target="test-stock" /> <antcall target="test-custom" /> </target> <!-- ============================================================= compile-test ============================================================= Compiles all the test cases. --> <target name="compile-test" depends="compile"> <mkdir dir="${build.testclasses.dir}" /> <javac destdir="${build.testclasses.dir}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" classpathref="test.classpath" source="${javac.src.spec}"> <src path="${test.src.dir}" /> <include name="**/*.java" /> </javac> </target> <!-- ============================================================= build-test ============================================================= Builds the test environment. --> <target name="build-test" depends="compile-test, build"> </target> <!-- ============================================================= test-stock ============================================================== Runs all unit tests found in any package with the name UnitTest.class. --> <target name="test-stock" unless="test.pattern"> <junit printsummary="${junit.printsummary}" fork="${junit.fork}" showoutput="${junit.showoutput}" haltonfailure="yes" failureproperty="junit.failed"> <sysproperty key="conf.dir" value="${build.dir}" /> <formatter type="plain" usefile="false" /> <classpath refid="test.classpath" /> <batchtest> <fileset dir="${build.testclasses.dir}"> <include name="**/UnitTest.class" /> <include name="**/*Tests.class" /> <include name="**/*Test.class" /> </fileset> </batchtest> </junit> <fail if="junit.failed"> One or more JUnit tests failed. </fail> </target> <!-- ============================================================= test-custom ============================================================== Runs the unit test specified by the 'test.pattern' property. --> <target name="test-custom" if="test.pattern"> <junit printsummary="${junit.printsummary}" fork="${junit.fork}" showoutput="${junit.showoutput}" haltonfailure="no" failureproperty="junit.failed"> <sysproperty key="conf.dir" value="${build.dir}" /> <formatter type="plain" usefile="false" /> <classpath refid="test.classpath" /> <batchtest> <fileset dir="${build.testclasses.dir}"> <include name="${test.pattern}" /> </fileset> </batchtest> </junit> <fail if="junit.failed"> One or more JUnit tests failed. </fail> </target> <!-- ************************** --> <!-- * Tomcat Control Targets * --> <!-- ************************** --> <!-- ============================================================= tomcat-start ============================================================== Starts the user-specific instance of Tomcat. --> <target name="tomcat-start" depends="init,prepare-local-tomcat" description="Starts the Tomcat server for your port"> <echo>=============== Starting Tomcat =============== JAVA_HOME is ${app.java-home} CATALINA_BASE is ${app.home.dir} </echo> <exec os="Linux" executable="${app.tomcat-home}/bin/catalina.sh"> <env key="JAVA_HOME" value="${app.java-home}" /> <env key="CATALINA_BASE" value="${app.home.dir}" /> <arg value="start" /> </exec> <!-- Separate script for win32 --> <exec os="Windows 2000, Windows XP" executable="${app.tomcat-home}/bin/catalina.bat"> <env key="JAVA_HOME" value="${app.java-home}" /> <env key="CATALINA_BASE" value="${app.home.dir}" /> <arg value="start" /> </exec> </target> <!-- ============================================================= tomcat-stop ============================================================== Stops the user-specific instance of Tomcat. --> <target name="tomcat-stop" depends="init,prepare-local-tomcat" description="Stops the Tomcat server for your port"> <echo>=============== Stopping Tomcat =============== JAVA_HOME is ${app.java-home} CATALINA_BASE is ${app.home.dir} </echo> <exec os="Linux" executable="${app.tomcat-home}/bin/catalina.sh"> <env key="JAVA_HOME" file="${app.java-home}" /> <env key="CATALINA_BASE" file="${app.home.dir}" /> <arg value="stop" /> </exec> <!-- Separate script for win32 --> <exec os="Windows 2000, Windows XP" executable="${app.tomcat-home}/bin/catalina.bat"> <env key="JAVA_HOME" file="${app.java-home}" /> <env key="CATALINA_BASE" file="${app.home.dir}" /> <arg value="stop" /> </exec> </target> <!-- Aliases for the 'real' targets --> <target name="start-tomcat" depends="tomcat-start" /> <target name="stop-tomcat" depends="tomcat-stop" /> <!-- ============================================================= validate-yourkit-settings ============================================================== A pre-requisite for doing anything with YourKit, your settings must be set up correctly. YourKit settings should be specified by users in the .ant.properties file in their home directory. This target sets the 'yourkit-required' property if the settings are not set correctly. It should only really be called from the 'require-yourkit-settings target. --> <target name="validate-yourkit-settings"> <condition property="yourkit-required"> <not> <isset property="yourkit.library.dir" /> </not> </condition> <!-- Default options is "" --> <property name="yourkit.options" value="" /> </target> <!-- ============================================================= require-yourkit-settings ============================================================== This target invokes the 'validate-yourkit-settings' target and then executes only if the 'yourkit-required' property is set. In this case, one or more settings have not been configured correctly. --> <target name="require-yourkit-settings" depends="validate-yourkit-settings" if="yourkit-required"> <fail> ================================= YourKit settings are incorrect ================================= Please set the following properties in your .ant.properties file: yourkit.library.dir yourkit.options [optional] Here is an example configuration: yourkit.library.dir=/usr/local/yourkit/bin/linux-x86-32 yourkit.options=port=10005,disablealloc </fail> </target> <!-- ============================================================= tomcat-start-yourkit ============================================================== Starts the user-specific instance of Tomcat. --> <target name="tomcat-start-yourkit" depends="init,prepare-local-tomcat,require-yourkit-settings" description="Starts the Tomcat server in profiling mode for YourKit"> <echo>=============== Starting Tomcat =============== JAVA_HOME is ${app.java-home} CATALINA_BASE is ${app.home.dir} JAVA_OPTS is ${java.opts.value} </echo> <exec os="Linux" executable="${app.tomcat-home}/bin/catalina.sh"> <env key="JAVA_HOME" value="${app.java-home}" /> <env key="CATALINA_BASE" value="${app.home.dir}" /> <env key="JAVA_OPTS" value="-agentpath:${yourkit.library.dir}/libyjpagent.so=${yourkit.options}" /> <arg value="start" /> </exec> <!-- Separate script for win32 --> <exec os="Windows 2000, Windows XP" executable="${scripts.dir}\tomcat.bat"> <env key="JAVA_HOME" value="${app.java-home}" /> <env key="CATALINA_BASE" value="${app.home.dir}" /> <env key="JAVA_OPTS" value="-agentpath:${yourkit.library.dir}/yjpagent.dll=${yourkit.options}" /> <arg value="start" /> </exec> </target> <!-- ============================================================= backup ============================================================== Backup the application database's non-static tables. --> <target name="backup" depends="init" description="Backup the project database NON-STATIC DATA ONLY."> <!-- Create a readable timestamp --> <tstamp> <format property="todays-date" pattern="yyyy-MM-dd" /> </tstamp> <!-- Make sure backup directory exists --> <mkdir dir="${backup.dir}" /> <!-- Create a backup filename property for future reference --> <property name="backup-file-name" value="${app.database.name}-backup-data-${todays-date}.sql" /> <property name="backup-file-path" location="${backup.dir}/${backup-file-name}" /> <echo file="${backup.dir}/backup.log" append="true">Starting backup: ${todays-date} </echo> <!-- Execute the mysqldump --> <exec executable="mysqldump" dir="${backup.dir}" output="${backup.dir}/backup.log" append="true"> <!-- All mysql specific create statements, don't write Table creation info, Complete inserts --> <arg value="-atc" /> <arg value="--single-transaction" /> <arg value="--no-autocommit" /> <arg value="--host=${app.database.host}" /> <arg value="--user=${app.database.username}" /> <arg value="--password=${app.database.password}" /> <arg value="--result-file=${backup-file-path}" /> <arg value="${app.database.name}" /> <!-- List database tables as arguments in the order in which they must be dumped. --> <!-- <arg value="my_database_table" /> --> </exec> <echo file="${backup.dir}/backup.log" append="true">Backup Completed: ${todays-date} </echo> </target> <!-- ============================================================= full-backup ============================================================= Backup the entire application database. --> <target name="full-backup" depends="init" description="Backup the entire project database, including table structure, etc."> <!-- Create a readable timestamp --> <tstamp> <format property="todays-date" pattern="yyyy-MM-dd" /> </tstamp> <!-- Make sure backup directory exists --> <mkdir dir="${backup.dir}" /> <!-- Create a backup filename property for future reference --> <property name="backup-file-name" value="${app.database.name}-backup-full-${todays-date}.sql" /> <property name="backup-file-path" location="${backup.dir}/${backup-file-name}" /> <echo file="${backup.dir}/backup.log" append="true">Starting backup: ${todays-date} </echo> <!-- Execute the mysqldump --> <exec executable="mysqldump" dir="${backup.dir}" output="${backup.dir}/backup.log" append="true"> <!-- All mysql specific create statements, Complete inserts --> <arg value="-vac" /> <arg value="--single-transaction" /> <arg value="--no-autocommit" /> <arg value="--host=${app.database.host}" /> <arg value="--user=${app.database.username}" /> <arg value="--password=${app.database.password}" /> <arg value="--result-file=${backup-file-path}" /> <arg value="${app.database.name}" /> <!-- List database tables as arguments in the order in which they must be dumped. --> <!-- <arg value="my_database_table" /> --> </exec> <echo file="${backup.dir}/backup.log" append="true">Backup Completed: ${todays-date} </echo> </target> <!-- ******************************* --> <!-- * Documentation Targets * --> <!-- ******************************* --> <!-- ============================================================= doc ============================================================== Builds all the project documentation. --> <target name="doc"> <delete dir="${doc.dir}" /> <!-- start from scratch --> <antcall target="javadoc" /> </target> <!-- ============================================================= javadoc ============================================================== Builds the javadoc documentation for the project. --> <target name="javadoc" description="Builds project JavaDoc"> <mkdir dir="${javadoc.dir}" /> <javadoc packagenames="${javadoc.packages}" excludepackagenames="${javadoc.packages.exclude}" destdir="${javadoc.dir}" author="${javadoc.author}" version="${javadoc.version}" classpathref="compile.classpath" access="${javadoc.access}" use="${javadoc.use}" Windowtitle="${javadoc.title}" Doctitle="${javadoc.title}" source="${src.spec}" > <sourcepath> <pathelement location="${java.src.dir}" /> </sourcepath> <!-- Links the JavaDoc to other useful online javadocs --> <!-- Choose your Java API version --> <!-- <link href="http://java.sun.com/j2se/1.4.2/docs/api/" /> --> <link href="http://java.sun.com/j2se/1.5.0/docs/api" /> <!-- <link href="http://java.sun.com/j2se/1.6.0/docs/api" /> --> <!-- Choose your Servlet API version --> <!-- <link href="http://java.sun.com/products/servlet/2.3/javadoc" /> --> <link href="http://java.sun.com/products/servlet/2.4/javadoc" /> <!-- <link href="http://java.sun.com/products/servlet/2.5/docs/servlet-2_5-mr2/" /> --> </javadoc> </target> </project>
# ------------------------------------------------------------------- # # P R O J E C T P R O P E R T I E S # # ------------------------------------------------------------------- # # build.properties # # This file configures many properties for building this application # using ant. # # # Path settings # src.dir = src java.src.dir = ${src.dir}/java test.src.dir = ${src.dir}/test lib.dir = lib lib.build.dir = ${lib.dir}/build lib.test.dir = ${lib.dir}/test doc.dir = doc build.dir = build build.classes.dir = ${build.dir}/classes build.testclasses.dir = ${build.dir}/tests # # Project source settings # backup.dir = backup conf.dir = conf properties.dir = properties scripts.dir = ${basedir}/scripts web.dir = web # # Compilation settings # javac.deprecation=off javac.debug=true javac.debuglevel=lines,vars,source javac.src.spec=1.5 # # JavaDoc configuration # javadoc.dir=${doc.dir}/javadoc javadoc.packages=* javadoc.packages.exclude= javadoc.author=true javadoc.version=true javadoc.access=protected javadoc.use=true javadoc.title=My Project Javadoc # # JUnit configuration # junit.printsummary=on junit.showoutput=withOutAndErr junit.fork=true # # Generic build configuration # build.webinf.dir = ${build.dir}/WEB-INF # # Installation settings # # WARNING: Do not change any of the following unless you know what # you are doing. # jar.file=${app.context.name}.war war.file=${app.context.name}.war app.home.dir=${app-base}/${ant.project.name}/${app.tomcat-port} app.webapps.dir=${app.home.dir}/webapps app.log.dir=${app.home.dir}/logs app.conf.dir=${app.home.dir}/conf app.temp.dir=${app.home.dir}/temp app.app.dir=${app.webapps.dir}/${app.context.name} app.webinf.dir=${app.app.dir}/WEB-INF app.classes.dir=${app.webinf.dir}/classes app.lib.dir=${app.webinf.dir}/lib
# # Global peroperties # # Release type = what type of release are we doing? release-type=dev # Default paths tomcat-home=/usr/local/tomcat java-home=/usr app-base=/home/you/app # Yourkit setup yourkit.library.dir=${user.home}/yjp-8.0.6/bin/linux-x86-32 yourkit.port=10005 # Default database properties database.username=scott database.password=toger database.target=mysql database.host=localhost.localdomain database.driver=com.mysql.jdbc.Driver ## ## Application configuration ## # # myapp # myapp.tomcat-port=8185 myapp.tomcat-shutdown-port=8186 myapp.database.name=resource myapp.database.url=jdbc:mysql://${database.host}/${resource.database.name}?zeroDateTimeBehavior=convertToNull # # myotherapp # myotherapp.tomcat-port=8285 myotherapp.tomcat-shutdown-port=8286 myotherapp.database.name=resource myoptherapp.database.url=jdbc:mysql://${database.host}/${resource-search.database.name}?characterEncoding=utf8&dumpQueriesOnException=true
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org