快捷搜索:  as  test  1111  test aNd 8=8  test++aNd+8=8  as++aNd+8=8  as aNd 8=8

澳门黄金城官网网:Eclipse快速上手指南(3)



5. 在Eclipse中应用Ant

Ant是Java平台下异常棒的批处置惩罚敕令履行法度榜样,能异常方便地自动完成编译,测试,打包,支配等等一系列义务,大年夜大年夜前进开拓效率。假如你现在还没有开始应用Ant,那就要从速开始进修应用,使自己的开拓水平上一个新台阶。

Eclipse中已经集成了Ant,我们可以直接在Eclipse中运行Ant。

曩昔面建立的Hello工程为例,创建以下目录布局:

新建一个build.xml,放在工程根目录下。build.xml定义了Ant要履行的批处置惩罚敕令。虽然Ant也可以应用其它文件名,然则遵照标准能更使开拓更规范,同时易于与别人交流。

平日,src寄放Java源文件,classes寄放编译后的class文件,lib寄放编译和运行用到的所有jar文件,web寄放JSP等web文件,dist寄放打包后的jar文件,doc寄放API文档。

然后在根目录下创建build.xml文件,输入以下内容:

奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫**

奸淫*One or more tests failed!Check the output ...奸淫*

奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫奸淫**

Hello, test澳门黄金城官网网]]>

All Rights Reserved.]]>

以上xml依次定义了init(初始化),compile(编译),test(测试),doc(天生文档),pack(打包)义务,可以作为模板。

选中Hello工程,然后选择“Project”,“Properties”,“Builders”,“New…”,选择“Ant Build”:

填入Name:Ant_Builder;Buildfile:build.xml;Base Directory:${workspace_loc:/Hello}(按“Browse Workspace”选择工程根目录),因为用到了junit.jar包,搜索Eclipse目录,找到junit.jar,把它复制到Hello/lib目录下,并添加到Ant的Classpath中:

然后在Builder面板中钩上Ant_Build,去掉落Java Builder:

再次编译,即可在节制台看到An澳门黄金城官网网t的输出:

Buildfile: F:\eclipse-projects\Hello\build.xml

init:

compile:

[mkdir] Created dir: F:\eclipse-projects\Hello\classes

[javac] Compiling 2 source files to F:\eclipse-projects\Hello\classes

test:

[mkdir] Created dir: F:\eclipse-projects\Hello\report

[junit] Running example.HelloTest

[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.02 sec

pack:

[mkdir] Created dir: F:\eclipse-projects\Hello\dist

[jar] Building jar: F:\eclipse-projects\Hello\dist\hello.jar

doc:

[mkdir] Created dir: F:\eclipse-proj澳门黄金城官网网ects\Hello\doc

[javadoc] Generating Javadoc

[javadoc] Javadoc execution

[javadoc] Loading source files for package example...

[javadoc] Constructing Javadoc information...

[javadoc] Standard Doclet version 1.4.2_04

[javadoc] Building tree for all the packages and classes...

[javadoc] Building index for all the packages and classes...

[javadoc] Building index for all classes...

[javadoc] Generating F:\eclipse-projects\Hello\doc\stylesheet.css...

[javadoc] Note: Custom tags that could override future standard tags:@todo. To avoid potential overrides, use at least one period character (.) in custom tag names.

[javadoc] Note: Custom tags that were not seen:@tod澳门黄金城官网网o

BUILD SUCCESSFUL

Total time: 11 seconds

Ant依次履行初始化,编译,测试,打包,天生API文档一系列义务,极大年夜地前进了开拓效率。将来开拓J2EE项目时,还可加入支配等义务。并且,纵然离开了Eclipse情况,只要精确安装了Ant,设置设置设备摆设摆设好情况变量ANT_HOME=,Path=…;%ANT_HOME%\bin,在敕令行提示符下切换澳门黄金城官网网到Hello目录,简单地键入ant即可。

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

您可能还会对下面的文章感兴趣: