我是Apache Ant的新手,运行ant命令时遇到以下问题: 建立失败
C:\testANT\build.xml:17: srcdir "C:\testANT\src" does not exist!
at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:925)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.ja
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchU
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.jav
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(De
at org.apache.tools.ant.Project.executeTargets(Project.java:1260
at org.apache.tools.ant.Main.runBuild(Main.java:853)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
我的build.xml文件是:
<?xml version="1.0" ?>
<project name="JarBuild" basedir="." default="jarfile">
<target name="init" description="Initializes properties">
<property name="project.name" value="helloWorld"/>
<property name="src.dir" value="src"/>
<property name="build.dir" value="build"/>
<property name="classes.dir" value="${build.dir}/classes"/>
<property name="etc.dir" value="etc"/>
</target>
<target name="prepare" description="Creates the build and classes directories" depends="init">
<mkdir dir="${classes.dir}"/>
</target>
<target name="compile" description="Compiles the code" depends="prepare">
<javac srcdir="${src.dir}" destdir="${classes.dir}" />
</target>
<target name="jarfile" description="JARs the code" depends="compile">
<jar destfile="${build.dir}/${project.name}.jar"
basedir="${classes.dir}"
manifest="${etc.dir}/MANIFEST.MF" />
</target>
<target name="clean" description="delete the build directory" depends="init">
<delete dir="${build.dir}}" />
</target>
</project>
我提到build.xml文件位于主文件夹中。 非常感谢! 此致!