Ant development one (but only the best)

2010-12-04  来源:本站原创  分类:Development  人气:106 

Replies to look after the (absolute classic)
Ant Ant development <br /> To be honest the emergence of great help to the java programmer, but also other languages emulating tool. Really powerful ah.

1 Author

Between learning new tools, even the authors do not know who you can not learn the technology at home haha. . . . If nothing else the author: chenhailong (author ),^_^. . . No joke, turn to the question ah

Author: James Duncan Davidson This person is cow B, to participate in Apache Tomcat is a key member of the project. . . Are now focused on doing the standardization of XML. . . Because it is very cattle people. Ant is mainly the emergence of this person to do. (In fact, his trip to Europe when I wanted to, you do not say Meng)

2 released

Apache ant project is now version 1.8, did not miss the recent update, then I do with 1.8 Introduction

ant 1.8 Download: http://ant.apache.org/bindownload.cgi

Above for Windows and Unix versions. . . (In order of Windows and Unix)

Released a version of Apache 2 is src, one bin. . . The above is the bin. . . For experts who want to see the source code under the src version can. .

Note: When the decompression time, Windows users do not add spaces in the folder, the main causes for bat batch dir parse error

Directory structure:

bin

docs (can be deleted)

etc (expand)

lib (core jar package)

ANT release steps:

1 Set ANT_HOME environment variable

2 Set the JAVA_HOME

3 in the system PATH environment variable to add ANT_HOME / bin

4 in the system CLASSPATH environment variable to add ANT_HOME / lib

Bat file I wrote the following to facilitate handling:

@ Echo off

REM This is the ANT set path and classpath

set ANT_HOME = D: \ apache-ant-1.8.1

set JAVA_HOME = C: \ JAVA \ jdk1.4

set PATH = D: \ apache-ant-1.8.1 \ bin

Copy the code above (directory location can be set for myself, here is my directory location)

ANT release is completed.

Test Release ------

1 First, enter cmd in the fight ant. . .

Buildfile: build.xml does not exist!
Build failed

(Emergence of this success is released)

2 test build.xml

<?xml version="1.0" encoding="GBK"?>
<project name=" Test script" default="copyfile" basedir="." >
   <target name="copyfile">
      <copy file="d:/test.txt" todir="e:/" overwrite="true" />
   </target>
</project>

3 The final step is verification, and now in cmd type d:, then the output ant, the last to see the results. . . . e more than a test disk file, copy the success of

(These are the bare-metal operating)

Here are the ant eclipse plugin

ant eclipse is an integrated plug-ins, and can be used directly. But it should also set ant_home position.

1. Midpoint window into eclipse

2 found prefenerce label, ant point after heading into the ant configuration

3 In the runtime tab, click Ant_Home configuration options anthome

Configuration is complete, ant can be run

If you are operating in accordance with the bare metal, then in fact no configuration. If not, then you must configure, or jvm can not find the location of the ant

Ant to complete the configuration, then we see if you can run. . . There a simple way to tune, but for future development, we do a little example.

1 First create a java project (in fact, what other projects as Tomcat project, web project line, java project is simple and convenient)

2. Here's my directory structure

src

com

Account.java

Person.java

PersonTest.java

build.xml

3.java class is very simple, is that some bean, Test There is a main method. .

4 Configuring build.xml

<?xml version="1.0" encoding="UTF-8"?>
<!-- build.xml a simple Ant build file -->
<project name="Simple Buildfile" default="compile" basedir=".">
        <!-- The directory containing source code -->
        <property name="src.dir" value="src" />

        <!-- Temporary build directories -->
        <property name="build.dir" value="build" />
        <property name="build.classes" value="${build.dir}/classes" />
        <property name="build.lib" value="${build.dir}/lib" />

        <!-- Target to create the build directories prior to the compile target -->
        <target name="prepare" >
                <mkdir dir="${build.dir}"></mkdir>
                <mkdir dir="${build.classes}" ></mkdir>
                <mkdir dir="${build.lib}" ></mkdir>
        </target>
        <target name="clean" description="Removes all generated files" >
                <delete dir="${build.dir}"></delete>
        </target>
        <target name="compile" depends="prepare" description="Compile all source code" >
                <javac srcdir="${src.dir}" destdir="${build.classes}" />
        </target>
        <target name="jar" depends="compile" description="Get the jar of classes">
                <!-- Exclude unit tests from the final JAR File -->
                <jar jarfile="${build.lib}/test.jar" basedir="${build.classes}" excludes="**/*Test.class" />
        </target>
        <target name="all" depends="clean,jar" description="Cleans ,compiles,the builds the JAR file" />
</project>

Good. . Run the build file you can see

Buildfile: E: \ JavaPortlet \ AntDemo1 \ build.xml
prepare:
[Mkdir] Created dir: E: \ JavaPortlet \ AntDemo1 \ build
[Mkdir] Created dir: E: \ JavaPortlet \ AntDemo1 \ build \ classes
[Mkdir] Created dir: E: \ JavaPortlet \ AntDemo1 \ build \ lib
compile:
[Javac] E: \ JavaPortlet \ AntDemo1 \ build.xml: 22: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath = last; set to false for repeatable builds
[Javac] Compiling 3 source files to E: \ JavaPortlet \ AntDemo1 \ build \ classes
BUILD SUCCESSFUL
Total time: 2 seconds

javac warnings appear because I have two jdk. . . My eclipse with a jdk, my system has a jdk, so I use the elipse warning the jdk, you need not worry. .

