<?xml version="1.0" encoding="UTF-8"?>
<!-- mkdir javac jar clean 在控制台或者MyEclipse指定project的,而不是在构建文件<project name="OurProject" default="archive" basedir="..\">指定-->
<project name="OurProject" default="archive" basedir="..\">
<target name="init" description="创建文件夹">
<mkdir dir="build\classes" description="用来放置类文件"/>
<mkdir dir="dist" description="用来放置打包文件"/>
</target>
<target name="compile" depends="init" description="编译源文件">
<javac srcdir="src" destdir="build/classes"></javac>
</target>
<target name="archive" depends="compile" description="打包">
<jar destfile="dist\project.jar" basedir="build\classes"></jar>
</target>
<target name="clean" depends="init" description="清除类文件和打包文件">
<delete dir="build" description="如果该文件夹有打开的文件,删除失败"></delete>
<delete dir="dist"></delete>
</target>
</project>
<!--
在控制台或者MyEclipse指定project的,而不是在构建文件<project name="OurProject" default="archive" basedir="..\">指定
当两方面同时指定,以控制台或者MyEclipse指定project为准
MyEclipse指定project
1.Run As->2 Ant Build...->Targets
2.也Run As->2 Ant Build...->Main->Arguments写上 -verbose clean(相当于在控制台写上ant -verbose clean)
如果用以上两种方式指定的project跟构建文件的default project一致的话,相当于没有指定
如果以上两种方式指定的project不同,则表示同时指定两个project,先执行第二种方式指定的project,后执行第一种方式指定的project
第一种方式指定比较方便,直接点钩就行,但推荐使用第二种方式,因为可以加上诸如-verbose之类的参数,输出更多的信息,这是第一种方式做不到的
当然也可以在第二种方式写上-verbose,不写project,用第一种方式写上project
D:\Workspaces\AntTest\src>ant -verbose clean
Apache Ant(TM) version 1.8.2 compiled on December 20 2010
Trying the default build file: build.xml
Buildfile: D:\Workspaces\AntTest\src\build.xml
Detected Java version: 1.6 in: C:\Program Files\Java\jre6
Detected OS: Windows 7
parsing buildfile D:\Workspaces\AntTest\src\build.xml with URI = file:/D:/Workspaces/AntTest/src/build.xml
Project base dir set to: D:\Workspaces\AntTest
Build sequence for target(s) `clean' is [init, clean]
Complete build sequence is [init, clean, compile, archive, ]
init:
parsing buildfile jar:file:/E:/JavaEE/Data/Ant/apache-ant-1.8.2/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/E:/JavaEE/Data/Ant/a
pache-ant-1.8.2/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
[mkdir] Created dir: D:\Workspaces\AntTest\build\classes
[mkdir] Created dir: D:\Workspaces\AntTest\dist
clean:
[delete] Deleting directory D:\Workspaces\AntTest\build
[delete] Deleting directory D:\Workspaces\AntTest\build\classes
[delete] Deleting directory D:\Workspaces\AntTest\build
[delete] Deleting directory D:\Workspaces\AntTest\dist
[delete] Deleting directory D:\Workspaces\AntTest\dist
BUILD SUCCESSFUL
Total time: 0 seconds
--> 
   详细解决方案
                mkdir javac jar clean 在控制台或者MyEclipse指定project的,而不是在构建文件project name=OurProject default=archive
热度:89   发布时间:2024-01-17 03:30:55.0
                    相关解决方案
                
                - MyEclipse 连接tomcat 出现如上异常
 - MyEclipse 上配置tomcat遇到的有关问题
 - myeclipse 左侧的目录结构变了 如何改回来
 - MyEclipse 中 jsp页面编译报错有关问题
 - eclipse ee版本 怎么新建和发布 web project
 - MyEclipse 8.5怎么使用JeasyOPC
 - myeclipse 8一个使用有关问题
 - dynamic web project怎么转成tomcat project
 - Myeclipse 运行tomcat时出现 以上提示
 - MyEclipse lib 目录上的jar包不能自动识别
 - ()关于web project与java project的有关问题(MyEclipse)
 - struts1 myeclipse tomcat 从页面失去乱码
 - Myeclipse+tomcat开发web项目编译成功后可以不用在浏览器输入吗解决方法
 - myeclipse javascript代码不执行,灰色的解决方法
 - myeclipse 6 集成svn插件 建资源库报错咋解决啊解决办法
 - myeclipse web项目中 引入的很多jar包无法展开解决方法
 - 现下公司里开发用的 Eclipse + MyEclipse + Tomcat + JDK 都是什么版本的
 - 现时公司里开发用的 Eclipse + MyEclipse + Tomcat + JDK 都是什么版本的
 - MyEclipse JAVA向MYSQL导入与导出,出现中文乱码的有关问题!
 - default package中的类怎么访问
 - MyEclipse 显示代码提示的时间,该怎么解决
 - MyEclipse 8.5开发时的揭示快捷键是什么
 - Your project contains error(s), please fix them beforerunning your application.该怎么解决
 - MyEclipse 打包jar文件,cmd下可运行,但是双击不能运行、解决方案
 - javac.exe、 java.exe、 java虚拟机三者之间的区别与联系?该怎么解决
 - javac 环境变量设置解决方案
 - NetBeans启动程序后提示异常:javac: 无效的目标版本: 1.6
 - MyEclipse 配备Tomcat 服务器
 - myeclipse debug调试 坐待!求各位大侠指点迷津
 - myeclipse/eclipse不能编译java程序解决办法