Ant is an important part of the Java Developer Toolbox, and Junit,xdoclet is closely associated with it, and programmers may be accustomed to the automatic build and even deployment capabilities provided by the IDE, ignoring the ant itself, in fact, the mainstream IDE is usually built into the ant task to do the work, Familiar with Ant's internal mechanism, you can read or simply modify Build.xml can undoubtedly help you to more flexibly integrate, manage application projects, if you need to learn maven this open source project management solution, but also to understand Ant based on yo. In addition, the process of using ant actually documents the build, which is nothing about the IDE, and imagine that One-third of your colleagues may be using Jbuilderx, One-third with Eclipse, and some others.
I use eclipse3.0.1, the previous construction and release work by the MyEclipse Plug-ins, while the weekend practice a manual build, remember this memo.
Practice
Preparation: This is my personal habit, put all the common library jar in a fixed directory, divided into classes, do not throw in a folder, such as Jakarta-commons, Hibernate, Spring, struts and so on, these are the source code to build the need to use, There may be some need to be deployed, such as Servlet.jar. If you have your own framework, put it here as well. Then, open eclipse, go into windows->preferences->java->user libraries, add a library of your own, such as Mylib, to add just the public jars, which is a good thing, in the Eclipse Project, No longer have to see the annoying long list of jars, more tidy.
To come down formally:
1. Create a new Java Project, and then do not choose your EE plug-in built-in some of the options, to Jane can.
2. Create several folders under root, which we can often see in open source projects downloaded from the Web, such as:
SRC-source
Classes-Compiling
WEB-JSP, etc.
Lib-Library, here can simply put the mylib under the Dongdong copy over, easy to release the source code in the future.
Dlist-output jar or war
Of course, we want to build a build.xml,eclipse will appear a small ant icon, generally this file is established, the next project simple copy past, a little change on it.
3. Open the Project's property page, and in the Java Build Path library option, join our customized public Library Mylib. As for the builders mode, use the default Java builer, I just use ant for project deployment, Let the IDE do the usual job of scheduling mistakes.
4. The most important, write your build.xml, online article is very sea, I here will not long-winded, basically divided into those several tasks:
4.1 First declare some path variables, such as
<property name= "War.dir" value= "Dlist"
It can also be written to the properties file, where it is referenced;
<copy todir= "${build.dir}" preservelastmodified= "true" >
<fileset dir= "${src.dir}" >
<include name= "**/*.xml"/>
<include name= "**/*.properties"/>
</fileset>
</copy>
!--=============================================-->
!--It is tested that the resource file cannot be hit into the jar file and the rest can be-->
!--=============================================-->
<copy todir= "${webclasses.dir}/conf" preservelastmodified= "true"
<fileset dir= "${src.dir}/conf"
<include name= "Springresources*.properties"/>
</fileset>
</copy>
!--=============================================-->
!--Compile main Java sources and copy libraries-->
!--=============================================-->
<target name= "Warfile" description= "Build the Web application archive"
Finish the work. In practice, some configuration files, such as Struts-config.xml Ibatis and spring XML, can be typed into the jar file, and the spring resource file does not seem to be able to be copy to Web-infclasses alone, and Your Web folder, you have to put a good web.xml, as well as some tld files yo.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.