Creating Firefox extensions using Eclipse
by Vijay Kiran
Mozilla firefox, the latest hot browser from Mozilla Foundation. The firefox interface is developed in XUL, which gives the most flexible way to develop extra features called "extensions". I’ve been working with XUL since sometime, you can find the XUL Tutorial I’m writing in the Articles & Tutorials section. The most difficult thing for a developer coming from other language experience such as Java/.Net is the lack of proper IDE. I started out creating an extension recently. But code-debug-deploy was painful. I’d to create the XPIs manually and editing the files in Notepad was like going back in time. So I started out using Eclipse and Ant for developing the extension. The best thing is I can sync my source code using a cvs server as well. Its very simple. Create a simple project in Eclipse. And start adding your directories and files. For example, if you want to create a helloworld.xpi here is the list of files and directory structure you’ll need:
helloworld/
install.rdf
build.xml
content/
contents.rdf
helloworld.xul
helloworld.js
helloworld.css
You can create the entire structure in Eclipse -> New .. -> New File/New Folder. Here’s a sample build.xml
<?xml version="1.0"?> <project name="helloworld" default="createxpi"> <target name="createjar"> <zip destfile="hellworld.jar" basedir="." includes="content/**" /> </target> <target name="createxpi" depends="createjar"> <zip destfile="helloworld.xpi"> <zipfileset dir="." includes="helloworld.jar " prefix="chrome" /> <zipfileset dir="." includes="install.rdf" /> </zip> </target> </project>
Please see this link for more information on the source code for hellworld: Writing an Extension for Firefox Once you’ve added all the code, just right-click on the build.xml -> Run As -> Ant Build. Your XPI will be created and Open it using Firefox to install it. That’s it!
