PageRenderTime 50ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

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