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>
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>
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>
You need something like this,
<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>