Use the ant tool on linux to regularly update tomcat for java web projects to automate the process.
Build. properties
Build. version = 1.8.2 includeantruntime = on svnant. jar =/jdk/jar/svnant. jar svnClientAdapter. jar =/jdk/jar/svnClientAdapter. jar svnjavahl. jar =/jdk/jar/svnjavahl. jar javaEE1.4.lib =/usr/java/jdk1.6.0 _ 18/lib debuglevel = source, lines target = 1.6 source = 1.6 work. space =/jdk/workspace dist. dir =$ {work. space} build. dir =$ {work. space}/WebRoot/WEB-INF/classes lib. dir =$ {work. space}/Web root/WEB-INF/lib java. source =$ {work. space}/src java. config =$ {work. space}/src/config web. dir =$ {work. space}/WebRoot resource. dir =$ {work. space}/resources tomcat. home =/usr/java/apache-tomcat-6.0.32/war. file =$ {dist. dir}/$ {ant. project. name }. war urlreposition = http://www.abc.com/
Build. xml
<Project basedir = "." name = "ROOT" default = "auto"> <! -- All properties are in build. properties --> <property file = "build. properties"/> <! -- The Runtime Library required by svn itself --> <path id = "svnant. lib "> <pathelement location =" $ {svnjavahl. jar} "/> <pathelement location =" $ {svnant. jar} "/> <pathelement location =" $ {svnClientAdapter. jar} "/> </path> <! -- Java EE 1.4 database --> <path id = "javaEE1.4"> <fileset dir = "$ {javaEE1.4.lib}"> <include name = "**/*. jar "/> </fileset> </path> <path id =" tomcat6.0.32 "> <fileset dir =" $ {tomcat. home} "> <include name = "**/*. jar "/> </fileset> </path> <! -- Classpath library of the project --> <path id = "project. classpath "> <pathelement location =" $ {build. dir} "/> <fileset dir =" $ {lib. dir} "> <! -- <Include name = "**/*. jar"/> --> </fileset> </path> <! -- Clear the project task (delete the download directory, the original tomcat deployment file) --> <target name = "clear"> <delete dir = "$ {work. space} "/> <delete dir =" $ {tomcat. home}/work/Catalina/localhost/$ {ant. project. name} "/> <delete dir =" $ {tomcat. home}/webapps/$ {ant. project. name} "/> <delete dir =" $ {tomcat. home}/webapps/$ {ant. project. name }. war "/> </target> <! -- Load the svn task --> <taskdef name = "svn" classname = "org. tigris. subversion. svnant. SvnTask" classpathref = "svnant. lib"/> <! -- Svn synchronization task --> <target name = "svn" depends = "clear"> <mkdir dir = "$ {work. space} "/> <svn username =" xxxxx "password =" xxxxx "javahl =" false "> <checkout url =" $ {urlRepos} "destPath =" $ {work. space} "/> </svn> </target> <! -- Compile --> <target name = "compile" depends = "svn" description = "===== compile project ===="> <echo message =" compile ==========>$ {ant. project. name }:$ {ant. file} "/> <mkdir dir =" $ {build. dir} "/> <copy includeemptydirs =" false "todir =" $ {build. dir} "> <fileset dir =" $ {java. source} "excludes = "**/*. launch ,**/*. java, config /*. * "/> </copy> <copy includeemptydirs =" false "todir =" $ {build. dir} "> <fileset dir =" $ {java. c Onfig} "excludes = "**/*. launch ,**/*. java "/> </copy> <javac includeantruntime =" false "includejavaruntime =" true "debug =" true "debuglevel =" $ {debuglevel} "destdir =" $ {build. dir} "source =" $ {source} "target =" $ {target} "encoding =" UTF-8 "> <src path =" $ {java. source} "/> <exclude name =" config/"/> <classpath> <path refid =" project. classpath "> </path> <path refid =" javaEE1.4 "> </path> <path refid =" tomcat6.0.32 "> </Path> </classpath> <compilerarg value = "-Xlint: unchecked"/> <compilerarg value = "-Xlint: deprecation"/> </javac> <! -- <Javac debug = "true" debuglevel = "$ {debuglevel}" destdir = "$ {build. dir} "source =" $ {source} "target =" $ {target} "encoding =" UTF-8 "> <src path =" $ {java. config} "/> </javac> --> </target> <! -- Compression, package --> <target name = "war" depends = "compile" description = "===== compress j2ee war file ===="> <mkdir dir = "$ {dist. dir} "/> <! -- Compress j2ee war file --> <war destfile = "$ {war. file} "webxml =" $ {web. dir}/WEB-INF/web. xml "> <fileset dir =" $ {web. dir} "/> <classes dir =" $ {build. dir} "/> <lib dir =" $ {lib. dir} "/> </war> </target> <! -- Shutdowntomcat --> <target name = "shutdowntomcat" description = "======= shutdowntomcat ========="> <exec executable = "$ {tomcat. home}/bin/shutdown. sh "failonerror =" false "> </exec> <sleep seconds =" 10 "/> </target> <! -- Startuptomcat --> <target name = "startuptomcat" description = "======= startuptomcat ========="> <sleep seconds = "5"/> <exec executable = "$ {tomcat. home}/bin/startup. sh "failonerror =" false "> </exec> </target> <! -- Deploy it under tomcat --> <target name = "deploy" depends = "war"> <copy file = "$ {war. file} "todir =" $ {tomcat. home}/webapps "/> </target> <! -- Fully automated and invincible deployment, start and close tomcat --> <target name = "auto" depends = "shutdowntomcat, deploy, startuptomcat"> <echo message = "DONE !!!! "/> </Target> </project>
Build. sh
#! /Bin/sh JAVA_HOME =/usr/java/jdk1.6.0 _ 18 ANT_HOME =/usr/java/apache-ant-1.8.2 PATH = $ ANT_HOME/bin: $ JAVA_HOME/bin: $ PATH cd/jdk/usr/java/apache-ant-1.8.2/bin/ant-f/jdk/build. xml>/jdk/ant-build.log 2> & 1
Crontab-e
25, 50 */jdk/build. sh