readme.txt
ant-helloworld
1,目录结构
/src 源文件目录
binzi/HelloWorld.java
/build.xml
2,命令执行:
F:\Desktop\20180404\ant-helloworld>ant
Buildfile: F:\Desktop\20180404\ant-helloworld\build.xml
init:
[mkdir] Created dir: F:\Desktop\20180404\ant-helloworld\class
compile:
[javac] F:\Desktop\20180404\ant-helloworld\build.xml:14: warning: 'includean
truntime' was not set, defaulting to build.sysclasspath=last; set to false for r
epeatable builds
[javac] Compiling 1 source file to F:\Desktop\20180404\ant-helloworld\class
run:
[java] test
BUILD SUCCESSFUL
Total time: 1 second
F:\Desktop\20180404\ant-helloworld>
HelloWorld.java
package com.binzi;
public class HelloWorld{
public static void main(String[] args){
System.out.println("test");
}
}
build.xml:
<project name="helloworld" default="run" basedir=".">
<property name="src" value="src"/>
<property name="class" value="class"/>
<target name = "init">
<mkdir dir="${class}"/>
</target>
<path id="classpath">
<pathelement path = "${class}"/>
</path>
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${class}" >
</javac>
</target>
<target name="run" depends="compile">
<java classname="com.binzi.HelloWorld">
<classpath refid ="classpath"></classpath>
</java>
</target>
<target name = "clean">
<delete dir="${class}"/>
</target>
</project>