build.xml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="ownCloud" default="build" xmlns:jsl="antlib:com.googlecode.jslint4java">
  3. <!-- the target 'build' can be used by developers for command line builds -->
  4. <target name="build" depends="prepare,lint,jslint,phploc,pdepend,phpmd,phpcs,phpcpd,phpdoc,phpunit"/>
  5. <!-- the target 'build-ci' is used within our Jenkins CI-server http://ci.tmit.eu -->
  6. <target name="build-ci" depends="prepare,lint,jslint-ci,phploc,pdepend,phpmd-ci,phpcs-ci,phpcpd-ci,phpdoc,phpunit,phpcb-ci"/>
  7. <!-- the target 'build-pullrequests' is used within our Jenkins CI-server for pull request analysis -->
  8. <target name="build-pullrequests" depends="prepare,lint,jslint-ci"/>
  9. <target name="clean" description="Cleanup build artifacts">
  10. <delete dir="${basedir}/build/api"/>
  11. <delete dir="${basedir}/build/code-browser"/>
  12. <delete dir="${basedir}/build/coverage"/>
  13. <delete dir="${basedir}/build/logs"/>
  14. <delete dir="${basedir}/build/pdepend"/>
  15. </target>
  16. <target name="prepare" depends="clean"
  17. description="Prepare for build">
  18. <mkdir dir="${basedir}/build/api"/>
  19. <mkdir dir="${basedir}/build/code-browser"/>
  20. <mkdir dir="${basedir}/build/coverage"/>
  21. <mkdir dir="${basedir}/build/logs"/>
  22. <mkdir dir="${basedir}/build/pdepend"/>
  23. </target>
  24. <!-- php syntax analysis -->
  25. <target name="lint">
  26. <apply executable="php" failonerror="true">
  27. <arg value="-l" />
  28. <fileset dir="${basedir}">
  29. <include name="**/*.php" />
  30. <exclude name="**/3rdparty/**" />
  31. <exclude name="**/l10n/**" />
  32. <!-- modified / -->
  33. </fileset>
  34. </apply>
  35. <!-- this looks for @brief and @returns annotation in PHP files and fails if it found some -->
  36. <apply executable="egrep" failonerror="false" resultproperty="grepReturnCode">
  37. <arg value="-rsHn" />
  38. <arg value="@brief|@returns" />
  39. <fileset dir="${basedir}/build">
  40. <include name="**/*.php" />
  41. <exclude name="**/3rdparty/**" />
  42. <exclude name="**/l10n/**" />
  43. </fileset>
  44. </apply>
  45. <!-- fail if grep has found something -->
  46. <fail message="Please remove @returns and @brief annotations for PHPDoc (listed above)">
  47. <condition>
  48. <equals arg1="0" arg2="${grepReturnCode}"/>
  49. </condition>
  50. </fail>
  51. </target>
  52. <!-- javascript lint -->
  53. <target name="jslint-ci" description="Run the JSLint tool on JS files">
  54. <jsl:jslint options="white,sloppy,vars,bitwise,eqeq,browser" haltOnFailure="false">
  55. <jsl:predef>
  56. jQuery,$$,OC,$,oc_webroot,oc_appswebroots,oc_current_user,t,Files,FileList,FileActions,localStorage,OCCategories,EventSource,OCdialog,SVGSupport,dragOptions,dragOptions,folderDropOptions,formatDate,humanFileSize,procesSelection,relative_modified_date,scanFiles,simpleFileSize,simpleSize
  57. </jsl:predef>
  58. <!-- jsl:formatter type="plain" / -->
  59. <jsl:formatter type="xml" destfile="build/logs/jslint.xml" />
  60. <fileset dir="${basedir}" includes="**/*.js" excludes="**/*.min.js,**/3rdparty/**" />
  61. </jsl:jslint>
  62. </target>
  63. <target name="jslint" description="Run the JSLint tool on JS files">
  64. <jsl:jslint options="white,sloppy,vars,bitwise,eqeq,browser" haltOnFailure="false">
  65. <jsl:predef>
  66. jQuery,$$,OC,$,oc_webroot,oc_appswebroots,oc_current_user,t,Files,FileList,FileActions,localStorage,OCCategories,EventSource,OCdialog,SVGSupport,dragOptions,dragOptions,folderDropOptions,formatDate,humanFileSize,procesSelection,relative_modified_date,scanFiles,simpleFileSize,simpleSize
  67. </jsl:predef>
  68. <jsl:formatter type="plain" />
  69. <fileset dir="${basedir}" includes="**/*.js" excludes="**/*.min.js,**/3rdparty/**" />
  70. </jsl:jslint>
  71. </target>
  72. <target name="phploc" description="Measure project size using PHPLOC">
  73. <exec executable="phploc">
  74. <arg value="--log-csv" />
  75. <arg value="${basedir}/build/logs/phploc.csv" />
  76. <arg path="${basedir}" />
  77. </exec>
  78. </target>
  79. <target name="pdepend"
  80. description="Calculate software metrics using PHP_Depend">
  81. <exec executable="pdepend">
  82. <arg value="--jdepend-xml=${basedir}/build/logs/jdepend.xml" />
  83. <arg value="--jdepend-chart=${basedir}/build/pdepend/dependencies.svg" />
  84. <arg value="--overview-pyramid=${basedir}/build/pdepend/overview-pyramid.svg" />
  85. <arg value="--ignore=${basedir}/3rdparty/"/>
  86. <arg path="${basedir}" />
  87. </exec>
  88. </target>
  89. <target name="phpmd-ci"
  90. description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
  91. <exec executable="phpmd">
  92. <arg path="${basedir}" />
  93. <arg value="xml" />
  94. <arg value="${basedir}/build/phpmd.xml" />
  95. <arg value="--reportfile" />
  96. <arg value="${basedir}/build/logs/pmd.xml" />
  97. <arg value="--exclude" />
  98. <arg value="${basedir}/3rdparty/" />
  99. </exec>
  100. </target>
  101. <target name="phpmd"
  102. description="Perform project mess detection using PHPMD creating a log file for the continuous integration server">
  103. <exec executable="phpmd">
  104. <arg path="${basedir}" />
  105. <arg value="xml" />
  106. <arg value="${basedir}/build/phpmd.xml" />
  107. <arg value="--exclude" />
  108. <arg value="${basedir}/3rdparty/" />
  109. </exec>
  110. </target>
  111. <target name="phpcs-ci"
  112. description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
  113. <exec executable="phpcs" >
  114. <arg value="-p" />
  115. <arg value="-v" />
  116. <arg value="--tab-width=4" />
  117. <arg value="--report=checkstyle" />
  118. <arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
  119. <arg value="--standard=${basedir}/build/phpcs.xml" />
  120. <arg path="${basedir}" />
  121. </exec>
  122. </target>
  123. <target name="phpcs"
  124. description="Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server">
  125. <exec executable="phpcs" >
  126. <arg value="-p" />
  127. <arg value="-v" />
  128. <arg value="--tab-width=4" />
  129. <arg value="--standard=${basedir}/build/phpcs.xml" />
  130. <arg path="${basedir}" />
  131. </exec>
  132. </target>
  133. <target name="phpcpd" description="Find duplicate code using PHPCPD">
  134. <exec executable="phpcpd">
  135. <arg value="--exclude" />
  136. <arg value="${basedir}/3rdparty/" />
  137. <arg path="${basedir}" />
  138. </exec>
  139. </target>
  140. <target name="phpcpd-ci" description="Find duplicate code using PHPCPD">
  141. <exec executable="phpcpd">
  142. <arg value="--log-pmd" />
  143. <arg value="${basedir}/build/logs/pmd-cpd.xml" />
  144. <arg value="--exclude" />
  145. <arg value="${basedir}/3rdparty/" />
  146. <arg path="${basedir}" />
  147. </exec>
  148. </target>
  149. <!-- No idea if we need this within this build file. This is part of the release which is not contained within this script. -->
  150. <target name="phpdoc"
  151. description="Generate API documentation using PHPDocumentor">
  152. <!-- exec executable="phpdox"/ -->
  153. </target>
  154. <!-- currently we use autotest.sh for executing the unit tests against 3 different database setups -->
  155. <target name="phpunit" description="Run unit tests with PHPUnit">
  156. <echo message="TODO: phpunit goes here"/>
  157. <!-- exec executable="phpunit" failonerror="true"/ -->
  158. </target>
  159. <target name="phpcb-ci"
  160. description="Aggregate tool output with PHP_CodeBrowser">
  161. <exec executable="phpcb">
  162. <arg value="--log" />
  163. <arg path="${basedir}/build/logs" />
  164. <arg value="--source" />
  165. <arg path="${basedir}" />
  166. <arg value="--output" />
  167. <arg path="${basedir}/build/code-browser" />
  168. </exec>
  169. </target>
  170. </project>