Ant build file to package Firefox's extension

By xngo on February 22, 2019

Below is an example of Ant build file to package Firefox's extension.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build" name="yourFirefoxExtName">
  <target name="build">
    <!-- JAR the content of your chrome/ folder -->
    <jar destfile="${ant.project.name}.jar">
      <fileset dir="chrome">
        <exclude name="${ant.project.name}.jar"/>
      </fileset>
    </jar>
 
    <!-- Create XPI file. -->
    <move file="${ant.project.name}.jar" todir="chrome" overwrite="yes" />
    <zip destfile="${ant.project.name}.xpi" basedir=".">
        <include name="chrome/${ant.project.name}.jar"/>
        <include name="chrome.manifest"/>
        <include name="install.rdf"/>
    </zip>
    <!--
      The content of your XPI file looks like the following:
      C:.
      ¦   chrome.manifest
      ¦   install.rdf
      ¦
      +---chrome
              yourFirefoxExtName.jar      
    -->
  </target>
</project>

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.