- FAQ 319: What is eScript?
- FAQ 320: Language integration phase 1: How do I compile and build programs?
- FAQ 321: How do I load source files edited outside Eclipse?
- FAQ 322: How do I run an external builder on my source files?
- FAQ 323: How do I implement a compiler that runs inside Eclipse?
- FAQ 324: How do I react to changes in source files?
- FAQ 325: How do I implement an Eclipse builder?
- FAQ 326: Where are project build specifications stored?
- FAQ 327: How do I add a builder to a given project?
- FAQ 328: How do I implement an incremental project builder?
- FAQ 329: How do I handle setup problems for a given builder?
- FAQ 330: How do I make my compiler incremental?
- FAQ 331: Language integration phase 2: How do I implement a DOM?
- FAQ 332: How do I implement a DOM for my language?
- FAQ 333: How can I ensure that my model is scalable?
- FAQ 334: Language integration phase 3: How do I edit programs?
- FAQ 335: How do I write an editor for my own language?
- FAQ 336: How do I add Content Assist to my language editor?
- FAQ 337: How do I add hover support to my text editor?
- FAQ 338: How do I create problem markers for my compiler?
- FAQ 339: How do I implement Quick Fixes for my own language?
- FAQ 340: How do I support refactoring for my own language?
- FAQ 341: How do I create an Outline view for my own language editor?
- FAQ 342: Language integration phase 4: What are the finishing touches?
- FAQ 343: What wizards do I define for my own language?
- FAQ 344: When does my language need its own nature?
- FAQ 345: When does my language need its own perspective?
- FAQ 346: How do I add documentation and help for my own language?
- FAQ 347: How do I support source-level debugging for my own language?
FAQ 322: 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"/> </exec> <copy file="src/EscriptPlugin/SampleAction.class" todir="bin/EscriptPlugin/actions/"/> <eclipse.convertPath fileSystemPath="c:\faq\Escript Plugin\" property="resourcePath"/> <eclipse.refreshLocal resource="${resourcePath}" depth="infinite"/> </target> </project>
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.
Note
FAQ 315 What is Ant?
FAQ 317 How do I add my own external tools?
FAQ 323 How do I implement a compiler that runs inside Eclipse?