PageRenderTime 74ms CodeModel.GetById 62ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 1ms

/jEdit/tags/jedit-4-3-pre5/build-support/plugin-build.xml

#
XML | 563 lines | 267 code | 62 blank | 234 comment | 0 complexity | 3bbc7870f9c5c0de465ee30d7c0aaad7 MD5 | raw file
  1<project name="jEditPlugin" default="build">
  2
  3    <!-- {{{ Top-Level build file for jEdit plugins. ====== -->
  4    <!--
  5        Version: $Id: plugin-build.xml 5520 2006-07-03 17:44:45Z vampire0 $
  6        Requires apache Ant 1.6, including optional tasks, and xerces.
  7
  8        :tabSize=4:indentSize=4:noTabs=true:
  9        :folding=explicit:collapseFolds=2:
 10
 11        To use this file, use the "import" task from ant
 12        on your plugin's build file, like this:
 13
 14        <import file="../build-support/plugin-build.xml" />
 15
 16        The use of the property is to ease the work of the plugin
 17        packagers.
 18
 19        General tips:
 20        - To override properties, either use the several
 21          options for build.properties files, or declare
 22          them in you plugin's build file *before* the
 23          import statement.
 24        - To override paths and selectors, declare them in
 25          your build file *after* the import statement.
 26
 27        Some tasks require the ant-contrib library available from
 28        http://ant-contrib.sourceforge.net. If you have the
 29        library, specify a property named "ant-contrib.jar" with
 30        the location of the library. The tasks that need ant-contrib
 31        are the tasks related to plugin dependencies.
 32
 33        For JUnit support, make sure you have the ant-junit.jar
 34        library in Ant's lib directory. Specify the location of
 35        the junit jar file using the property "junit.jar".
 36    -->
 37    <!-- ===============================================}}} -->
 38
 39    <!-- {{{ Property definitions ========================= -->
 40    <!-- First loads options from the user's optional
 41         build.properties files in the following order:
 42         current dir, parent dir, $HOME/.build.properties
 43         and finally $HOME/build.properties . The defines
 44         several default properties used by the different
 45         targets.                                           -->
 46    <!-- ================================================== -->
 47    <property file="../build.properties" />
 48    <property file="build.properties" />
 49    <echo>${java.home}</echo>
 50    <property file="${user.home}/.build.properties" />
 51    <property file="${user.home}/build.properties" />
 52
 53    <!-- where to find jEdit and plugins    -->
 54    <property name="jedit.install.dir"  value="../../jEdit" />
 55    <property name="jedit.user.home"    value="${user.home}/.jedit" />
 56    <property name="plugins.srcdir"     value=".." />
 57    <property name="install.dir"        value=".." />
 58
 59    <!-- some info about the plugin and where to put it -->
 60    <property name="src.dir"        value="." />
 61    <property name="jar.file"       value="${ant.project.name}.jar" />
 62    <property name="src.zip.file"   value="${ant.project.name}.zip" />
 63    <property name="dist.target"    value="dist.nojavadoc" />
 64
 65    <!-- where files will go    -->
 66    <property name="build.dir"      value="build" />
 67    <property name="build.classes"  value="${build.dir}/classes" />
 68    <property name="build.docs"     value="${build.dir}/docs" />
 69    <property name="build.javadoc"  value="${build.docs}/javadoc" />
 70    <property name="build.extras"   value="${build.dir}/extras" />
 71
 72    <!-- default compiler flags -->
 73    <property name="compiler.debug"         value="off" />
 74    <property name="compiler.optimize"      value="off" />
 75    <property name="compiler.deprecation"   value="off" />
 76    <property name="compiler.verbose"       value="off" />
 77    <property name="compiler.nowarn"        value="off" />
 78    <property name="compiler.target"        value="1.4" />
 79    <property name="compiler.source"        value="1.4" />
 80    <property name="compiler.listfiles"     value="no" />
 81    <property name="compiler.fork"          value="no" />
 82
 83    <!-- default documentation options  -->
 84    <property name="docs-proc.target"       value="xsltproc" />
 85    <property name="docbookx.dtd"           value="../XML/xml/dtds/docbookx.dtd" />
 86    <dirname property="build.support"       file="${ant.file.jEditPlugin}" />
 87    <property name="user-doc.xsl"           location="${build.support}/users-guide.xsl" />
 88    <property name="user-doc.xml"           location="${basedir}/docs/users-guide.xml" />
 89    <property name="user-doc.out"           value="users-guide.html" />
 90    <property name="javadoc.title"          value="${ant.project.name} API" />
 91    <property name="docbook.xsl.sheet"      value="html/chunk.xsl" />
 92    <pathconvert property="docs.style.sheet"
 93                 dirsep="/">
 94        <path location="${docbook.xsl}/${docbook.xsl.sheet}" />
 95    </pathconvert>
 96    <property name="xsltproc.executable"    value="xsltproc" />
 97
 98    <!-- default cvs options -->
 99    <property name="jedit.cvs.user" value="${user.name}" />
100    <property name="cvs.rsh"        value="ssh" />
101    <property name="cvs.root"       value=":ext:${jedit.cvs.user}@jedit.cvs.sourceforge.net:/cvsroot/jedit" />
102
103    <!-- default junit options -->
104    <property name="junit.jar"              value="junit.jar" />
105    <property name="junit.testcase"         value="${ant.project.name}TestSuite" />
106    <property name="junit.printsummary"     value="on" />
107    <property name="junit.haltonfailure"    value="off" />
108
109    <fail message="The jedit JAR (jedit.jar) is not available in &quot;${jedit.install.dir}&quot;">
110        <condition>
111            <not>
112                <available file="${jedit.install.dir}/jedit.jar"
113                           type="file" />
114            </not>
115        </condition>
116    </fail>
117
118    <!-- default class path; try not to override this,
119         since the intention is to add here anything that
120         might be needed by all the plugins (such as the
121         jedit.jar file and any other jar files that
122         jEdit might use in the future.                     -->
123    <path id="default.class.path">
124        <pathelement location="${jedit.install.dir}/jedit.jar" />
125        <pathelement location="${junit.jar}" />
126    </path>
127
128    <!-- this is the classpath used by the "compile"
129         target. Override this one if you need to. You don't
130         need to reference "default.class.path" here - it's added
131         automatically to the javac command.                -->
132    <path id="project.class.path" />
133
134    <!-- {{{ Load ant-contrib library ===================== -->
135    <taskdef resource="net/sf/antcontrib/antcontrib.properties" onerror="ignore">
136        <classpath>
137            <pathelement location="${ant-contrib.jar}"/>
138        </classpath>
139    </taskdef>
140    <!-- ===============================================}}} -->
141
142    <!-- ===============================================}}} -->
143
144    <!-- {{{ Custom javac task ============================ -->
145    <presetdef name="jp.javac">
146        <javac destdir="${build.classes}"
147                debug="${compiler.debug}"
148                optimize="${compiler.optimize}"
149                deprecation="${compiler.deprecation}"
150                verbose="${compiler.verbose}"
151                nowarn="${compiler.nowarn}"
152                target="${compiler.target}"
153                source="${compiler.source}"
154                listfiles="${compiler.listfiles}"
155                fork="${compiler.fork}"
156                >
157            <src location="${src.dir}" />
158            <classpath refid="default.class.path" />
159            <classpath refid="project.class.path" />
160        </javac>
161    </presetdef>
162    <!-- }}} ============================================== -->
163
164    <!-- {{{ Compilation and building ===================== -->
165
166    <!-- This selector defines the files that will be
167         compiled by the "compile" target. Define here which
168         files under ${src.dir} will be compiled when the
169         "compile" task is called.                          -->
170    <selector id="compileFiles">
171        <filename name="**/*.java" />
172    </selector>
173
174    <!-- This selector defines extra files to be included
175         in the plugin's JAR file. The context of the
176         selector is the plugin's directory (${basedir}),
177         so it will not work for files outside the plugin
178         directory. For those cases, use the "build.prepare"
179         target. By default, it's empty.                    -->
180    <selector id="packageFiles">
181        <size value="0" when="less" />
182    </selector>
183
184    <!-- This selector defines other files that should be packaged
185         in the plugin's jar file; by default it contains actions.xml,
186         dockables.xml, services.xml, any files ending in ".props",
187         "LICENSE" and "README". The context is "${basedir}". Override
188         it if your plugin needs special treatment for these files. -->
189    <selector id="extraFiles">
190        <and>
191            <or>
192                <filename name="**/actions.xml" />
193                <filename name="**/dockables.xml" />
194                <filename name="**/services.xml" />
195                <filename name="**/*.props" />
196                <filename name="**/LICENSE" />
197                <filename name="**/README" />
198            </or>
199            <not>
200                <filename name="${build.dir}/**" />
201            </not>
202        </and>
203    </selector>
204
205    <!-- {{{ Target: compile ============================== -->
206    <!-- Compiles all the ".java" files present in the
207         directory pointed by the "src.dir" property
208         defined above. Classes are put in the directory
209         designated in the "build.classes" property.
210         The following properties control the behavior of
211         the compiler (relates to options to the javac
212         ant task, defaults in parethesis):
213         compiler.debug: the debug option (off)
214         compiler.optimize: the optimize option (off)
215         compiler.deprecation: deprecation option (off)
216         compiler.verbose: the verbose option (off)
217         compiler.nowarn: the nowarn option (off)
218         compiler.target: the target option (1.3)
219         compiler.source: the source option (1.3)
220         compiler.listfiles: the listfiles option (no)      -->
221    <target name="compile"
222            description="Compile the plugin's classes">
223
224        <mkdir dir="${build.classes}" />
225        <jp.javac>
226            <selector refid="compileFiles" />
227        </jp.javac>
228
229    </target>
230    <!-- ===============================================}}} -->
231
232    <!-- {{{ Target: clean ================================ -->
233    <!-- Removes the directory defined in the "build"
234         property, the "docbook-wrapper.xsl" file and the
235         file defined by the property "jar.file" in the
236         directory defined by "install.dir".                -->
237    <target name="clean" description="Cleans project directories">
238        <delete dir="${build.dir}" quiet="true" />
239    </target>
240    <!-- ===============================================}}} -->
241
242    <!-- {{{ Target: build ================================ -->
243    <!-- This target build the plugin JAR file. It
244         depends on two other targets: "compile", defined
245         above, and "build.prepare", which is empty in
246         this file but can be overriden by the plugin's
247         build file.
248         This target does the following after that:
249         * Copies all files defined by the extraFiles selector
250           to the staging area.
251         * Copies all files defined by the packageFiles selector
252           to the staging area.
253         * Creates a JAR with the name defined in
254           "jar.file" in the directory defined by
255           "install.dir". This JAR will contain the
256           contents of the directories defined by
257           "build.classes", "build.docs" and "build.extras"
258         If you need to have any other files added to the
259         JAR, override the "build.prepare" target and use
260         it to copy files to one of those three
261         directories, or redefine the "extraFiles"
262         selector.                                          -->
263
264    <target name="build"
265          depends="build.prepare,compile"
266          description="Builds the plugin JAR file (no docs)">
267
268        <mkdir dir="${build.classes}" />
269        <mkdir dir="${build.docs}" />
270        <mkdir dir="${build.extras}" />
271        <mkdir dir="${install.dir}" />
272
273        <copy todir="${build.extras}" includeEmptyDirs="false">
274            <fileset dir="${basedir}">
275                <selector refid="extraFiles" />
276            </fileset>
277        </copy>
278
279        <copy todir="${build.extras}" includeEmptyDirs="false">
280            <fileset dir="${basedir}">
281                <selector refid="packageFiles" />
282            </fileset>
283        </copy>
284
285        <jar jarfile="${install.dir}/${jar.file}">
286            <fileset dir="${build.classes}" />
287            <fileset dir="${build.docs}" />
288            <fileset dir="${build.extras}" />
289        </jar>
290
291        <antcall target="build.post" />
292
293    </target>
294    <!-- ===============================================}}} -->
295
296    <!-- {{{ Target: build.prepare ======================== -->
297    <!-- This implementation does nothing. See the
298         "build" target for details.                        -->
299    <target name="build.prepare" />
300    <!-- ===============================================}}} -->
301
302    <!-- {{{ Target: build.post =========================== -->
303    <!-- Called after the build process is finished.
304         Plugins can use this to copy extra jar files the
305         plugin needs to ${install.dir}.
306         By default does nothing.                           -->
307    <target name="build.post" />
308    <!-- ===============================================}}} -->
309
310    <!-- {{{ Target: dist.nojavadoc ======================= -->
311    <!-- Meta-task that builds the user documentation and
312         builds the plugin JAR file, but not the javadoc.   -->
313    <target name="dist.nojavadoc"  depends="userdocs,build" />
314    <!-- =============================================== }}} -->
315
316    <!-- {{{ Target: dist.complete ======================== -->
317    <!-- Meta-task that builds the user documentation,
318         javadoc documentation and builds the plugin JAR
319         file.                                              -->
320    <target name="dist.complete" depends="docs,build" />
321    <!-- ===============================================}}} -->
322
323    <!-- {{{ Target: dist ================================= -->
324    <!-- This task calls the target defined in the
325         property "dist.target" to build the plugin and
326         package it for distribution. Before proceeding,
327         it cleans the build directory.                     -->
328    <target name="dist" depends="clean" description="Builds JAR file, with docs">
329        <antcall target="${dist.target}" />
330    </target>
331    <!-- =============================================== }}} -->
332
333    <!-- {{{ Target: dist.source ========================== -->
334    <!-- Creates a ZIP file of the plugin's source. The
335         name of the file is defined in the property
336         "src.zip.file" and will be created in the
337         directory defined by "install.dir".                -->
338    <target name="dist.source">
339        <delete file="${install.dir}/${src.zip.file}" quiet="true" />
340        <zip destfile="${install.dir}/${src.zip.file}">
341            <fileset dir="${src.dir}">
342                <include name="**/*.*" />
343                <exclude name="${build.dir}/**" />
344            </fileset>
345        </zip>
346    </target>
347    <!-- ===============================================}}} -->
348
349    <!-- {{{ Target: package ============================== -->
350    <!-- Convenience target that calls both "docs" and
351         "build" to create the plugin jar file.             -->
352    <target name="package" depends="docs,build" />
353    <!-- =============================================== }}} -->
354
355    <!-- =============================================== }}} -->
356
357    <!-- {{{ Documentation ================================ -->
358
359    <!-- {{{ Target: docs ================================= -->
360    <!-- Meta-task that calls javadoc and userdocs.         -->
361    <target name="docs"
362            depends="javadoc,userdocs"
363            description="Build the User's Guide and Javadoc documentation" />
364    <!-- =============================================== }}} -->
365
366    <!-- {{{ Target: userdocs ============================= -->
367    <target name="userdocs"
368            description="Builds the user's guide.">
369        <mkdir dir="${build.docs}" />
370        <copy tofile="${build.docs}/users-guide.xsl"
371              flatten="true"
372              file="${user-doc.xsl}">
373            <filterset>
374                <filter token="docs.style.sheet"
375                        value="${docs.style.sheet}" />
376            </filterset>
377        </copy>
378        <antcall target="docs-${docs-proc.target}" />
379        <delete file="${build.docs}/users-guide.xsl" />
380    </target>
381    <!-- =============================================== }}} -->
382
383    <!-- {{{ Target: javadoc ============================== -->
384    <!-- Builds the javadoc documentation for the plugin,
385         placing it under "build.javadoc". Your plugin
386         build file *must* define a property called
387         named "javadoc.packagenames" to be used as the
388         "packagenames" option of ant's javadoc task.
389         This property is not defined in this file and
390         execition will probably fail if it's not defined.
391         The title of the documentation is defined in the
392         "javadoc.title" property.                          -->
393    <target name="javadoc"
394            description="Generates javadoc sourcecode documentation"
395            if="javadoc.packagenames">
396        <mkdir dir="${build.javadoc}" />
397        <javadoc sourcepath="${src.dir}"
398                    destdir="${build.javadoc}"
399                    packagenames="${javadoc.packagenames}"
400                    windowtitle="${javadoc.title}">
401            <classpath refid="default.class.path" />
402            <classpath refid="project.class.path" />
403        </javadoc>
404    </target>
405    <!-- =============================================== }}} -->
406
407    <!-- {{{ Target: docs-xsltproc ======================== -->
408    <!-- Generate docs with xsltproc tool from
409         www.xmlsoft.org. This task creates a temporary
410         file called "docbook.catalog" containing a
411         reference to the Docbook DTD defined in the
412         property "docbookx.dtd" above. The style sheet
413         used is defined by the property "user-doc.xsl",
414         and defaults to "docbook-wrapper.xsl". The XML
415         document to be processed is defined by the
416         "user-doc.xml" property, and defaults to
417         "docs/users-guide.xml". The output is defined in
418         the "user-doc.out" property.                       -->
419    <target name="docs-xsltproc" description="Generate user documentation in html format with xsltproc" if="docbook.catalog">
420        <exec executable="${xsltproc.executable}" dir="${build.docs}">
421            <arg value="-o" />
422            <arg value="${user-doc.out}" />
423            <arg value="--catalogs" />
424            <arg value="users-guide.xsl" />
425            <arg value="${user-doc.xml}" />
426			<env key="SGML_CATALOG_FILES"
427				 file="${docbook.catalog}" />
428        </exec>
429    </target>
430    <!-- ===============================================}}} -->
431
432    <!-- {{{ Target: docs-xalan =========================== -->
433    <!-- Generate docs with Xalan tool from
434         xml.apache.org . Same properties as the
435         "docs-xsltproc" target apply here.                 -->
436    <target name="docs-xalan"
437            if="docbookx.dtd"
438            description="Generate user documentation in html format with xalan">
439        <xslt basedir="."
440              destdir="${build.docs}"
441              style="${build.docs}/users-guide.xsl"
442              includes="${user-doc.xml}">
443            <xmlcatalog>
444                <dtd publicId="-//OASIS//DTD DocBook XML V4.2//EN"
445                     location="${docbookx.dtd}" />
446            </xmlcatalog>
447        </xslt>
448    </target>
449    <!-- ===============================================}}} -->
450
451    <!-- =============================================== }}} -->
452
453    <!-- {{{ Unit testing ================================= -->
454
455    <!-- {{{ Target: test ================================= -->
456    <!-- Meta-task that calls the defined test target.      -->
457    <target name="test"
458            description="Runs the plugin's unit tests.">
459        <antcall target="${unit.test.target}" />
460    </target>
461    <!-- ===============================================}}} -->
462
463    <!-- {{{ Target: test-junit============================ -->
464    <!-- Executes a jUnit test case defined by the plugin's
465         build file. The classpath for the test will be the
466         ${build.class} directory, the ${junit.jar} file and
467         the default.class.path and project.class.path path
468         structures.
469         -->
470    <target name="test-junit"
471            description="Runs the plugin's jUnit tests."
472            if="junit.testcase,junit.jar">
473
474        <junit printsummary="${junit.printsummary}"
475                haltonfailure="${junit.haltonfailure}">
476
477            <classpath>
478                <pathelement location="${junit.jar}" />
479                <pathelement location="${build.classes}" />
480                <path refid="default.class.path" />
481                <path refid="project.class.path" />
482            </classpath>
483
484            <test name="${junit.testcase}" />
485        </junit>
486
487    </target>
488    <!-- ===============================================}}} -->
489
490    <!-- ===============================================}}} -->
491
492    <!--{{{  Dependencies ================================= -->
493
494    <!-- {{{ Target: cvs.update =========================== -->
495    <!-- Updates a plugin's source code from CVS. This
496         target expects one parameter, "plugin.name",
497         containing the name of the plugin's directory in
498         CVS (don't include the leading "plugins"; for
499         example, use "XML" for the XML Plugin.             -->
500    <target name="cvs.update">
501        <mkdir dir="${plugins.srcdir}" />
502        <cvs command="update -dP"
503                compression="true"
504                cvsRsh="${cvs.rsh}"
505                cvsRoot="${cvs.root}"
506                dest="${plugins.srcdir}"
507                package="${plugin.name}" />
508    </target>
509    <!-- ===============================================}}} -->
510
511    <!-- {{{ Target: update.dependencies ================== -->
512    <!-- This task iterates through the dependency list
513         defined in the property "plugin.dependencies"
514         as a comma-separated list of plugin names, calling
515         the "cvs.update" target for each dependency.       -->
516    <target name="update.dependencies"
517            description="Download the most recent source of the needed plugins from CVS"
518            if="plugin.dependencies,ant-contrib.jar">
519        <foreach list="${plugin.dependencies}"
520                    target="cvs.update"
521                    param="plugin.name"
522                    delimiter=","
523                    trim="true" />
524    </target>
525    <!-- ===============================================}}} -->
526
527    <!-- {{{ Target: build.dependencies =================== -->
528    <target name="build.dependencies"
529            description="Builds the needed plugins from the available source code."
530            if="plugin.dependencies,ant-contrib.jar">
531        <foreach list="${plugin.dependencies}"
532                    target="build.other"
533                    param="plugin.name"
534                    delimiter=","
535                    trim="true" />
536    </target>
537    <!-- ===============================================}}} -->
538
539    <!-- {{{ Target: build.other=========================== -->
540    <!-- Builds a plugin from the code available in its
541         directory under "plugins.srcdir". This will call
542         the "build" target of that plugin's build file.
543         Expects the "plugin.name" parameter with the name
544         of the plugin's directory.                         -->
545    <target name="build.other">
546        <fail message="Can't find plugin: ${plugin.name}">
547            <condition>
548                <not>
549                    <available file="${plugins.srcdir}/${plugin.name}/build.xml" />
550                </not>
551            </condition>
552        </fail>
553        <ant antfile="${plugins.srcdir}/${plugin.name}/build.xml"
554                target="build"
555                inheritAll="false"
556                inheritRefs="false" />
557    </target>
558    <!-- ===============================================}}} -->
559
560    <!-- ================================================== }}}-->
561
562</project>
563