`
liudong19870227
  • 浏览: 31831 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

A first Ant build

    博客分类:
  • Ant
 
阅读更多

前提已有java和ant环境(运行java -version和ant -version测试)

 

一、新建项目文件夹并再新建文件夹src,并创建Main.java

package com.ant.welcome;
public class Main{
	public static void main(String args[]){
		for(int i=0; i<args.length; i++){
			System.out.print(args[i]);
		}
	}
}

二、在 项目路径下床架build.xml

<?xml version="1.0" ?>
<project name="structure" default="archive">
	<target name="init">
		<mkdir dir="build/classes"/>
		<mkdir dir="dist"/>
	</target>
	<target name="compile" depends="init">
		<javac srcdir="src" destdir="build/classes"/>
		<echo>complication complete!</echo>
	</target>
	<target name="archive" depends="compile">
		<jar destfile="dist/project.jar" basedir="build/classes"/>
	</target>
	<target name="clean" depends="init" description="delete the build and dist directory">
		<delete dir="build"/>
		<delete dir="dist"/>
	</target>
	<target name="execute" depends="init" description="execute the Main class">
		<java classname="com.ant.welcome.Main" classpath="build/classes">
			<arg value="a"/>
			<arg value="b"/>
			<arg file="."/>
		</java>
	</target>
</project>

知识点:

1.<project>为根节点。

2.<project>中的default属性定义默认执行的target。

3.<target>中的name属性唯一,并且depends属性定义了它们之间的依赖关系。

4.学习到的命令有mkdir、echo、jar、java、delete。

 

分享到:
评论

相关推荐

    EJB3 实例教程(JBoss+Eclipse+Ant)

    在学习过程中,提供的`first-ejb3-ant-tutorial-en.pdf`文档将详细解释每个步骤,而`first-ejb3-ant-tutorial.zip`则包含了源代码和相关资源,供读者实际操作练习。 总之,这个教程旨在帮助开发者快速理解和掌握EJB...

    apache-cxf-2.4.2.zip

    2. **创建项目结构**:建立一个标准的Java项目目录结构,包括src/main/java(存放Java源代码)、src/main/resources(存放资源文件)和build.xml(Ant构建文件)。 3. **编写服务接口和实现**:在src/main/java目录...

    完全免费的Java/jsp开发编辑工具FirstJava2

    你还将学会直接用javac命令来编译代码,java运行代码方法,ANT方式编译和运行代码, 创建自己的更高效的Build.xml文件,实现DIY自已的工程, Eclipse和Jbuild编译和运行代码方式,和这差不多,把他们隐藏起来了. 请...

    FirstJava2完全教材

    你还将学会直接用javac命令来编译代码,java运行代码方法,ANT方式编译和运行代码, 创建自己的更高效的Build.xml文件,实现DIY自已的工程, Eclipse和Jbuild编译和运行代码方式,和这差不多,把他们隐藏起来了. 请输入...

    Android代码-reader

    So Github likes the idea of a README file, so here goes the unofficial first draft. Building the source code for Reader is extremely simple at the moment. I use ant to actually build my code but there...

    build_tool:众多构建 andoird apk

    first install ant Cmd运行:java -jar package.jar C:\Users\zhangying-pd\Desktop\svn_res\branchs\Discovery(项目dir) C:\Users\zhangying-pd\Desktop\apk(生成apk件dir) 附件中是jar包 注意事项: 1、 确保...

    chires开发包

    ------------------------------------- &lt;br&gt; First download aspectwerkz 1.0 and JDK 1.5 &lt;br&gt; Install JDK 1.5 if you haven't already &lt;br&gt; Run 'ant dist' in the aspectwerkz directory ...

    chires包

    ------------------------------------- &lt;br&gt; First download aspectwerkz 1.0 and JDK 1.5 &lt;br&gt; Install JDK 1.5 if you haven't already &lt;br&gt; Run 'ant dist' in the aspectwerkz directory ...

    Red5的MetaDataGenerator

    ant build - will compile the MetaDataGenerator application. ant start - will start the MetaDataGenerator tool, it will first ask to input the path to the flv files. start.sh /path/to/flv - shell ...

    移动代理源代码

    A version of Ant, the build tool used to build and distribute the MUM project, can be downloaded here. Install Ant on your desktop. Change the setupMUM batch file so that the absolute paths to the ...

    checkStyleant使用方式配置说明[整理].pdf

    3. `build.xml`:这是Ant的构建脚本,你需要在这个文件中配置CheckStyle任务,包括引入CheckStyle库,指定配置文件(`sunrising_checks.xml`和`user.properties`),以及处理检查结果的输出格式(如XML或HTML)。...

    hibernate_reference.pdf

    - **Building with Ant**: An Ant build script is provided to automate the building and deployment process of the application. - **Startup and Helpers**: This section covers the initialization of ...

    spring-boot-reference.pdf

    13.4. Ant 13.5. Starters 14. Structuring Your Code 14.1. Using the “default” Package 14.2. Locating the Main Application Class 15. Configuration Classes 15.1. Importing Additional Configuration ...

    CE中文版-启点CE过NP中文.exe

    Thanks go out to SER[G]ANT for updating the russion translation files already June 23 2018:Cheat Engine 6.8.1 Released: Apparently 6.8 contained a couple of annoying bugs, so here's an update that ...

    globus_Math

    6. `build.xml`:这是Ant构建文件,用于自动化Java项目的构建过程,包括编译、测试和打包。 7. `schema` 文件夹:可能包含了XML模式定义,用于验证服务交互的数据格式。 8. `org` 和 `build` 文件夹:这两个可能是...

    mkvtoolnix_2.7.0

    mkvtoolnix 2.7.0 and Windows ---------------------------- ---[ NOTE 1 ]---------------------------------------------------------...please upload them somewhere and post a link in the Anthill bug report.

Global site tag (gtag.js) - Google Analytics