--- a/build.xml
+++ b/build.xml
@@ -1,28 +1,118 @@
 <?xml version="1.0"?>
-<!-- This is the build.xml file for the BufferSelector plugin. -->
+
+<!--
+
+     This is the standard build.xml file for building the BufferSelector plugin.
+
+     The 'dist' target compiles the plugin, generates documentation, and creates
+     the JAR file.  Before running the 'dist' target, you will need to choose
+     whether to generate the documentation using one of these two targets:
+
+     - 'docs-xsltproc': Creates documentation using the xsltproc tool from
+       libxslt, available at http://xmlsoft.org/XSLT
+     - 'docs-xalan': Creates documentation using the Xalan XSLT processor,
+       available at http://xml.apache.org/
+
+     The default processor is xsltproc. You can change the processor to Xalan by
+     setting the docs-proc.target property to xalan. This can be done on the
+     command line by adding '-Ddocs-proc.target=xalan'. If you do not have any
+     documentation, you can remove the 'docs' target from the depends list for
+     the 'dist' target.
+
+     To use this template for building your own plugin, make these changes:
+
+     - Change 'name' property for the <project> to the name of your plugin
+     - Change definition of 'jedit.install.dir' to point to the directory
+       containing jedit.jar
+     - If necessary, add any dependencies to the 'project.class.path' definition
+     - If necessary, change the list of files in the 'dist' target
+     - If necessary, change the 'docs-xalan' and 'docs-xsltproc' targets to
+       reflect the appropriate values for your documentation
+
+-->
+
 <project name="BufferSelector" default="dist" basedir=".">
 
+    <property name="jedit.install.dir"  value="../.."/>
+    <property name="jar.name"  value="${ant.project.name}.jar"/>
+    <property name="docs-proc.target"  value="xsltproc"/>
+
+    <property name="src.dir" value="."/>
+    <property name="build.dir" value="build"/>
+    <property name="install.dir"  value=".."/>
 
 
-    <property file="build.properties" />
-    <property file="../build.properties" />
+    <path id="project.class.path">
+        <pathelement location="${jedit.install.dir}/jedit.jar"/>
+        <pathelement location="${src.dir}"/>
+    </path>
 
-    <property name="docs-proc.target"  value="xsltproc"/>
-    <property name="src.dir" value="."/>
-    <property name="build.dir" value="build"/>
 
-    <!-- You should set this property in your ../build.properties to 
-	     the location of the jedit "build-support/trunk" project
-	     checked out from jEdit's SVN repository --> 
-    
-   	<import file="${build.support}/plugin-build.xml" />
+    <target name="init">
+        <mkdir dir="${build.dir}"/>
+    </target>
 
-   	<selector id="packageFiles">
-      <or>
-        <filename name="*.gif" />
-        <filename name="*.txt" />
-      </or>
-    </selector>
 
-   	
+    <target name="compile" depends="init">
+        <javac
+            srcdir="${src.dir}"
+            destdir="${build.dir}"
+            deprecation="on"
+            includeJavaRuntime="yes"
+        >
+            <classpath refid="project.class.path"/>
+        </javac>
+    </target>
+
+
+    <target name="dist" depends="compile, docs">
+        <mkdir dir="${install.dir}"/>
+
+        <jar jarfile="${install.dir}/${jar.name}">
+            <fileset dir="${build.dir}"/>
+            <fileset dir="${src.dir}">
+                <include name="actions.xml"/>
+                <include name="**/*.props"/>
+                <include name="**/*.gif"/>
+                <include name="**/*.html"/>
+                <include name="**/*.txt"/>
+            </fileset>
+        </jar>
+    </target>
+
+
+    <target name="docs">
+        <antcall target="docs-${docs-proc.target}"/>
+    </target>
+
+
+    <!-- Generate docs with xsltproc tool from www.xmlsoft.org -->
+    <target name="docs-xsltproc">
+        <exec executable="xsltproc">
+            <arg value="--catalogs"/>
+            <arg value="--output"/>
+            <arg value="users-guide.html"/>
+            <arg value="users-guide.xsl"/>
+            <arg value="users-guide.xml"/>
+        </exec>
+    </target>
+
+
+    <!-- Generate docs with Xalan tool from xml.apache.org -->
+    <target name="docs-xalan">
+        <style
+            style="users-guide.xsl"
+            in="users-guide.xml"
+            out="users-guide.html"
+        />
+    </target>
+
+
+    <target name="clean">
+        <delete dir="${build.dir}"/>
+        <delete>
+            <fileset dir="." includes="users-guide.html"/>
+            <fileset dir="." includes="**/*~"/>
+        </delete>
+    </target>
 </project>