<?xml version="1.0" encoding="UTF-8"?> <project name="javaTest" default="compile" basedir="."> <!-- 在此.代表当前目录 --> <target name="clean"> <delete dir="build"/> </target> <target name="compile" depends="clean"> <mkdir dir="build/classes"/> <javac srcdir="src" destdir="build/classes"/> </target> </project> <!--运行结果 E:\antstudy>ant compile Buildfile: E:\antstudy\build.xml clean: compile: [mkdir] Created dir: E:\antstudy\build\classes [javac] E:\antstudy\build.xml:9: warning: ‘includeantruntime‘ was not set, d efaulting to build.sysclasspath=last; set to false for repeatable builds [javac] Compiling 1 source file to E:\antstudy\build\classes BUILD SUCCESSFUL Total time: 1 second -->
先建一个文件夹 antstudy(project文件夹)
再建一个src文件夹(作为源代码目录)
里面放置java程序
在antstudy目录下建一个build.xml文件如上
时间: 2024-11-13 09:27:19