(This is the entry-level, I hope you on the ant to have a preliminary understanding, want to see the advanced, see ant development 2 .......)

相关文章
  • Ant development (just the best) 2010-12-04

    Replies after watching the (absolute classic) Ant Ant development <br /> the emergence of the truth, a great help to the java programmer is imitated by the other language tools. Really strong ah. 1. Of Between learning new tools, and even of people

  • Ant development one (but only the best) 2010-12-04

    Replies to look after the (absolute classic) Ant Ant development <br /> To be honest the emergence of great help to the java programmer, but also other languages emulating tool. Really powerful ah. 1 Author Between learning new tools, even the autho

  • Ant development of three (but only the best) 2010-12-04

    Replies to look after the (absolute classic) Now we continue. . . . First you see the article, you must have read my previous articles written. If not seen, I'm sorry this article is not for you to learn techniques. This article is about the Ant addi

  • Ant development of four (but only the best) 2010-12-05

    Replies to look after the (absolute classic) Here we continue to develop our ant journey. . . . . This article is about the core ant tasks. . . Very strong look and give me hope that message. . . Core mission by order of presentation: ant: build file

  • Ant development of five (but only the best) 2010-12-12

    Then the above article: 3.available: What is the common property <available classname="" property="" file="" value="" classpath="" classpathref="" /> 4.condition Example: <?xml version=&

  • Ant's build.xml 2010-03-29

    Ant's build.xml (1) The concept of Ant Make command is a project management tool, achieved Ant functionality is similar. Like make, gnumake and nmake build tool to have some of these defects, but Ant has to overcome the shortcomings of these tools. A

  • Ant's most complete build.xml (change) 2010-03-23

    The concept of Ant Make command is a project management tool, achieved Ant functionality is similar. Like make, gnumake and nmake build tool to have some of these defects, but Ant has to overcome the shortcomings of these tools. Ant developers in the

  • Ant learning experience 2010-02-22

    The concept of Ant may be some readers are not connected to what is to use Ant and into it, but so long as the system used by Linux have readers should be aware of make this command. When compiling Linux kernel and some software source code, we often

  • Ant commonly used commands 2010-05-03

    Ant is a Java-based build tool. In theory, it is similar to (Unix) C in the make, but did not make the defect. Since we already have make, gnumake, nmake, jam and why the other build tools to build a new tool? Because of Ant's original author in a va

  • Ant build file to learn 2010-08-10

    build.xml file: <? Xml version = "1.0" encoding = "UTF-8"?> <! - ============================================== ========================= -> <! - EJB3 HelloWorld build file -> <! - =================================

  • Ant configuration file 2010-10-11

    Ant Development Ant build file when starting a new project, should first write Ant build file. Build file defines the build process, team development and was used for each person. The default Ant build file named build.xml, you can get other names. O

  • Ant introduction. Use of a Detailed 2011-05-08

    The concept of ant Some readers may not be connected into what is Ant, and can use it, but as long as the Linux system was used by the reader, should know the make of this command. When compiling Linux kernel and some software source code, we often u

  • Introduction Ant tool (reproduced) 2011-09-30

    Original link: http://blog.163.com/jack0220 @ 126/blog/static/5618620420093225183543 / Ant is a Java-based build tool. In theory, it is similar to (Unix) C in the make, but did not make the defects. Now that we have make, gnumake, nmake, jam and why

  • ANT的环境搭建和开发 2012-08-07

    Ant 是apache 工程的一个子工程,是一个基于Java的build工具.Ant 类似于make工具,但没有传统的make工具的缺点.传统的make往往只能限制在某一平台上使用,ant本身用java类实现,要构建的工程的配置文件用xml格式描述,可以很方便实现多平台编译. 版本 JDK1.6.0.21 Ant1.8.1 安装JDK 无论用什么开发工具,JDK(Java Development Kit)都是必不可少的.从 官网上下载完JDK后,直接安装即可.我把JDK安装到了目录C:\Java

  • ANT-build.xml file Xiangjie 2010-03-29

    The concept of Ant may be some readers are not connected to what is Ant and entry can use it, but as long as the use by Linux systems from readers should be aware of make this command. When compiling Linux kernel and some software source code, we oft

  • ANT-build.xml file Xiangjie (collection, transferred from: http://www.blogjava.net/zhengtengfeng/archive/2007/04/2) 2010-04-11

    The concept of Ant Perhaps some readers are not connected to what is Ant and into the can use it, but as long as the system used by Linux have readers should know make this command. When compiling Linux kernel and some software source code, we often

  • Common abnormalities resolved 2011-09-18

    ConcurrentHashMap and CopyOnWriteArrayList comparison. Blog categories: Java ConcurrentHashMap ConcurrentHashMap introduced Segment, each Segment is a hashtable, the equivalent of two Hash table, and then lock in the Segment level, and increased conc

  • Ant Task combination of rapid development of Hibernate Tools3.x 2009-05-23

    Hibernate Reference Documentation watch recently, it was found that the official Hibernate Tools 3.x recommend that the instrument is very strong. If used before because of the development of Hibernate directly in the general combination of Ant Task

  • Development of basic issues Ant 2010-07-12

    Development of basic issues Ant

  • Application development and integration of Ant Xiangjie 2010-08-11

    Ant tool in the package of each task to perform specific functions, is the Ant tool basic unit of execution. Ant tools provide many useful tasks, project developers may use tools provided by the built-in Ant task automatically and easily build and so