Use of ANT in JBuilder8: Weng Chi original in JBuilder8, Apache Ant version 1.5.1 has been updated to provide greater functionality. What is ANT? In general, Ant is a Java-based build tool. About Build Tools, I believe that everyone has already been exposed to many, such as: make, gnumake, nmake, jam, and other build tools. So why do you want to use Ant? Because Ant is a Java-based cross-platform build tool. ANT expands with Java classes, (users) Do not have to write shell commands, the profile is based on XML, perform tasks by the Targets and Tasks defined in the configuration file. JBuilder automatically identifies the build file of Ant's ANT named Build.xml, and this file in JBuilder will display an icon of an ant. The JBuilder version used herein is JBuilder8, which is assumed to have a certain understanding of JBuilder and Java. Let's take a step by step how to use Ant in JBuilder. 1. Establish an engineering and application to open JBuilder8, select Menu File | New to open the new panel. Select Project in Project, fill in the ANTPROject in the Name column, skip the steps below, press Finish to complete. Select File | New In the General panel, select Application, and accept the default option to finish the end. 2. Establish an ANT file in JBuilder Select Project | Add Files / Packages, select the explorer on the left, select the root directory of the ANTProject project, fill in the build.xml in the File Name field, press OK to play a prompt to ask if you want to create, press OK Just create a file called Build.xml. The system can automatically identify it is an Ant file and display it into an ant icon. If you have other names. XML files I hope JBuilder will identify it as an Ant's build file, right-click on this file, select Properties in the ANT page Select Ant Build File.
Open the build.xml file you just created, please save the project after adding the following contents XML Version = "1.0"?>
You can also write if or unless control statements, such as:
You can try it, right-click Compile Target, click Make, take a closer look, you will find more information, the specific information can be referred to: (Figure 3) Ant stdout apache ant version 1.5.1 Compiled on October 2 2002 BuildFile: build.xml Detected Java version: 1.4 in: H: /JBuilder7/jdk1.4/jre Detected OS: Windows 2000 parsing buildfile build.xml with URI = file: I: / personal / project / j_project / jbuilder_torial / AntProject / build. xml Project base dir set to: I: / personal / project / j_project / jbuilder_torial / AntProject Override ignored for property build Build sequence for target `compile 'is [init, compile] Complete build sequence is [init, compile, clean, dist] init: compile: [javac] antproject / Application1.java omitted as I: /personal/project/j_project/jbuilder_torial/AntProject/test/antproject/Application1.class is up to date [javac] antproject / Frame1.java omitted as I. : /personal/project/j_project/jbuilder_torial/antproject/test/antproject/frame1.class is up to date. [j AVAC] AVAC] ANTPROJECT / FRAME1.JBX SKIPPED - DON 'TOTAL TO HANDLE IT Build Successful Total Time: 1 SECOND Next, first select Project | Clean After clearing the directory, let's see how to set it in JBuilder when compiling. Compile with Ant to compile. Mark the mouse on ANTProject.jpx Select Clean, which is used to delete the class and class directory generated by jbuilder. Then select Properties after right-click Build.xml, select the always run ant when it buildings project is OK to close this dialog. Now, when you select Project | make Project, JBuilder automatically calls Ant to perform compilation tasks. If you need other class libraries when compiling, for example, you need to execute Java Mail, or JUnit test, you can join what you need: Choose Project | Project Properties, select the build page in the pop-up panel The ANT page, press Add to open a Select A Library Dialog window to increase the class library you need. If there is no desired class library in this window, you can click the New button to point to the lower left corner. Click After OK is turned off. You can adjust their sequence of lookup class libraries by Move Up or Move Down.