Ant buildfile does not contain a javac task

I have build.xml file and I want to create Java project from Existing Ant Buildfile. But I have an error: Specified buildfile does not contain a javac task My file has simple structure:

<project>
     <target ...>
     </target>
     ...
</project>

将javac提供给您的build.xml,如下所示:

<javac srcdir="src" destdir="bin" />

As Puneet Pandey pointed out, this error occurs when your build.xml file is lacking a <javac> XML element.

The <javac> XML element in the build.xml file (referred to as javac task) tells the compiler or IDE (Eclipse in this case) where the source Java files are for compiling. Once you know that it should be quite clear why Eclipse can't import your build.xml without a <javac> XML element.

In case you are not sure where to stick the <javac> tag I'll add a slightly fuller example. You will need to navigate to your build.xml and edit it so that it contains the <javac> line in the appropriate section inside the <project> tag.

<project ...>
  <javac srcdir="src" destdir="bin" />
  <target ...>
  </target>
  ...
</project>

你需要这样的东西,

    <target name="compile">
  <javac destdir="build/classes" srcdir="src" includeantruntime="false">
    <classpath refid="compile.classpath"/>
  </javac>
  </target>

    <target name="war" depends="compile">   
  <war destfile="build/${name}.war" webxml="WebContent/WEB-INF/web.xml">
   <fileset dir="WebContent" casesensitive="no">
   </fileset>
   <lib dir="WebContent/WEB-INF/lib"/>
   <classes dir="build/classes">
   </classes>   
  </war>
</target>
链接地址: http://www.djcxy.com/p/44380.html

上一篇: 如何在eclipse juno中导入并运行ivy + ant项目

下一篇: Ant构建文件不包含javac任务