Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: for the plan.

Jump to: navigation, search

FAQ How do I run an external builder on my source files?

Use the default Eclipse text editor to edit the eScript source files, and use an Ant script to compile the eScript source into Java bytecodes. Ant scripts are XML-based scripts that can be used to automate certain build processes. You could view them as a much more flexible incarnation of Make.

A simple Ant script (build.xml) may look like this:

	<?xml version="1.0" encoding="UTF-8"?>
	<project name="eScript" default="compile" basedir=".">
	   <target name="compile">
	      <exec executable="eScriptc.exe" dir="src">
	         <arg value="-cp"/>
	         <arg value="... long classpath specifier ..."/>
	         <arg value="EscriptPlugin/SampleAction.eScript"/>
	      <copy file="src/EscriptPlugin/SampleAction.class" 
	                   fileSystemPath="c:\faq\Escript Plugin\" 
	      <eclipse.refreshLocal resource="${resourcePath}" 

Of course, this script can be made more elegant, but it serves to highlight the main problems with the approach. First, we have to compute the project&#146;s classpath, which can be quite complex for a plug-in, and pass it to the eScript compiler. Second, we have to explicitly pass in the name of the source file. Third, we need to replicate the JDT&#146;s behavior by copying the resulting class file to the project&#146;s bin directory. Finally, we have to refresh the workspace so that Eclipse gets notified of the changes in the class files and can rebuild dependant components in the workspace.

It is not easy to discover structure about Eclipse&#146;s installed plug-ins from outside Eclipse, so compilation of eScript source files becomes a real challenge when done outside Eclipse. Perhaps most troublesome is that each time the source changes, the user has to manually run Ant on the build.xml file. This spins off a new compiler, which has to load the entire classpath to do name and symbol resolution, and the compilation process becomes quite noticeable and annoying after a while.

But even with these limitations, this approach is viable for developers who do not want to write a new plug-in to support their language. Using the Eclipse support for launching external tools and Ant scripts, eScript files can be edited and compiled without having to leave the IDE.

See Also:

This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Back to the top