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

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