I am using the following bunch of softwares:
- Ant 1.7.1
- Eclipse Helios
- Java 1.6
- Apache thrift 0.8.0
I am using Thrift to generate java source code in Ant using the following code block:
<exec executable="thrift-0.8.0.exe" osfamily="windows">
<arg value="-out" />
<arg value="java/src" />
<arg value="--gen" />
<arg value="java" />
<arg file="Sample.thrift" />
</exec>
So, now I want to add the generated src folder automatically to the classpath of the project in Eclipse using Ant so that it is shown as a source folder when I open the project in Eclipse.
NOTE: I understand that the classpath for a project is present in the .classpath file and adding a classpathentry to it would solve my issue. But I want Eclipse to do that instead of me doing it in the .classpath file manually.
Further, I also had a look at the Ant-Eclipse project and found an Ant task to create a new Eclipse Java project and display its src folder as a source folder. But I don’t want a dependency on an external library.
<project name="test" default="eclipse" basedir=".">
<target name="eclipse">
<taskdef name="eclipse" classname="prantl.ant.eclipse.EclipseTask" />
<eclipse>
<project />
<classpath>
<source path="src" />
<output path="bin" />
</classpath>
</eclipse>
</target>
</project>
Is there a way to do this in the already existing Ant library in Eclipse?
Thanks a lot!
If you really don’t want to depend on anything external then you could consider using an XSLT stylesheet to edit the
.classpathfile (which is XML).add-dir.xsl
build.xml