Preface ANT is an important ring of the Java Developer Toolbox, JUnit, XDoclet, etc. closely related to it, and programmers may get used to the automatic build, and even deployment features provided by IDE, which ignores Ant itself, in fact, mainstream IDE It is usually a built-in Ant task to complete these work, familiar with Ant's internal mechanism, you can read or simply modifying build.xml can help you integrate, manage application projects, if you need to learn Maven this open source project management solution, It is also necessary to understand Ant. 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:
Fileset>
Fileset>
Fileset>
Fileset> s
......
Path>
4.3 Empty Output Directory, such as web, dlist, etc.
4.4 Compilation Construction:
Javac>
Fileset>
Copy>
Fileset>
Copy>
Fileset>
Jar>
Fileset>
Fileset>
Fileset>
Fileset>
......
Copy>
Target>
War>
Target>
4.5 Made WAR
War>
Target>
4.6 Take a few tasks together and get a default target
Target>
After completing the job. In practice, some profiles, such as struts-config.xml ibatis and Spring's XML can entroy JAR files, Spring resource files are not good, have a separate copy to Web-Infclasses, in addition, your web folder Next, you have to put it in advance, and some TLD files.