Browse Source

Use ProGuard to find dead code.

Add ProGuard as a dependency, and add a report target to generate a list of
dead code.

Includes a bunch of rules to keep obvious things we access via reflection,
but there's probably a lot more that needs adding.

Change-Id: I4ff6fc0b44c80ff6863f5f24995f4e7cb8e60293
Reviewed-on: http://gerrit.dmdirc.com/2862
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.8rc1
Chris Smith 10 years ago
parent
commit
5381cb708a
3 changed files with 116 additions and 0 deletions
  1. 1
    0
      .gitignore
  2. 113
    0
      build-reports.xml
  3. 2
    0
      ivy.xml

+ 1
- 0
.gitignore View File

@@ -32,6 +32,7 @@ __history
32 32
 /reports/report-fb.html
33 33
 /reports/report-pmd.*
34 34
 /reports/checkstyle.*
35
+/reports/deadcode.txt
35 36
 /etc/clover.license
36 37
 /.clover
37 38
 /test_profile

+ 113
- 0
build-reports.xml View File

@@ -88,4 +88,117 @@
88 88
         </findbugs>
89 89
         <xslt in="reports/findbugs/report-fb.xml" style="checkstyle/findbugs.xslt" out="reports/report-fb.html" />
90 90
     </target>
91
+
92
+    <target name="-init-proguard" depends="-init-dependencies">
93
+        <taskdef resource="proguard/ant/task.properties" classpathref="analyse-classpath"/>
94
+    </target>
95
+
96
+    <target name="deadcode" depends="-init-proguard">
97
+        <proguard>
98
+            -libraryjars ${java.home}/lib/rt.jar
99
+            -libraryjars ${java.home}/lib/jce.jar
100
+            -libraryjars lib/main/
101
+            -libraryjars modules/plugins/lib/main/
102
+
103
+            -injars dist/DMDirc.jar(com/dmdirc/**,net/miginfocom/**)
104
+            -injars modules/plugins/dist/(com/dmdirc/**)
105
+
106
+            -dontoptimize
107
+            -dontobfuscate
108
+            -dontpreverify
109
+            -printusage reports/deadcode.txt
110
+
111
+            -dontnote !com.dmdirc.**
112
+
113
+            <!-- The main entry point -->
114
+            -keep public class com.dmdirc.Main {
115
+                public static void main(java.lang.String[]);
116
+            }
117
+
118
+            <!-- All plugins -->
119
+            -keep class ** implements com.dmdirc.plugins.Plugin {
120
+                &lt;init&gt;(...);
121
+                public void load(com.dmdirc.plugins.PluginInfo, dagger.ObjectGraph);
122
+		public void onLoad();
123
+		public void showConfig(com.dmdirc.config.prefs.PreferencesDialogModel);
124
+            }
125
+
126
+            <!-- Dagger provider methods -->
127
+            -keepclassmembers @dagger.Module class ** {
128
+                @dagger.Provides *;
129
+            }
130
+
131
+            <!-- Dagger generated subclasses -->
132
+            -keep class **$$ModuleAdapter
133
+            -keep class **$$InjectAdapter
134
+            -keep class **$$StaticInjection
135
+
136
+            <!-- Injectable constructors -->
137
+            -keepclassmembers class * {
138
+                @javax.inject.Inject *;
139
+                &lt;init&gt;();
140
+            }
141
+
142
+            <!-- Package info classes -->
143
+            -keep class **.package-info
144
+
145
+            <!-- Enum stuff. -->
146
+            -keepclassmembers enum ** {
147
+                *** valueOf(java.lang.String);
148
+                *** values();
149
+            }
150
+
151
+            <!-- Parser callbacks -->
152
+            -keepclassmembers class ** {
153
+                public void on*(com.dmdirc.parser.interfaces.Parser, ...);
154
+            }
155
+
156
+            <!-- Serializable version fields -->
157
+            -keepclassmembers class ** implements java.io.Serializable {
158
+                static final long serialVersionUID;
159
+            }
160
+
161
+            <!-- Swing dialogs -->
162
+            -keep class com.dmdirc.addons.ui_swing.** extends com.dmdirc.addons.ui_swing.dialogs.StandardDialog {
163
+                &lt;init&gt;(...);
164
+            }
165
+
166
+            <!-- Swing window implementations -->
167
+            -keep class ** extends com.dmdirc.addons.ui_swing.components.frames.TextFrame {
168
+                &lt;init&gt;(...);
169
+            }
170
+
171
+            <!-- Swing frame managers -->
172
+            -keep class ** implements com.dmdirc.addons.ui_swing.framemanager.FrameManager {
173
+                &lt;init&gt;(...);
174
+            }
175
+
176
+            <!-- DCC plugin panels -->
177
+            -keep class com.dmdirc.addons.dcc.ui.PlaceholderPanel { &lt;init&gt;(...); }
178
+            -keep class com.dmdirc.addons.dcc.ui.TransferPanel { &lt;init&gt;(...); }
179
+
180
+            <!-- Exported services -->
181
+            -keepclassmembers class ** implements com.dmdirc.plugins.Plugin {
182
+                <!-- Parsers -->
183
+                public com.dmdirc.parser.interfaces.Parser getParser(com.dmdirc.parser.common.MyInfo,java.net.URI);
184
+                public com.dmdirc.parser.interfaces.ProtocolDescription getDescription();
185
+                <!-- Tab completers -->
186
+                public com.dmdirc.ui.input.tabstyles.TabCompletionStyle getCompletionStyle(com.dmdirc.ui.input.TabCompleter,com.dmdirc.WritableFrameContainer);
187
+            }
188
+
189
+            <!-- Possibly inlined constants -->
190
+            -keepclassmembers class * {
191
+                static final % *;
192
+                static final java.lang.String *;
193
+            }
194
+
195
+            <!-- Non-DMDirc classes -->
196
+            -keep class org.** { *; }
197
+            -keep class net.** { *; }
198
+            -keep class com.sun.** { *; }
199
+            -keep class com.google.** { *; }
200
+            -keep class com.palintir.** { *; }
201
+            -keep class dagger.** { *; }
202
+        </proguard>
203
+    </target>
91 204
 </project>

+ 2
- 0
ivy.xml View File

@@ -30,6 +30,8 @@
30 30
         <dependency org="com.puppycrawl.tools" name="checkstyle" rev="5.+" conf="analyse->default" />
31 31
         <dependency org="net.sourceforge.findbugs" name="findbugs-ant" rev="1.+" conf="analyse->default" />
32 32
 
33
+        <dependency org="net.sf.proguard" name="proguard-anttask" rev="4.+" conf="analyse->default" />
34
+
33 35
         <exclude org="ant" module="ant"/>
34 36
     </dependencies>
35 37
 </ivy-module>

Loading…
Cancel
Save