Foreword
Ant is an important part of the Java Developer Toolbox, JUnit, XDoclet, etc., is closely related to it. The programmer may get used to the automatic build, even deployment features provided by IDE, which ignores Ant itself, in fact, the mainstream IDE usually It is a built-in Ant task to complete these work, familiar with Ant's internal mechanism, you can read or simply modify building.xml can help you integrate, manage application projects, if you need to learn Maven open source project management solutions, too To understand the Ant-based 哟. In addition, the process of using ANT actually documents the construction, it is no IDE, imagined, your colleague may be in one-third of JBuilderx, one-third with Eclipse, and some of.
I use Eclipse3.0.1, the previous build and release work is made by myECLIPSE plug-in, and the weekend practiced manual construction and remember this.
practice
Preparation: This is my personal habit, put all the public class library JARs in a fixed directory, divide the class, do not lose in a folder, such as Jakarta-Commons, Hibernate, Spring, Struts, etc. These are the source code. It is necessary to use when building, there may be some no need to play in, such as servlet.jar. If you have your own Framework, you will be placed here. Then, open Eclipse, enter Windows-> Preferences-> Java-> User Libraries, add a book, such as MYLIB, add all the public JARs all, so there is a good place, in the Eclipse project, no need See the annoying long JAR list, which is more tidy.
It is officially conducted:
1. Create a new Java Project, do not choose some of your J2EE plugins to be built, you can easily.
2. Create several folders in root, we can often see these in open source projects downloaded online, such as:
SRC - source code
Classes - Compilation
Web - JSP, etc.
Lib - library, here you can simply come over the Southone COPY under Mylib, which will be released in the future.
Dlist - Output JAR or WAR
Of course, we have to build a build.xml. There will be a small icon of an ant on Eclipse. After this file is established, the next project is simple COPY, and it can be changed.
3. Open the properties page of the project, in the Java Build Path library option, join our custom public library MYLIB. As for the builders, you don't have to change it. Use the default Java Builer, I just use Ant when the project is deployed. The usual tired work will be handed over to the IDE.
4. Heavy weight, write your build.xml, online article is very sea, I will not be embarrassed here, basically in the same task:
4.1 To declare some path variables, such as
You can also write it to the Properties file, here reference;
4.2 Declaring Compilation Class Path, as follows:
4.4 Compilation Construction:
4.6 Take a few tasks together and get a default target