• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1@echo off
2:: Launch FindBugs on a Windows system.
3:: Adapted from scripts found at http://www.ericphelps.com/batch/
4:: This will only work on Windows NT or later!
5
6:: Don't affect environment outside of this invocation
7setlocal
8
9:: ----------------------------------------------------------------------
10:: Set up default values
11:: ----------------------------------------------------------------------
12set appjar=findbugs.jar
13set javahome=
14set launcher=java.exe
15set start=start "FindBugs"
16set jvmargs=
17set debugArg=
18set conserveSpaceArg=
19set workHardArg=
20set args=
21set javaProps=
22set maxheap=768
23
24REM default UI is gui2
25set launchUI=2
26
27:: Try finding the default FINDBUGS_HOME directory
28:: from the directory path of this script
29set default_findbugs_home=%~dp0..
30
31:: Honor JAVA_HOME environment variable if it is set
32if "%JAVA_HOME%"=="" goto nojavahome
33if not exist "%JAVA_HOME%\bin\javaw.exe" goto nojavahome
34set javahome=%JAVA_HOME%\bin\
35:nojavahome
36
37goto loop
38
39:: ----------------------------------------------------------------------
40:: Process command-line arguments
41:: ----------------------------------------------------------------------
42
43:shift2
44shift
45:shift1
46shift
47
48:loop
49
50:: Remove surrounding quotes from %1 and %2
51set firstArg=%~1
52set secondArg=%~2
53
54if "%firstArg%"=="" goto launch
55
56:: AddMessages
57if not "%firstArg%"=="-addMessages" goto notAddMessages
58set fb_mainclass=edu.umd.cs.findbugs.AddMessages
59goto shift1
60:notAddMessages
61
62:: computeBugHistory
63if not "%firstArg%"=="-computeBugHistory" goto notUpdate
64set fb_mainclass=edu.umd.cs.findbugs.workflow.Update
65goto shift1
66:notUpdate
67
68:: convertXmlToText
69if not "%firstArg%"=="-xmltotext" goto notXmlToText
70set fb_mainclass=edu.umd.cs.findbugs.PrintingBugReporter
71goto shift1
72:notXmlToText
73
74:: copyBuggySource
75if not "%firstArg%"=="-copyBS" goto notCopyBS
76set fb_mainclass=edu.umd.cs.findbugs.workflow.CopyBuggySource
77goto shift1
78:notCopyBS
79
80:: defectDensity
81if not "%firstArg%"=="-defectDensity" goto notDefectDensity
82set fb_mainclass=edu.umd.cs.findbugs.workflow.DefectDensity
83goto shift1
84:notDefectDensity
85
86:: filterBugs
87if not "%firstArg%"=="-filterBugs" goto notFilterBugs
88set fb_mainclass=edu.umd.cs.findbugs.workflow.Filter
89goto shift1
90:notFilterBugs
91
92:: listBugDatabaseInfo
93if not "%firstArg%"=="-listBugDatabaseInfo" goto notListBugDatabaseInfo
94set fb_mainclass=edu.umd.cs.findbugs.workflow.ListBugDatabaseInfo
95goto shift1
96:notListBugDatabaseInfo
97
98:: mineBugHistory
99if not "%firstArg%"=="-mineBugHistory" goto notMineBugHistory
100set fb_mainclass=edu.umd.cs.findbugs.workflow.MineBugHistory
101goto shift1
102:notMineBugHistory
103
104:: printAppVersion
105if not "%firstArg%"=="-printAppVersion" goto notPrintAppVersion
106set fb_mainclass=edu.umd.cs.findbugs.workflow.PrintAppVersion
107goto shift1
108:notPrintAppVersion
109
110:: printClass
111if not "%firstArg%"=="-printClass" goto notPrintClass
112set fb_mainclass=edu.umd.cs.findbugs.workflow.PrintClass
113goto shift1
114:notPrintClass
115
116:: rejarForAnalysis
117if not "%firstArg%"=="-rejar" goto notRejar
118set fb_mainclass=edu.umd.cs.findbugs.workflow.RejarClassesForAnalysis
119goto shift1
120:notRejar
121
122:: setBugDatabaseInfo
123if not "%firstArg%"=="-setInfo" goto notSetBugDatabaseInfo
124set fb_mainclass=edu.umd.cs.findbugs.workflow.SetBugDatabaseInfo
125goto shift1
126:notSetBugDatabaseInfo
127
128:: unionBugs
129if not "%firstArg%"=="-unionBugs" goto notUnionBugs
130set fb_mainclass=edu.umd.cs.findbugs.workflow.UnionResults
131goto shift1
132:notUnionBugs
133
134:: xpathFind
135if not "%firstArg%"=="-xpathFind" goto notXPathFind
136set fb_mainclass=edu.umd.cs.findbugs.workflow.XPathFind
137goto shift1
138:notXPathFind
139
140if not "%firstArg%"=="-gui" goto notGui
141set launchUI=2
142set launcher=javaw.exe
143goto shift1
144:notGui
145
146if not "%firstArg%"=="-gui1" goto notGui1
147set launchUI=1
148set javaProps=-Dfindbugs.launchUI=1 %javaProps%
149set launcher=javaw.exe
150goto shift1
151:notGui1
152
153if not "%firstArg%"=="-textui" goto notTextui
154set launchUI=0
155set launcher=java.exe
156set start=
157goto shift1
158:notTextui
159
160if not "%firstArg%"=="-debug" goto notDebug
161set launcher=java.exe
162set start=
163set debugArg=-Dfindbugs.debug=true
164goto shift1
165:notDebug
166
167if not "%firstArg%"=="-help" goto notHelp
168set launchUI=help
169set launcher=java.exe
170set start=
171goto shift1
172:notHelp
173
174if not "%firstArg%"=="-version" goto notVersion
175set launchUI=version
176set launcher=java.exe
177set start=
178goto shift1
179:notVersion
180
181if "%firstArg%"=="-home" set FINDBUGS_HOME=%secondArg%
182if "%firstArg%"=="-home" goto shift2
183
184if "%firstArg%"=="-jvmArgs" set jvmargs=%secondArg%
185if "%firstArg%"=="-jvmArgs" goto shift2
186
187if "%firstArg%"=="-maxHeap" set maxheap=%secondArg%
188if "%firstArg%"=="-maxHeap" goto shift2
189
190if "%firstArg%"=="-conserveSpace" set conserveSpaceArg=-Dfindbugs.conserveSpace=true
191if "%firstArg%"=="-conserveSpace" goto shift1
192
193if "%firstArg%"=="-workHard" set workHardArg=-Dfindbugs.workHard=true
194if "%firstArg%"=="-workHard" goto shift1
195
196if "%firstArg%"=="-javahome" set javahome=%secondArg%\bin\
197if "%firstArg%"=="-javahome" goto shift2
198
199if "%firstArg%"=="-property" set javaProps=-D%secondArg% %javaProps%
200if "%firstArg%"=="-property" goto shift2
201
202if "%firstArg%"=="" goto launch
203
204set args=%args% "%firstArg%"
205goto shift1
206
207:: ----------------------------------------------------------------------
208:: Launch FindBugs
209:: ----------------------------------------------------------------------
210:launch
211:: Make sure FINDBUGS_HOME is set.
212:: If it isn't, try using the default value based on the
213:: directory path of the invoked script.
214:: Note that this will fail miserably if the value of FINDBUGS_HOME
215:: has quote characters in it.
216if not "%FINDBUGS_HOME%"=="" goto checkHomeValid
217set FINDBUGS_HOME=%default_findbugs_home%
218
219:checkHomeValid
220if not exist "%FINDBUGS_HOME%\lib\%appjar%" goto homeNotSet
221
222:found_home
223:: Launch FindBugs!
224if "%fb_mainclass%"=="" goto runJar
225"%javahome%%launcher%" %debugArg% %conserveSpaceArg% %workHardArg% %javaProps% "-Dfindbugs.home=%FINDBUGS_HOME%" -Xmx%maxheap%m %jvmargs% "-Dfindbugs.launchUI=%launchUI%" -cp "%FINDBUGS_HOME%\lib\%appjar%" %fb_mainclass% %args%
226goto end
227:runjar
228%start% "%javahome%%launcher%" %debugArg% %conserveSpaceArg% %workHardArg% %javaProps% "-Dfindbugs.home=%FINDBUGS_HOME%" -Xmx%maxheap%m %jvmargs% "-Dfindbugs.launchUI=%launchUI%" -jar "%FINDBUGS_HOME%\lib\%appjar%" %args%
229goto end
230
231:: ----------------------------------------------------------------------
232:: Report that FINDBUGS_HOME is not set (and was not specified)
233:: ----------------------------------------------------------------------
234:homeNotSet
235echo Could not find FindBugs home directory.  There may be a problem
236echo with the FindBugs installation.  Try setting FINDBUGS_HOME, or
237echo re-installing.
238goto end
239
240:end
241