File:  [mozdev] / adblocklearner / www / build.html
Revision 1.12: download - view: text, annotated - select for diffs - revision graph
Sat Sep 18 20:33:55 2004 UTC (13 years, 1 month ago) by babak
Branches: MAIN
CVS tags: HEAD
Full Learner with positive and negative experts, still needs some clean-up (remove unblocked items from list, remove some duplication, tokenize periods, case insensitivity...) .

<h4>A portable build script for Firefox extensions</h4>

<p>AdBlockLearner is my first experience with developing Firefox extensions. The first problem I faced was that for every change I made to my overlay or Javascript code, I needed to repackage the whole thing, which was very tedious. Unix developers probably use a makefile or a shell script to automate the build process. With Windows you can either create a batch file (.bat) or run shell scripts under Cygwin.</p>

<p>Being mostly a Java guy myself, I like to write things that are as platform independent as possible.  <a href="">Ant</a> is a great build tool written in Java and for Java projects, but you can use it for many other things too. It uses an XML syntax which can make it sometimes hard to read, but the fact that it abstracts away operations such as creating and deleting directories, or zipping and tarring files, largely makes up for it. Of course it is also smart like makefile in that it only worries about files that have been changed. Finally, it is very well documented with plenty of examples and is very easy to learn. That is why I decided to write my build script for my extension using Ant!</p>

<p>The cool thing is that you can probably reuse my script for your own extensions, as long as you use the same folder hierarchy as mine. Then you only need to replace "adblocklearner" in my <a href="build.xml">build.xml file</a> with whatever the name of your own project is, et voila! My folder hierarchy is very straightforward, and just follows the Firefox extension guidelines:</p>


    -----build.xml, install.js, install.rdf, adblocklearner.xpi   
    -----chrome    //the structure of this folder is more or less the same for every Firefox extension
               ----- content
                   ----- adblocklearner    //this folder contains the overlay and javascript
                   ----- skin                      //this folder contains a subfolder called "classic", 
                                                       //which in turn contains an "adblocklearner" subfolder with the skin-related files inside

<p>Explanation of the build file, if you are new to Ant: </p><ul>
<li>The property tags define the project name, the location of the source folder as well the temporary location of a "build" folder, which is deleted once the packaging is finished.</li>
<li>The target tag is where all the action happens...  The timestamp thing is useful if you want to use it to name your latest build for example. Here it doesn't do much, you can safely remove it!  Using the mkdir, zip and copy tags, the script respectively creates a temporary build folder, zips the content of the chrome folder, copies the install files it to the folder as well and then there's a second round of zipping to create the final xpi file, before finally deleting the temporary "build" folder.</li>

<p> I realize that this build file could be improved. For example, I don't think I need to create a property tag for the project name, since it is already specified in the "project" tag. Also, the "timestamp" tag can be safely removed.</p>

FreeBSD-CVSweb <>