build.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Copyright (c) 2010, 2011, Barthelemy Dagenais All rights reserved.
  4. Redistribution and use in source and binary forms, with or without
  5. modification, are permitted provided that the following conditions are met:
  6. - Redistributions of source code must retain the above copyright notice, this
  7. list of conditions and the following disclaimer.
  8. - Redistributions in binary form must reproduce the above copyright notice,
  9. this list of conditions and the following disclaimer in the documentation
  10. and/or other materials provided with the distribution.
  11. - The name of the author may not be used to endorse or promote products
  12. derived from this software without specific prior written permission.
  13. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  14. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  17. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  18. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  19. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  20. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  21. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  22. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  23. POSSIBILITY OF SUCH DAMAGE.
  24. -->
  25. <project basedir="." default="build" name="py4j">
  26. <property environment="env"/>
  27. <property file="ant.properties"/>
  28. <property name="debuglevel" value="source,lines,vars"/>
  29. <property name="jar.name" value="py4j${version}.jar"/>
  30. <property name="release.name" value="py4j-${version}"/>
  31. <property name="junit.src.tests" value="test"/>
  32. <property name="py4jpy.dir" value="../py4j-python"/>
  33. <property name="py4jpy.dist.dir" value="${py4jpy.dir}/dist"/>
  34. <property name="java.dst.dir" value="${py4jpy.dir}/py4j-java"/>
  35. <property name="javadoc.dst.dir" value="${java.dst.dir}/javadoc"/>
  36. <property name="py4jdoc.dir" value="../py4j-web"/>
  37. <property name="doc.src.dir" value="${py4jdoc.dir}/_build/html/"/>
  38. <property name="doc.dst.dir" value="${py4jpy.dir}/doc" />
  39. <property name="htdocs.dst.dir" value="${basedir}/${py4jpy.dir}/htdocs"/>
  40. <property name="doc.javadoc.dst.dir" value="${doc.dst.dir}/_static/javadoc" />
  41. <!-- Py4J JAVA -->
  42. <path id="junit4.classpath">
  43. <pathelement location="${junit.path}"/>
  44. </path>
  45. <path id="py4j.classpath">
  46. <pathelement location="${build.dir}"/>
  47. <path refid="junit4.classpath"/>
  48. </path>
  49. <target name="init-dist">
  50. <mkdir dir="${dist.dir}"/>
  51. <mkdir dir="${dist.dir}/${release.name}"/>
  52. </target>
  53. <target name="init-java-release">
  54. <mkdir dir="${java.dst.dir}"/>
  55. </target>
  56. <target name="init">
  57. <mkdir dir="${build.dir}"/>
  58. <mkdir dir="${junit.output.dir}"/>
  59. <copy includeemptydirs="false" todir="${build.dir}">
  60. <fileset dir="src">
  61. <exclude name="**/*.launch"/>
  62. <exclude name="**/*.java"/>
  63. </fileset>
  64. </copy>
  65. <copy includeemptydirs="false" todir="${build.dir}">
  66. <fileset dir="test">
  67. <exclude name="**/*.launch"/>
  68. <exclude name="**/*.java"/>
  69. </fileset>
  70. </copy>
  71. </target>
  72. <!-- JAVA - CLEAN -->
  73. <target name="clean">
  74. <delete dir="${build.dir}"/>
  75. </target>
  76. <target name="clean-javadoc">
  77. <delete dir="${javadoc.dir}"/>
  78. </target>
  79. <target name="clean-junit">
  80. <delete dir="${junit.output.dir}"/>
  81. </target>
  82. <target depends="clean" name="clean-dist">
  83. <delete dir="${dist.dir}"/>
  84. </target>
  85. <target name="clean-jar">
  86. <delete file="${jar.name}"/>
  87. </target>
  88. <target depends="clean,clean-javadoc,clean-junit,clean-dist,clean-jar" name="cleanall"/>
  89. <target depends="cleanall" name="clean-java-release">
  90. <delete dir="${java.dst.dir}"/>
  91. </target>
  92. <!-- JAVA - COMPILE -->
  93. <target depends="init" name="build">
  94. <echo message="${ant.project.name}: ${ant.file}"/>
  95. <javac debug="true" debuglevel="${debuglevel}" destdir="${build.dir}" encoding="UTF-8"
  96. source="1.6" target="1.6" bootclasspath="${env.JAVA6_BOOTCLASSPATH}">
  97. <src path="src"/>
  98. <classpath refid="py4j.classpath"/>
  99. </javac>
  100. <javac debug="true" debuglevel="${debuglevel}" destdir="${build.dir}" encoding="UTF-8"
  101. source="1.6" target="1.6" bootclasspath="${env.JAVA6_BOOTCLASSPATH}">
  102. <src path="test"/>
  103. <classpath refid="py4j.classpath"/>
  104. </javac>
  105. </target>
  106. <!-- JAVA - JUNIT -->
  107. <target depends="build" name="java-test">
  108. <mkdir dir="${junit.output.dir}"/>
  109. <junit fork="yes" haltonfailure="true" printsummary="on">
  110. <formatter type="brief" usefile="false"/>
  111. <batchtest todir="${junit.output.dir}">
  112. <fileset dir="${junit.src.tests}">
  113. <include name="**/*Test.java"/>
  114. <exclude name="py4j/examples/*.java"/>
  115. </fileset>
  116. </batchtest>
  117. <classpath refid="py4j.classpath"/>
  118. </junit>
  119. </target>
  120. <target name="junitreport">
  121. <junitreport todir="${junit.output.dir}">
  122. <fileset dir="${junit.output.dir}">
  123. <include name="TEST-*.xml"/>
  124. </fileset>
  125. <report format="frames" todir="${junit.output.dir}"/>
  126. </junitreport>
  127. </target>
  128. <!-- JAVA - JAVADOC -->
  129. <target name="javadoc">
  130. <javadoc access="protected" author="true" classpath="" destdir="${javadoc.dir}" doctitle="Py4J" nodeprecated="false" nodeprecatedlist="false" noindex="false" nonavbar="false" notree="false" packagenames="py4j,py4j.examples,py4j.commands,py4j.reflection,py4j.model" source="1.6" sourcepath="src:examples" splitindex="true" use="true" version="true">
  131. <link href="http://java.sun.com/javase/6/docs/api/"/>
  132. </javadoc>
  133. </target>
  134. <!-- JAVA - DISTRIBUTION -->
  135. <target depends="build" name="jar">
  136. <jar destfile="${jar.name}" basedir="${build.dir}" excludes="p1/**,**/*Test*.class"/>
  137. </target>
  138. <target depends="init-dist,build,jar" name="dist">
  139. <copy todir="${dist.dir}/${release.name}/src">
  140. <fileset dir="src"/>
  141. </copy>
  142. <copy todir="${dist.dir}/${release.name}/test">
  143. <fileset dir="test"/>
  144. </copy>
  145. <copy file="LICENSE.txt" tofile="${dist.dir}/py4j-${version}/LICENSE.txt"/>
  146. <copy file="README.txt" tofile="${dist.dir}/py4j-${version}/README.txt"/>
  147. <copy file="build.xml" tofile="${dist.dir}/py4j-${version}/build.xml"/>
  148. <copy file="ant.properties" tofile="${dist.dir}/py4j-${version}/ant.properties"/>
  149. <copy file="${jar.name}" tofile="${dist.dir}/py4j-${version}/${jar.name}"/>
  150. <tar destfile="${dist.dir}/${release.name}.tar" basedir="${dist.dir}/${release.name}/"/>
  151. <gzip src="${dist.dir}/${release.name}.tar" destfile="${dist.dir}/${release.name}.tar.gz"/>
  152. <delete file="${dist.dir}/${release.name}.tar"/>
  153. </target>
  154. <target depends="dist,java-test,init-java-release,javadoc" name="java-release">
  155. <copy todir="${java.dst.dir}">
  156. <fileset dir="${dist.dir}/${release.name}"/>
  157. </copy>
  158. <copy todir="${javadoc.dst.dir}">
  159. <fileset dir="${javadoc.dir}"/>
  160. </copy>
  161. </target>
  162. <target depends="dist,init-java-release,javadoc" name="java-light-release">
  163. <copy todir="${java.dst.dir}">
  164. <fileset dir="${dist.dir}/${release.name}"/>
  165. </copy>
  166. <copy todir="${javadoc.dst.dir}">
  167. <fileset dir="${javadoc.dir}"/>
  168. </copy>
  169. </target>
  170. <!-- JAVA - EXECUTE EXAMPLE APPLICATIONS -->
  171. <target name="BufferGateway">
  172. <java classname="py4j.examples.BufferGateway" failonerror="true" fork="yes">
  173. <classpath refid="py4j.classpath"/>
  174. </java>
  175. </target>
  176. <target name="ExampleApplication">
  177. <java classname="py4j.examples.ExampleApplication" failonerror="true" fork="yes">
  178. <classpath refid="py4j.classpath"/>
  179. </java>
  180. </target>
  181. <!-- Py4J DOCUMENTATION -->
  182. <target name="clean-sphinx">
  183. <exec executable="make" dir="${py4jdoc.dir}">
  184. <arg line="clean"/>
  185. </exec>
  186. </target>
  187. <target name="sphinx">
  188. <exec executable="make" dir="${py4jdoc.dir}">
  189. <arg line="html"/>
  190. </exec>
  191. </target>
  192. <target depends="clean-sphinx,clean-javadoc" name="clean-sphinx-release">
  193. <delete dir="${doc.dst.dir}"/>
  194. <delete dir="${htdocs.dst.dir}"/>
  195. </target>
  196. <target depends="sphinx,javadoc" name="sphinx-release">
  197. <copy todir="${doc.dst.dir}">
  198. <fileset dir="${doc.src.dir}"/>
  199. </copy>
  200. <copy todir="${doc.javadoc.dst.dir}">
  201. <fileset dir="${javadoc.dir}"/>
  202. </copy>
  203. </target>
  204. <!-- Py4J PYTHON DISTRIBUTION -->
  205. <target name="clean-python-release">
  206. <delete dir="${py4jpy.dist.dir}"/>
  207. <delete file="${py4jpy.dir}/MANIFEST"/>
  208. </target>
  209. <target depends="build" name="python-test">
  210. <exec executable="python" dir="${py4jpy.dir}" failonerror="true">
  211. <arg line="--version"/>
  212. </exec>
  213. <exec executable="nosetests" dir="${py4jpy.dir}" failonerror="true">
  214. <arg line="-w src"/>
  215. <arg line="-c nose.cfg"/>
  216. </exec>
  217. </target>
  218. <target depends="java-release" name="python-tox">
  219. <exec executable="tox" dir="${py4jpy.dir}" failonerror="true">
  220. <arg line="--"/>
  221. </exec>
  222. </target>
  223. <target depends="java-light-release,sphinx-release" name="python-light-release">
  224. <exec executable="python" dir="${py4jpy.dir}">
  225. <arg line="setup.py"/>
  226. <arg line="sdist"/>
  227. <arg line="--formats=zip,gztar"/>
  228. </exec>
  229. <exec executable="python" dir="${py4jpy.dir}">
  230. <arg line="setup.py"/>
  231. <arg line="bdist_wheel"/>
  232. </exec>
  233. </target>
  234. <target depends="java-release,sphinx-release,python-tox" name="python-release">
  235. <exec executable="python" dir="${py4jpy.dir}">
  236. <arg line="setup.py"/>
  237. <arg line="sdist"/>
  238. <arg line="--formats=zip,gztar"/>
  239. </exec>
  240. <exec executable="python" dir="${py4jpy.dir}">
  241. <arg line="setup.py"/>
  242. <arg line="bdist_wheel"/>
  243. </exec>
  244. </target>
  245. <target depends="clean-python-release,clean-sphinx-release,clean-java-release" name="clean-release"/>
  246. </project>