Using the Eclipse Ant plugin operation process

Source: Internet
Author: User

Http://jerry17768java.blogspot.com/search/label/Ant%E4%BD%BF%E7%94%A8

The Ant tool is now erhkan as part of the Eclipse IDE, so we don't need to install an ant plugin kit,
The use of the method is very simple, complete operation process can be reference to the following:

1. Open your Eclipse IDE and build a testproject, under the Src/jcode/test kit
Add hellotest the main () function of the program, add the following code:

Public Static void Main (string[] args) {
System.out.println ("Hello, everybody!");
}

2. Move the mouse cursor to the testproject image, and then click the right mouse button, and then click the context menu to point to the export item,



The screen brings out the "Export" dialog box below and selects the "Ant buildfiles" icon to produce the TestProject Build.xml file:



3. Open the Build.xml file, and make local changes to the document, and its modified code to Red Bold WordSaid.

<?xml version= "1.0" encoding= "UTF-8" standalone= "no"?> <project "basedir=". default= "Build" Name= "TestProject" > <property environment= "env"/> <property name= "Eclips" E_home "Value=". /.. /.. /eclipse-sdk-helios "/> <property name=" debuglevel "value=" Source,lines,vars "/> <property N Ame= "Target" value= "1.6"/> <property name= "source" value= "1.6"/> <property name= "Dist"  location= "dist"/>          <path   id= " Testproject.classpath ">          <pathelement   location=" bin "/ >          <pathelement   location= ". /.. /.. /jar-lib/ojdbc14.jar "/>      </path>      <target   Name=" Init ">          <mkdir   dir=" bin "/>               <copy   includeemptydirs= "false"   todir= "bin" >  & nbsp;           <fileset   dir= "src" >                   <exclude   Name= "**/ *.launch "/>                  <exclude   name= "**/*.java"/>               </fileset>          </copy>       </target>      <target   name= "clean" >           <delete   dir= "bin"/>      </target>       <target   depends= "clean"   name= "Cleanall"/>      <!--target Depe nds= "Build-subprojects,build-project" name= "Build"/-->            <target depends= "Dist" name= "Build"/><target name= "build-subprojects"/> <target depends= "init" name= "Build-project" > <e   Cho message= "${ant.project.name}: ${ant.file}"/> <javac debug= "true" Debuglevel= "${debuglevel}" Destdir= "Bin" source= "${source}" target= "${target}" > <src path= "src"/> Lasspath refid= "Testproject.classpath"/> </javac> </target>  <target name= "Dist" depends= "Build-subprojects,build-project" description= "Generate" Distribution ">         <!--Create and place jar archives-->         <mkdir dir= "${dist}/lib"/>                  <!--pack all the files in the build into a Testproject.jar file-->         <jar jarfile= "${dist}/lib/${ant.project.name}.jar" basedir= "Bin"/>       </target>          <target   description= "build all projects which Reference this project. Useful to propagate changes. "  name=" build-refprojects "/>      <target   Descripti on= "Copy Eclipse compiler jars to ant lib directory"   name= "Init-eclipse-compiler" > &NBSP;&NBSP;&NBSP;&NBSP;&N bsp;    <copy   todir= "${ant.library.dir}" >               <fileset   dir= "${eclipse_home}/plugins" includes= "org.eclipse.jdt.core_*". Jar "/>          </copy>           <unzip   dest= "${ant.library.dir}" >               <patternset   includes= "Jdtcompileradapter.jar"/>               <fiLeset   dir= "${eclipse_home}/plugins" includes= "Org.eclipse.jdt.core_*.jar"/>           </unzip>      </target>      < Target   description= "compile project with Eclipse compiler" Name= "Build-eclipse-compiler" >           <property   name= "Build.compiler" value= " Org.eclipse.jdt.core.JDTCompilerAdapter "/>          <antcall   target= "Build"/>      </target> </project>

4. Move the mouse cursor to the build.xml icon, click the mouse right and select the "Run as-> 1 ant build" to output the ant's Foot code in "Console":




Buildfile:d:\works\testproject\build.xml build-subprojects:init:build-project: [Echo] Testproject:d:\works\ Testproject\build.xml Dist: [mkdir] Created dir:d:\works\testproject\dist\lib [jar] Building Jar:d:\works \testproject\dist\lib\testproject.jar build:build Successful total time:526 milliseconds posted by: Jerry Chan Afternoon 4:070 to send this article blogthis email. Share to Twitter share to Facebook tags: ant usage ant's Manual installation setting
Ant itself is not a Windows program, so the installation process requires some manual installation steps.

1. First, go to Apache Ant's official website http://ant.apache.org/bindownload.cgi download Ant's Program suite compression



2. Again, the Zi of the Ant program Kit P is decompressed to Windows's specified catalogue e.g., C:\myant\
   zip files contain the subdirectory structure named "Apache-ant" according to the version information.
3. Then you need to set some environment variables to let your command console know how to find Ant's Execute file
    and let Ant know where to find the Java Execute file

in Windows In the XP dialog box, you can access the environment variables by "Start the menu" and right click on "My Computer". The
will later lead to a "system-nature" dialog. Select the Advanced button:



and click on the "Environment Change" button.

4. Finally, you need to use the "Add" button to add two new variables as follows:

Ant_home is the location where the root records are placed by the ANT Suite decompression Java_home represents the root of the JAVA SDK installation



and you also need to edit the variables:

Increase the PATH variable %ant_home%/bin path



5. After completing the steps above, open your command conso Le input ant presses the ENTER key, and if you output the following message string, it will be successful on behalf of Ant's installation.

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.