You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

build-reports.xml 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project name="DMDirc-reports" default="default" basedir=".">
  3. <description>Checkstyle, findbugs, CPD and PMD reports</description>
  4. <target name="doallreports" depends="test-both,-allreports,javadoc"
  5. description="Run all reports." />
  6. <target name="domostreports" depends="test-both,-mostreports,javadoc"
  7. description="Run all reports except Findbugs." />
  8. <target name="checkstyle" depends="checkstyle-all, -move-index" description="Run checkstyle." />
  9. <target name="-allreports" depends="findbugs, cpd, pmd, checkstyle" />
  10. <target name="-mostreports" depends="cpd, pmd, checkstyle" />
  11. <target name="-init-checkstyle" depends="-init-dependencies">
  12. <taskdef resource="checkstyletask.properties" classpathref="analyse-classpath"/>
  13. </target>
  14. <target name="-init-pmd" depends="-init-dependencies">
  15. <taskdef name="pmd" classpathref="analyse-classpath" classname="net.sourceforge.pmd.ant.PMDTask" />
  16. </target>
  17. <target name="-init-cpd" depends="-init-dependencies">
  18. <taskdef name="cpd" classpathref="analyse-classpath" classname="net.sourceforge.pmd.cpd.CPDTask" />
  19. </target>
  20. <target name="-init-findbugs" depends="-init-dependencies">
  21. <taskdef name="findbugs" classpathref="analyse-classpath" classname="edu.umd.cs.findbugs.anttask.FindBugsTask" />
  22. </target>
  23. <target name="checkstyle-all" depends="-init-checkstyle">
  24. <checkstyle config="etc/checkstyle/dmdirc.xml" failureProperty="checkstyle.failure" failOnViolation="false">
  25. <fileset dir="src/" includes="**/*.java" excludes="net/miginfocom/**"/>
  26. <fileset dir="modules/plugins/src/" includes="**/*.java"/>
  27. <fileset dir="modules/parser/src/" includes="**/*.java"/>
  28. <fileset dir="modules/util/src/" includes="**/*.java"/>
  29. <formatter type="xml" tofile="reports/checkstyle.xml"/>
  30. </checkstyle>
  31. <xslt in="reports/checkstyle.xml" out="reports/checkstyle.html" style="etc/checkstyle/checkstyle.xsl"/>
  32. </target>
  33. <target name="-move-index">
  34. <copy file="etc/reports/sorttable.js" tofile="reports/sorttable.js"/>
  35. </target>
  36. <target name="pmd" description="Run PMD." depends="-init-pmd">
  37. <pmd shortFilenames="true">
  38. <ruleset>etc/pmd/full.xml</ruleset>
  39. <formatter type="xml" toFile="reports/report-pmd.xml" linkPrefix="http://pmd.sourceforge.net/xref/"/>
  40. <fileset dir="src/" includes="com/dmdirc/**/*.java" />
  41. <fileset dir="modules/plugins/src/" includes="com/dmdirc/**/*.java"/>
  42. <fileset dir="modules/util/src/" includes="com/dmdirc/**/*.java"/>
  43. <fileset dir="modules/parser/src/" includes="com/dmdirc/**/*.java"/>
  44. </pmd>
  45. <xslt in="reports/report-pmd.xml" style="etc/pmd/pmd.xslt" out="reports/report-pmd.html" />
  46. </target>
  47. <target name="pmd-minimal" description="Run PMD with minimal ruleset." depends="-init-pmd">
  48. <pmd shortFilenames="true">
  49. <ruleset>etc/pmd/minimal.xml</ruleset>
  50. <formatter type="xml" toFile="reports/report-pmd.xml" linkPrefix="http://pmd.sourceforge.net/xref/"/>
  51. <fileset dir="src/" includes="com/dmdirc/**/*.java" />
  52. <fileset dir="modules/plugins/src/" includes="com/dmdirc/**/*.java"/>
  53. <fileset dir="modules/util/src/" includes="com/dmdirc/**/*.java"/>
  54. <fileset dir="modules/parser/src/" includes="com/dmdirc/**/*.java"/>
  55. </pmd>
  56. <xslt in="reports/report-pmd.xml" style="etc/pmd/pmd.xslt" out="reports/report-pmd.html" />
  57. </target>
  58. <target name="cpd" description="Run CPD." depends="-init-cpd">
  59. <cpd format="xml" minimumTokenCount="50" outputFile="reports/report-cpd.xml">
  60. <fileset dir="src/com/">
  61. <include name="**/*.java"/>
  62. </fileset>
  63. </cpd>
  64. <xslt in="reports/report-cpd.xml" style="etc/cpd/cpd.xslt" out="reports/report-cpd.html" />
  65. </target>
  66. <target name="findbugs" depends="-init-findbugs,jar" description="Run Findbugs.">
  67. <mkdir dir="reports/findbugs" />
  68. <findbugs home="/usr/share/java/findbugs/" effort="max"
  69. jvmargs="-Xmx512M"
  70. output="xml:withMessages"
  71. outputFile="reports/findbugs/report-fb.xml" reportLevel="low">
  72. <sourcePath path="src/" />
  73. <class location="dist/DMDirc.jar" />
  74. </findbugs>
  75. <xslt in="reports/findbugs/report-fb.xml" style="etc/findbugs/findbugs.xslt" out="reports/report-fb.html" />
  76. </target>
  77. <target name="-init-proguard" depends="-init-dependencies">
  78. <taskdef resource="proguard/ant/task.properties" classpathref="analyse-classpath"/>
  79. </target>
  80. <target name="deadcode" depends="-init-proguard">
  81. <proguard>
  82. -libraryjars ${java.home}/lib/rt.jar
  83. -libraryjars ${java.home}/lib/jce.jar
  84. -libraryjars lib/main/
  85. -libraryjars modules/plugins/lib/main/
  86. -injars dist/DMDirc.jar(com/dmdirc/**,net/miginfocom/**)
  87. -injars modules/plugins/dist/(com/dmdirc/**)
  88. -dontoptimize
  89. -dontobfuscate
  90. -dontpreverify
  91. -printusage reports/deadcode.txt
  92. -dontnote !com.dmdirc.**
  93. <!-- The main entry point -->
  94. -keep public class com.dmdirc.Main {
  95. public static void main(java.lang.String[]);
  96. }
  97. <!-- All plugins -->
  98. -keep class ** implements com.dmdirc.plugins.Plugin {
  99. &lt;init&gt;(...);
  100. public void load(com.dmdirc.plugins.PluginInfo, dagger.ObjectGraph);
  101. public void onLoad();
  102. public void showConfig(com.dmdirc.config.prefs.PreferencesDialogModel);
  103. }
  104. <!-- Dagger provider methods -->
  105. -keepclassmembers @dagger.Module class ** {
  106. @dagger.Provides *;
  107. }
  108. <!-- Dagger generated subclasses -->
  109. -keep class **$$ModuleAdapter
  110. -keep class **$$InjectAdapter
  111. -keep class **$$StaticInjection
  112. <!-- Injectable constructors -->
  113. -keepclassmembers class * {
  114. @javax.inject.Inject *;
  115. &lt;init&gt;();
  116. }
  117. <!-- Package info classes -->
  118. -keep class **.package-info
  119. <!-- Enum stuff. -->
  120. -keepclassmembers enum ** {
  121. *** valueOf(java.lang.String);
  122. *** values();
  123. }
  124. <!-- Parser callbacks -->
  125. -keepclassmembers class ** {
  126. public void on*(com.dmdirc.parser.interfaces.Parser, ...);
  127. }
  128. <!-- Serializable version fields -->
  129. -keepclassmembers class ** implements java.io.Serializable {
  130. static final long serialVersionUID;
  131. }
  132. <!-- Swing dialogs -->
  133. -keep class com.dmdirc.addons.ui_swing.** extends com.dmdirc.addons.ui_swing.dialogs.StandardDialog {
  134. &lt;init&gt;(...);
  135. }
  136. <!-- Swing window implementations -->
  137. -keep class ** extends com.dmdirc.addons.ui_swing.components.frames.TextFrame {
  138. &lt;init&gt;(...);
  139. }
  140. <!-- Swing frame managers -->
  141. -keep class ** implements com.dmdirc.addons.ui_swing.framemanager.FrameManager {
  142. &lt;init&gt;(...);
  143. }
  144. <!-- DCC plugin panels -->
  145. -keep class com.dmdirc.addons.dcc.ui.PlaceholderPanel { &lt;init&gt;(...); }
  146. -keep class com.dmdirc.addons.dcc.ui.TransferPanel { &lt;init&gt;(...); }
  147. <!-- Exported services -->
  148. -keepclassmembers class ** implements com.dmdirc.plugins.Plugin {
  149. @com.dmdirc.plugins.Exported &lt;methods&gt;;
  150. }
  151. <!-- Debug plugin commands -->
  152. -keep class * extends com.dmdirc.addons.debug.DebugCommand {
  153. &lt;init&gt;(...);
  154. String getName();
  155. void execute(...);
  156. }
  157. <!-- Possibly inlined constants -->
  158. -keepclassmembers class * {
  159. static final % *;
  160. static final java.lang.String *;
  161. }
  162. <!-- Non-DMDirc classes -->
  163. -keep class org.** { *; }
  164. -keep class net.** { *; }
  165. -keep class com.sun.** { *; }
  166. -keep class com.google.** { *; }
  167. -keep class com.palintir.** { *; }
  168. -keep class dagger.** { *; }
  169. </proguard>
  170. </target>
  171. <target name="with.warnings">
  172. <record name="reports/build-log.txt" action="start"/>
  173. </target>
  174. <target name="warnings-report">
  175. <record name="reports/build-log.txt" action="stop"/>
  176. <copy file="reports/build-log.txt" tofile="reports/warnings.txt">
  177. <filterchain>
  178. <!-- Pick out the warnings generated for source files -->
  179. <linecontainsregexp>
  180. <regexp pattern="java:[0-9]+: warning: .*"/>
  181. </linecontainsregexp>
  182. <!-- Trim whitespace and boilerplate -->
  183. <trim/>
  184. <replacestring from="[javac] ${basedir}${file.separator}" to=""/>
  185. <!-- Ignore anything that's not from a source directory (e.g. dagger generated code) -->
  186. <linecontainsregexp>
  187. <regexp pattern="^(modules${file.separator}[a-z]+${file.separator})?src.*"/>
  188. </linecontainsregexp>
  189. <!-- Sort the results in file order -->
  190. <sortfilter/>
  191. </filterchain>
  192. </copy>
  193. <copy file="reports/warnings.txt" tofile="reports/warnings-deprecations.txt">
  194. <filterchain>
  195. <linecontainsregexp>
  196. <regexp pattern=".*: warning: \[deprecation\] .*"/>
  197. </linecontainsregexp>
  198. </filterchain>
  199. </copy>
  200. <copy file="reports/warnings.txt" tofile="reports/warnings-other.txt">
  201. <filterchain>
  202. <linecontainsregexp negate="true">
  203. <regexp pattern=".*: warning: \[deprecation\] .*"/>
  204. </linecontainsregexp>
  205. </filterchain>
  206. </copy>
  207. </target>
  208. <target name="teamcity-warnings-report">
  209. <resourcecount property="warnings.count">
  210. <tokens>
  211. <concat>
  212. <filterchain>
  213. <tokenfilter>
  214. <linetokenizer/>
  215. </tokenfilter>
  216. </filterchain>
  217. <fileset file="reports/warnings.txt"/>
  218. </concat>
  219. </tokens>
  220. </resourcecount>
  221. <copy file="etc/warnings/template.xml" tofile="teamcity-info.xml">
  222. <filterset>
  223. <filter token="COUNT" value="${warnings.count}"/>
  224. </filterset>
  225. </copy>
  226. </target>
  227. </project>