The first goal of recent research on automatic building of projects is to use ant scripts to checkout source code compilation from the repository to the Tomcat WebApp and publish the project. It has been implemented and recorded the relevant things. Related resources and code mainly from the network, and then modify their own debugging through, and then improve the details of some of the instructions, I hope to have the need to help people, because the whole process before and after dragging a lot of time, may be less complete steps, if encountered in the process of any anomalies please note.
Download related resources.
1 Download Ant
http://ant.apache.org/bindownload.cgi
Add bin to PATH environment variable
2 Download Svnant
Http://subclipse.tigris.org/svnant.html
3 Download Subversion
Http://subversion.apache.org/packages.html
Add bin to PATH environment variable
4 Download Tomcat
http://tomcat.apache.org/download-60.cgi
Configure CATALINA_HOME environment variable for tomcat installation directory
<project basedir= "." Name= "TPO" default= "Auto" >
<!--all parameters are in Build.properties file-->
<property file= "Build.properties"/>
<!--svnant Support Library-->
<path id= "Svnant.lib" >
<pathelement location= "${svnjavahl.jar}"/>
<pathelement location= "${svnant.jar}"/>
<pathelement location= "${svnclientadapter.jar}"/>
</path>
Classpath Library--> for <!--project
<path id= "Project.classpath" >
<pathelement location= "${build.dir}"/>
<fileset dir= "${lib.dir}"/>
</path>
<!--clean up the projects deployed before Tomcat-->
<target name= "Clear" >
<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 Sync task-->
<target name= "svn" depends= "clear" >
<mkdir dir= "${work.space}"/>
<SVN username= "${svn.username}" password= "${svn.password}" javahl= "false" >
<checkout url= "${svn.url}" destpath= "${work.space}"/>
</svn>
</target>
<!--compiling-->
<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>
<javac includejavaruntime= "true" debug= "true" Debuglevel= "${debuglevel}" destdir= "${build.dir" source= "${source" } "target=" ${target} "encoding=" Utf-8 ">
<src path= "${java.source}"/>
<SRC path= "E:/anttest/tpo/src-framework"/>
<SRC path= "e:/anttest/tpo/src-org"/>
<SRC path= "E:/anttest/tpo/src-other"/>
<SRC path= "E:/anttest/tpo/src-example"/>
<classpath>
<path refid= "Project.classpath" >
</path>
</classpath>
</javac>
</target>
<!--compression, packaging-->
<target name= "war" depends= "Compile" description= "======compress java-ee war file======" >
<mkdir dir= "${dist.dir}"/>
<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>
<!--close Tomcat-->
<target name= "Shutdowntomcat" description= "========shutdowntomcat===========" >
<exec executable= "${tomcat.home}/bin/shutdown.bat" failonerror= "false" ></exec>
<sleep seconds= "Ten"/>
</target>
<!--start tomcat-->
<target name= "Startuptomcat" description= "========startuptomcat===========" >
<sleep seconds= "5"/>
<exec executable= "${tomcat.home}/bin/startup.bat" failonerror= "false" ></exec>
</target>
<!--Copy the Project War package to tomcat/webapps-->
<target name= "Deploy" depends= "war" >
<copy file= "${war.file}" todir= "${tomcat.home}/webapps"/>
</target>
<!--turn Tomcat off, deploy, start Tomcat if Tomcat executes deploy and startuptomcat--> directly in shutdown state
<!--<target name= "Auto" depends= "Deploy,startuptomcat" >-->
<target name= "Auto" depends= "Shutdowntomcat,deploy,startuptomcat" >
<echo message= "done!!!!"/>
</target>
</project>
Build.properties file content (the path in which the relevant path is modified to its own package)
build.version=1.0.0
Svnant.jar=d:/program Files/apache-ant-1.8.2/lib/svnant.jar
Svnclientadapter.jar=d:/program Files/apache-ant-1.8.2/lib/svnclientadapter.jar
Svnjavahl.jar=d:/program Files/apache-ant-1.8.2/lib/svnjavahl.jar
Debuglevel=source,lines
target=1.6
source=1.6
Work.space=e:/anttest/tpo
Dist.dir=${work.space}
Build.dir=${work.space}/webroot/web-inf/classes
Lib.dir=${work.space}/webroot/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=e:/anttest/tomcat7
War.file=${dist.dir}/${ant.project.name}.war
Svn.url=xxxxxxxxxxxxx
Svn.username=xxxxxxxxxxxxx
Svn.password=xxxxxxxxxxxxx
The exception encountered
1 SVN command is not found, probably a lot of people are installed that turtle, that does not have the local SVN command, to my listed above the link in the central download.
2 Unsupported Major.minor version 51.0 my local JDK is 1.7, compatibility issues, changed to 1.6 to solve.
The next goal is to use some continuous integration (continuous integration) tools to further make the project easier to build.