Jump to: navigation, search

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

Revision as of 22:26, 29 May 2006 by Psylence519.gmail.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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’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’s behavior by copying the resulting class file to the project’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’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.